-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c8794a
commit bf6fc0f
Showing
7 changed files
with
71 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import TutorAd from './tutor-ad'; | ||
|
||
export default TutorAd; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 24 additions & 6 deletions
30
src/app/pages/subjects/new/tutor-ad.js → src/app/pages/subjects/new/tutor-ad.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,47 @@ | ||
import React from 'react'; | ||
import useSubjectsContext from './context'; | ||
import useSubjectsContext, {ImageData} from './context'; | ||
import RawHTML from '~/components/jsx-helpers/raw-html'; | ||
import useOptimizedImage from '~/helpers/use-optimized-image'; | ||
import './tutor-ad.scss'; | ||
|
||
export function TutorAdThatTakesData({heading, image, html, ctaLink, ctaText}) { | ||
export type TutorValue = { | ||
heading: string; | ||
image: ImageData; | ||
adHtml: string; | ||
linkHref: string; | ||
linkText: string; | ||
}; | ||
|
||
export function TutorAdThatTakesData({ | ||
heading, | ||
image, | ||
adHtml, | ||
linkHref, | ||
linkText | ||
}: TutorValue) { | ||
const optimizedImage = useOptimizedImage(image?.file, 400); | ||
|
||
return ( | ||
<section className="tutor-ad"> | ||
<div className="content"> | ||
<h2>{heading}</h2> | ||
<img role="presentation" src={optimizedImage} /> | ||
<RawHTML html={html} /> | ||
<a data-analytics-link className="btn primary" href={ctaLink}>{ctaText}</a> | ||
<RawHTML html={adHtml} /> | ||
<a data-analytics-link className="btn primary" href={linkHref}> | ||
{linkText} | ||
</a> | ||
</div> | ||
</section> | ||
); | ||
} | ||
|
||
export default function TutorAd() { | ||
const {tutorAd} = useSubjectsContext(); | ||
const {image, heading, adHtml: html, linkHref: ctaLink, linkText: ctaText} = tutorAd[0].value; | ||
const {image, heading, adHtml, linkHref, linkText} = tutorAd[0].value; | ||
|
||
return ( | ||
<TutorAdThatTakesData {...{heading, image, html, ctaLink, ctaText}} /> | ||
<TutorAdThatTakesData | ||
{...{heading, image, adHtml, linkHref, linkText}} | ||
/> | ||
); | ||
} |