|
| 1 | +"use client" |
| 2 | + |
| 3 | +import { LinkButton } from "@/components/ui/LinkButton" |
| 4 | +import { Section } from "@/components/ui/Section" |
| 5 | +import { getMediaUrl } from "@/lib/media" |
| 6 | +import { cn } from "@/lib/utils" |
| 7 | +import type { Media } from "@/payload-types" |
| 8 | +import Image from "next/image" |
| 9 | +import { Card } from "../ui/Card" |
| 10 | + |
| 11 | +interface StandaloneCardSectionProps { |
| 12 | + content?: any | null |
| 13 | +} |
| 14 | + |
| 15 | +function getImage(image: number | Media | null | undefined) { |
| 16 | + return typeof image === "object" ? image : null |
| 17 | +} |
| 18 | + |
| 19 | +export function StandaloneCardSection({ content }: StandaloneCardSectionProps) { |
| 20 | + if (!content || !content.title) return null |
| 21 | + |
| 22 | + const image = getImage(content.image) |
| 23 | + const imageUrl = getMediaUrl(image?.url) |
| 24 | + const itemSettings = content as { |
| 25 | + sectionLayout?: "imageRight" | "imageLeft" | "imageFullscreen" | null |
| 26 | + showImageBorder?: boolean | null |
| 27 | + gradient?: string | null |
| 28 | + gradientDirection?: string | null |
| 29 | + } |
| 30 | + const isImageLeft = itemSettings.sectionLayout === "imageLeft" |
| 31 | + const isFullscreen = itemSettings.sectionLayout === "imageFullscreen" |
| 32 | + const showImageBorder = itemSettings.showImageBorder ?? true |
| 33 | + |
| 34 | + return ( |
| 35 | + <Section showFunnel={false} animation={{ preset: "none" }} className="h-[calc(100vh-6rem)]"> |
| 36 | + <Card |
| 37 | + size="lg" |
| 38 | + gradientDirection={itemSettings.gradientDirection as any} |
| 39 | + radialGradient={itemSettings.gradient as any} |
| 40 | + className={cn(isFullscreen ? "relative h-[80%] overflow-hidden bg-primary p-0" : "relative grid h-[80%] overflow-hidden bg-primary p-12 md:grid-cols-[0.95fr_1.05fr]")} |
| 41 | + > |
| 42 | + {isFullscreen ? ( |
| 43 | + <div className={cn("relative z-10 h-full w-full overflow-hidden rounded-3xl", showImageBorder && "border border-white/10")}> |
| 44 | + {imageUrl && <Image src={imageUrl} alt={image?.alt ?? content.title} fill sizes="100vw" className="object-cover object-center" />} |
| 45 | + </div> |
| 46 | + ) : ( |
| 47 | + <> |
| 48 | + <div className={cn("relative z-10 flex h-full flex-col justify-center gap-8 rounded-3xl", isImageLeft && "md:order-2")}> |
| 49 | + <div className="flex flex-col gap-4"> |
| 50 | + <h2 className="max-w-xl text-3xl font-semibold text-white md:text-5xl">{content.title}</h2> |
| 51 | + <p className="max-w-xl text-base leading-7 text-white/75 md:text-lg">{content.description}</p> |
| 52 | + </div> |
| 53 | + |
| 54 | + <div className="space-y-6"> |
| 55 | + <ul className="grid gap-2 text-sm text-white/75 md:text-base"> |
| 56 | + {content.bulletPoints?.map((point: any, pointIndex: number) => ( |
| 57 | + <li key={`point-${pointIndex}`} className="flex items-start gap-3"> |
| 58 | + <span className="mt-2 h-1.5 w-1.5 shrink-0 rounded-full bg-brand" /> |
| 59 | + <span>{point}</span> |
| 60 | + </li> |
| 61 | + ))} |
| 62 | + </ul> |
| 63 | + |
| 64 | + {content.link?.label && content.link?.url && <LinkButton href={content.link.url}>{content.link.label}</LinkButton>} |
| 65 | + </div> |
| 66 | + </div> |
| 67 | + |
| 68 | + <div className={cn("relative z-10 aspect-video w-full self-center overflow-hidden rounded-2xl", showImageBorder && "border border-white/10", isImageLeft && "md:order-1")}> |
| 69 | + {imageUrl && <Image src={imageUrl} alt={image?.alt ?? content.title} fill sizes="(min-width: 768px) 50vw, 100vw" className="object-contain object-center" />} |
| 70 | + </div> |
| 71 | + </> |
| 72 | + )} |
| 73 | + </Card> |
| 74 | + </Section> |
| 75 | + ) |
| 76 | +} |
0 commit comments