"use client"; import React, { memo } from "react"; import MediaContent from "@/components/shared/MediaContent"; import { useCardAnimation } from "@/components/cardStack/hooks/useCardAnimation"; import { cls, shouldUseInvertedText } from "@/lib/utils"; import { useTheme } from "@/providers/themeProvider/ThemeProvider"; import type { CardAnimationType } from "@/components/cardStack/types"; import type { InvertedBackground } from "@/providers/themeProvider/config/constants"; type MediaProps = | { imageSrc: string; imageAlt?: string; videoSrc?: never; videoAriaLabel?: never; } | { videoSrc: string; videoAriaLabel?: string; imageSrc?: never; imageAlt?: never; }; type BannerMedia = MediaProps & { title: string; }; type GridCard = { title: string; description: string; }; type BottomMedia = MediaProps; interface BannerGridAboutProps { bannerMedia: BannerMedia; cards: GridCard[]; bottomMedia: BottomMedia; animationType: CardAnimationType; useInvertedBackground: InvertedBackground; ariaLabel?: string; className?: string; containerClassName?: string; bannerCardClassName?: string; bannerMediaClassName?: string; bannerTitleClassName?: string; gridClassName?: string; cardClassName?: string; cardTitleClassName?: string; cardDescriptionClassName?: string; bottomMediaCardClassName?: string; bottomMediaClassName?: string; } interface GridCardItemProps { card: GridCard; shouldUseLightText: boolean; cardClassName?: string; cardTitleClassName?: string; cardDescriptionClassName?: string; } const GridCardItem = memo(({ card, shouldUseLightText, cardClassName = "", cardTitleClassName = "", cardDescriptionClassName = "", }: GridCardItemProps) => { return (

{card.title}

{card.description}

); }); GridCardItem.displayName = "GridCardItem"; const BannerGridAbout = ({ bannerMedia, cards, bottomMedia, animationType, useInvertedBackground, ariaLabel = "About section", className = "", containerClassName = "", bannerCardClassName = "", bannerMediaClassName = "", bannerTitleClassName = "", gridClassName = "", cardClassName = "", cardTitleClassName = "", cardDescriptionClassName = "", bottomMediaCardClassName = "", bottomMediaClassName = "", }: BannerGridAboutProps) => { const theme = useTheme(); const shouldUseLightText = shouldUseInvertedText(useInvertedBackground, theme.cardStyle); const cardCount = cards.length; // 1 card: 3 items (hero, card, media) // 2 cards: 4 items (hero, card1, media, card2) // 3 cards: 5 items (hero, card1, card2, card3, media) const itemCount = cardCount + 2; const { itemRefs } = useCardAnimation({ animationType, itemCount }); return (
{/* Banner Media Card */}
{ itemRefs.current[0] = el; }} className={cls( "relative w-full aspect-video rounded-theme-capped overflow-hidden", bannerCardClassName )} >

{bannerMedia.title}

{/* Bottom Grid */}
{/* First Card */}
{ itemRefs.current[1] = el; }}>
{/* 1 card: Media on right */} {cardCount === 1 && (
{ itemRefs.current[2] = el; }} className={cls( "relative rounded-theme-capped overflow-hidden aspect-square md:aspect-video", bottomMediaCardClassName )} >
)} {/* 2 cards: Media in middle */} {cardCount === 2 && ( <>
{ itemRefs.current[2] = el; }} className={cls( "relative rounded-theme-capped overflow-hidden aspect-square md:aspect-video order-last md:order-none", bottomMediaCardClassName )} >
{ itemRefs.current[3] = el; }}>
)} {/* 3 cards: Card 2, Card 3, then Media full width */} {cardCount === 3 && ( <>
{ itemRefs.current[2] = el; }}>
{ itemRefs.current[3] = el; }}>
{ itemRefs.current[4] = el; }} className={cls( "relative rounded-theme-capped overflow-hidden aspect-video md:aspect-[16/3] col-span-2 md:col-span-3", bottomMediaCardClassName )} >
)}
); }; BannerGridAbout.displayName = "BannerGridAbout"; export default memo(BannerGridAbout);