ldc-bien-etre-animal/resources/ts/front/Components/Testimonials/TestimonialsSection.tsx
2026-09-01 15:04:11 +02:00

92 lines
2.6 KiB
TypeScript

import { useState } from "react";
import quoteCloseIcon from "&/images/testimonials/cote_close.png";
import quoteOpenIcon from "&/images/testimonials/cote_open.png";
import Heading from "@/front/Components/Layout/Heading";
import CarouselControls from "@/front/Components/Shared/CarouselControls";
import ContentPanel from "@/front/Components/Shared/ContentPanel";
import TestimonialCard from "@/front/Components/Testimonials/TestimonialCard";
import useDeviceType from "@/hooks/use-device-type";
interface Testimonial {
quote: string;
authorName: string;
authorRole: string;
authorPhoto: string;
logo: string;
}
interface TestimonialsSectionProps {
testimonials: Testimonial[];
rotation?: number;
rotationMobile?: number;
roundedSize?: string;
bgColor?: string;
position?: "left" | "right";
edgeOffset?: string;
}
export default function TestimonialsSection({
testimonials,
rotation = -2,
rotationMobile = 0,
roundedSize = "100px",
bgColor = "bg-bleu",
position = "right",
edgeOffset,
}: Readonly<TestimonialsSectionProps>) {
const [activeIndex, setActiveIndex] = useState(0);
const { isMobile } = useDeviceType();
const goPrev = () => {
setActiveIndex((prev) => (prev === 0 ? testimonials.length - 1 : prev - 1));
};
const goNext = () => {
setActiveIndex((prev) => (prev === testimonials.length - 1 ? 0 : prev + 1));
};
const active = testimonials[activeIndex];
return (
<section className="relative w-full overflow-hidden py-20">
<ContentPanel
bgColor={bgColor}
position={position}
align="start"
rotation={isMobile ? rotationMobile : rotation}
roundedSize={roundedSize}
maxWidth="max-w-[1322px]"
className="w-full py-12 pl-6 pr-6 md:pl-16 md:pr-10"
edgeOffset={edgeOffset}
>
<div className="mx-auto flex max-w-[1160px] flex-col items-center gap-12">
<Heading
level="h2"
color="text-white"
className="self-end text-center lg:text-right"
>
Les témoignages des acteurs
</Heading>
<TestimonialCard
quote={active.quote}
authorName={active.authorName}
authorRole={active.authorRole}
authorPhoto={active.authorPhoto}
logo={active.logo}
quoteOpenIcon={quoteOpenIcon}
quoteCloseIcon={quoteCloseIcon}
/>
<CarouselControls
total={testimonials.length}
activeIndex={activeIndex}
onPrev={goPrev}
onNext={goNext}
onSelect={setActiveIndex}
/>
</div>
</ContentPanel>
</section>
);
}