118 lines
4.1 KiB
TypeScript
118 lines
4.1 KiB
TypeScript
import { motion } from "motion/react";
|
|
|
|
type HeroBrandCarouselProps = {
|
|
brand: string;
|
|
description: string;
|
|
primaryButton: { text: string; href: string };
|
|
secondaryButton: { text: string; href: string };
|
|
items: ({ imageSrc: string; videoSrc?: never } | { videoSrc: string; imageSrc?: never })[];
|
|
};
|
|
|
|
const HeroBrandCarousel = ({
|
|
brand,
|
|
description,
|
|
primaryButton,
|
|
secondaryButton,
|
|
items,
|
|
}: HeroBrandCarouselProps) => {
|
|
const featured = items[0];
|
|
|
|
return (
|
|
<section
|
|
data-webild-section="HeroBrandCarousel"
|
|
aria-label="Hero section"
|
|
className="relative w-full h-svh overflow-hidden flex flex-col justify-end"
|
|
>
|
|
{featured.videoSrc ? (
|
|
<video
|
|
src={featured.videoSrc}
|
|
autoPlay
|
|
muted
|
|
loop
|
|
playsInline
|
|
aria-label="Hero video"
|
|
className="absolute inset-0 w-full h-full object-cover"
|
|
/>
|
|
) : (
|
|
<img
|
|
src={featured.imageSrc}
|
|
alt=""
|
|
className="absolute inset-0 w-full h-full object-cover"
|
|
/>
|
|
)}
|
|
|
|
<div
|
|
aria-hidden="true"
|
|
className="absolute inset-x-0 bottom-0 z-1 h-3/5 bg-gradient-to-t from-foreground/70 via-foreground/30 to-transparent"
|
|
/>
|
|
|
|
<div className="relative z-10 w-content-width mx-auto pb-5">
|
|
<div className="flex flex-col gap-5">
|
|
<div className="w-full flex flex-col md:flex-row md:justify-between items-start md:items-end gap-3 md:gap-5">
|
|
<motion.p
|
|
initial={{ opacity: 0, y: 20 }}
|
|
whileInView={{ opacity: 1, y: 0 }}
|
|
viewport={{ once: true, margin: "-15%" }}
|
|
transition={{ duration: 0.6, ease: "easeOut" }}
|
|
className="w-full md:w-1/2 text-lg md:text-2xl text-balance text-primary-cta-text leading-tight"
|
|
>
|
|
{description}
|
|
</motion.p>
|
|
|
|
<div className="w-full md:w-1/2 flex justify-start md:justify-end">
|
|
<div className="flex flex-wrap gap-3">
|
|
<motion.a
|
|
href={primaryButton.href}
|
|
initial={{ opacity: 0, y: 20 }}
|
|
whileInView={{ opacity: 1, y: 0 }}
|
|
viewport={{ once: true, margin: "-15%" }}
|
|
transition={{ duration: 0.6, delay: 0.15, ease: "easeOut" }}
|
|
className="primary-button rounded-theme h-9 px-6 inline-flex items-center justify-center text-sm text-primary-cta-text"
|
|
>
|
|
{primaryButton.text}
|
|
</motion.a>
|
|
<motion.a
|
|
href={secondaryButton.href}
|
|
initial={{ opacity: 0, y: 20 }}
|
|
whileInView={{ opacity: 1, y: 0 }}
|
|
viewport={{ once: true, margin: "-15%" }}
|
|
transition={{ duration: 0.6, delay: 0.25, ease: "easeOut" }}
|
|
className="secondary-button rounded-theme h-9 px-6 inline-flex items-center justify-center text-sm text-secondary-cta-text"
|
|
>
|
|
{secondaryButton.text}
|
|
</motion.a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<motion.h1
|
|
initial={{ opacity: 0, y: 20 }}
|
|
whileInView={{ opacity: 1, y: 0 }}
|
|
viewport={{ once: true, margin: "-15%" }}
|
|
transition={{ duration: 0.6, delay: 0.05, ease: "easeOut" }}
|
|
className="font-semibold text-primary-cta-text text-9xl leading-none text-balance"
|
|
>
|
|
{brand}
|
|
</motion.h1>
|
|
|
|
<div className="flex gap-3 pb-5">
|
|
{items.map((_, i) => (
|
|
<div
|
|
key={i}
|
|
className="relative h-1 w-full rounded-full overflow-hidden bg-primary-cta-text/20"
|
|
aria-hidden="true"
|
|
>
|
|
<div
|
|
className={`absolute inset-0 bg-primary-cta-text rounded-full origin-left ${i === 0 ? "scale-x-100" : "scale-x-0"}`}
|
|
/>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
);
|
|
};
|
|
|
|
export default HeroBrandCarousel;
|