Files
3df875bd-3de5-46d4-bbca-c04…/src/components/sections/hero/HeroBillboardTestimonial.tsx
2026-05-05 11:59:18 +03:00

164 lines
5.6 KiB
TypeScript

import { motion } from "motion/react";
import { Star } from "lucide-react";
type Testimonial = {
name: string;
handle: string;
text: string;
rating: number;
} & ({ imageSrc: string; videoSrc?: never } | { videoSrc: string; imageSrc?: never });
type HeroBillboardTestimonialProps = {
tag: string;
title: string;
description: string;
primaryButton: { text: string; href: string };
secondaryButton: { text: string; href: string };
testimonials: Testimonial[];
} & ({ imageSrc: string; videoSrc?: never } | { videoSrc: string; imageSrc?: never });
const HeroBillboardTestimonial = ({
tag,
title,
description,
primaryButton,
secondaryButton,
imageSrc,
videoSrc,
testimonials,
}: HeroBillboardTestimonialProps) => {
const testimonial = testimonials[0];
return (
<section
data-webild-section="HeroBillboardTestimonial"
aria-label="Hero section"
className="relative w-full pt-25 pb-20 md:py-hero-page-padding"
>
<div className="flex flex-col gap-8 w-content-width mx-auto">
<div className="flex flex-col items-center gap-3 text-center">
<motion.span
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: "-15%" }}
transition={{ duration: 0.6, ease: "easeOut" }}
className="card rounded-full px-3 py-1 mb-1 text-sm"
>
{tag}
</motion.span>
<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="text-6xl font-medium text-balance"
>
{title}
</motion.h1>
<motion.p
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="text-base md:text-lg leading-tight text-balance"
>
{description}
</motion.p>
<div className="flex flex-wrap justify-center gap-3 mt-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.25, 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.35, 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>
<motion.div
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
viewport={{ once: true, margin: "-15%" }}
transition={{ duration: 0.6, delay: 0.2, ease: "easeOut" }}
className="relative card rounded-theme overflow-hidden p-3 xl:p-4 2xl:p-5 w-full aspect-3/4 md:aspect-video"
>
{videoSrc ? (
<video
src={videoSrc}
autoPlay
muted
loop
playsInline
aria-label="Hero video"
className="w-full h-full object-cover rounded-theme"
/>
) : (
<img
src={imageSrc}
alt=""
className="w-full h-full object-cover rounded-theme"
/>
)}
<figure className="absolute bottom-6 left-6 right-6 md:right-auto md:bottom-8 md:left-8 md:max-w-sm card rounded-theme p-4 flex flex-col gap-3">
<div className="flex gap-1">
{Array.from({ length: 5 }).map((_, i) => (
<Star
key={i}
className={`w-5 h-5 text-accent ${i < testimonial.rating ? "fill-accent" : "fill-transparent"}`}
strokeWidth={1.5}
/>
))}
</div>
<blockquote className="text-base leading-tight text-balance">
{testimonial.text}
</blockquote>
<figcaption className="flex items-center gap-3">
{testimonial.videoSrc ? (
<video
src={testimonial.videoSrc}
autoPlay
muted
loop
playsInline
className="w-10 h-10 rounded-full object-cover"
/>
) : (
<img
src={testimonial.imageSrc}
alt=""
className="w-10 h-10 rounded-full object-cover"
/>
)}
<div className="flex flex-col">
<span className="text-sm font-medium">{testimonial.name}</span>
<span className="text-sm text-muted-foreground">{testimonial.handle}</span>
</div>
</figcaption>
</figure>
</motion.div>
</div>
</section>
);
};
export default HeroBillboardTestimonial;