170 lines
6.1 KiB
TypeScript
170 lines
6.1 KiB
TypeScript
import { Star } from "lucide-react";
|
|
import { motion } from "motion/react";
|
|
|
|
type Testimonial = {
|
|
name: string;
|
|
role: string;
|
|
company: string;
|
|
rating: number;
|
|
} & ({ imageSrc: string; videoSrc?: never } | { videoSrc: string; imageSrc?: never });
|
|
|
|
type Metric = {
|
|
value: string;
|
|
label: string;
|
|
};
|
|
|
|
type TestimonialMetricsCardsProps = {
|
|
tag: string;
|
|
title: string;
|
|
description: string;
|
|
primaryButton?: { text: string; href: string };
|
|
secondaryButton?: { text: string; href: string };
|
|
testimonials: Testimonial[];
|
|
metrics: [Metric, Metric, Metric];
|
|
};
|
|
|
|
const TestimonialMetricsCards = ({
|
|
tag,
|
|
title,
|
|
description,
|
|
primaryButton,
|
|
secondaryButton,
|
|
testimonials,
|
|
metrics,
|
|
}: TestimonialMetricsCardsProps) => {
|
|
return (
|
|
<section
|
|
data-webild-section="TestimonialMetricsCards"
|
|
aria-label="Testimonials section"
|
|
className="relative w-full py-16 md:py-24"
|
|
>
|
|
<div className="flex flex-col gap-8 w-content-width mx-auto">
|
|
<div className="flex flex-col items-center gap-2">
|
|
<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.h2
|
|
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-center text-balance"
|
|
>
|
|
{title}
|
|
</motion.h2>
|
|
|
|
<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="md:max-w-6/10 text-lg leading-tight text-center"
|
|
>
|
|
{description}
|
|
</motion.p>
|
|
|
|
{(primaryButton || secondaryButton) && (
|
|
<div className="flex flex-wrap justify-center gap-3 mt-3">
|
|
{primaryButton && (
|
|
<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>
|
|
)}
|
|
{secondaryButton && (
|
|
<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: "-10%" }}
|
|
transition={{ duration: 0.6, delay: 0.3, ease: "easeOut" }}
|
|
className="grid grid-cols-1 md:grid-cols-3 gap-5"
|
|
>
|
|
{testimonials.map((testimonial) => (
|
|
<div key={testimonial.name} className="relative aspect-3/4 rounded-theme overflow-hidden">
|
|
{testimonial.videoSrc ? (
|
|
<video
|
|
src={testimonial.videoSrc}
|
|
autoPlay
|
|
muted
|
|
loop
|
|
playsInline
|
|
aria-label={testimonial.name}
|
|
className="w-full h-full object-cover"
|
|
/>
|
|
) : (
|
|
<img
|
|
src={testimonial.imageSrc}
|
|
alt={testimonial.name}
|
|
className="w-full h-full object-cover"
|
|
/>
|
|
)}
|
|
<div className="card rounded-theme absolute inset-x-5 bottom-5 flex flex-col gap-2 p-4">
|
|
<div className="flex gap-1 mb-1">
|
|
{Array.from({ length: testimonial.rating }).map((_, i) => (
|
|
<Star key={i} className="size-5 text-accent fill-current" strokeWidth={1.5} />
|
|
))}
|
|
</div>
|
|
<span className="text-2xl font-medium leading-tight">{testimonial.name}</span>
|
|
<div className="flex flex-col">
|
|
<span className="text-base leading-tight">{testimonial.role}</span>
|
|
<span className="text-base leading-tight opacity-75">{testimonial.company}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
))}
|
|
</motion.div>
|
|
|
|
<motion.div
|
|
initial={{ opacity: 0, y: 20 }}
|
|
whileInView={{ opacity: 1, y: 0 }}
|
|
viewport={{ once: true, margin: "-10%" }}
|
|
transition={{ duration: 0.6, delay: 0.4, ease: "easeOut" }}
|
|
className="card rounded-theme flex flex-col md:flex-row items-center justify-between p-8"
|
|
>
|
|
{metrics.map((metric, index) => (
|
|
<div key={metric.label} className="flex flex-col md:flex-row items-center w-full md:flex-1">
|
|
<div className="flex flex-col items-center flex-1 gap-1 text-center py-5 md:py-0">
|
|
<span className="text-5xl font-medium">{metric.value}</span>
|
|
<span className="text-base">{metric.label}</span>
|
|
</div>
|
|
{index < 2 && (
|
|
<div className="w-full h-px md:h-20 md:w-px bg-foreground/20" />
|
|
)}
|
|
</div>
|
|
))}
|
|
</motion.div>
|
|
</div>
|
|
</section>
|
|
);
|
|
};
|
|
|
|
export default TestimonialMetricsCards;
|