-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
9 changed files
with
211 additions
and
28 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
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
70 changes: 70 additions & 0 deletions
70
src/components/paragraphs/sup-carousel/sup-carousel-paragraph.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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import {HtmlHTMLAttributes} from "react"; | ||
import {ParagraphSupCarousel, ParagraphSupCarouselSlide} from "@lib/gql/__generated__/drupal.d"; | ||
import Slideshow from "@components/elements/slideshow"; | ||
import {H2} from "@components/elements/headers"; | ||
import Wysiwyg from "@components/elements/wysiwyg"; | ||
import Link from "@components/elements/link"; | ||
import Image from "next/image"; | ||
import {clsx} from "clsx"; | ||
import {twMerge} from "tailwind-merge"; | ||
|
||
type Props = HtmlHTMLAttributes<HTMLDivElement> & { | ||
paragraph: ParagraphSupCarousel | ||
/** | ||
* If the paragraph is configured in the "Top Banner" on Basic Pages. | ||
*/ | ||
isTopBanner?: boolean | ||
} | ||
|
||
const SupCarouselParagraph = ({paragraph, isTopBanner, ...props}: Props) => { | ||
return ( | ||
<div | ||
{...props} | ||
className={twMerge(clsx({"relative pt-[300px] -mb-[300px] -top-[300px] bg-blue-50": isTopBanner}), props?.className)} | ||
> | ||
{paragraph.supCarouselSlides.length === 1 && <Slide slideParagraph={paragraph.supCarouselSlides[0]}/>} | ||
|
||
{paragraph.supCarouselSlides.length > 1 && | ||
<Slideshow slideshowProps={{slidesToShow: 1}}> | ||
{paragraph.supCarouselSlides.map(slide => <div key={slide.id}><Slide key={slide.id} slideParagraph={slide}/> | ||
</div>)} | ||
</Slideshow> | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
const Slide = ({slideParagraph}: { slideParagraph: ParagraphSupCarouselSlide }) => { | ||
const slideTitle = slideParagraph.supSlideTitle || slideParagraph.supSlideBook?.title | ||
const image = slideParagraph.supSupImage?.mediaImage || slideParagraph.supSlideBook?.supBookImage?.mediaImage; | ||
|
||
return ( | ||
<article aria-labelledby={slideParagraph.id} className="centered-container"> | ||
<div className="xl:flex gap-10 xl:w-2/3 mx-auto"> | ||
{image && | ||
<div className="relative aspect-[9/16] w-1/3"> | ||
<Image | ||
className="object-cover" | ||
src={image.url} | ||
alt={image.alt || ""} | ||
fill | ||
/> | ||
</div> | ||
} | ||
<div> | ||
<div className="flex flex-col"> | ||
{slideTitle && <H2 id={slideParagraph.id}>{slideTitle}</H2>} | ||
{slideParagraph.supSlideEyebrow && <div className="order-first">{slideParagraph.supSlideEyebrow}</div>} | ||
</div> | ||
|
||
{slideParagraph.supSlideSubtitle && <div>{slideParagraph.supSlideSubtitle}</div>} | ||
{slideParagraph.supSlideBody && <Wysiwyg html={slideParagraph.supSlideBody.processed}/>} | ||
{slideParagraph.supSlideButton?.url && | ||
<Link href={slideParagraph.supSlideButton.url}>{slideParagraph.supSlideButton.title}</Link> | ||
} | ||
</div> | ||
</div> | ||
</article> | ||
) | ||
} | ||
export default SupCarouselParagraph |
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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