Adds the Lieve woorden section to the homepage

Shows client reviews one at a time with the framed photo, a large
quotation mark, the shoot type and the names. Uses Chakra's carousel for
paging, looping and swiping with our own controls, so visitors who
prefer reduced motion get instant changes, and loads the carousel only
when the section comes near the screen so the hero does not wait for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 01:52:41 +02:00
co-authored by Claude Opus 5.5
parent 30dab1af42
commit cb6a9b07f9
30 changed files with 1307 additions and 6 deletions
@@ -0,0 +1,129 @@
import { useState } from 'react';
import {
Box,
Carousel,
chakra,
Flex,
useCarousel,
useMediaQuery,
useRecipe,
VisuallyHidden,
} from '@chakra-ui/react';
import { Icon } from '@iconify/react/offline';
import leftOutlined from '@iconify-icons/ant-design/left-outlined';
import rightOutlined from '@iconify-icons/ant-design/right-outlined';
import type { Testimonial } from '@/content/types';
import { slideLabel } from '@/lib/slideLabel';
import TestimonialSlide from './TestimonialSlide';
// The carousel itself. Chakra's carousel (Zag) handles paging, snapping,
// looping, swiping and hiding off-screen slides. The buttons, dots and arrow
// keys are our own: the built-in ones always scroll smoothly from
// JavaScript, which CSS cannot switch off for visitors who prefer reduced
// motion; ours pass the API's `instant` flag instead (BR-REV-06).
export default function TestimonialCarousel({
testimonials,
}: {
testimonials: Testimonial[];
}) {
const count = testimonials.length;
const [reducedMotion] = useMediaQuery(
['(prefers-reduced-motion: reduce)'],
{ ssr: false },
);
// Empty on load; filled only by a change, so nothing is read out then
const [announcement, setAnnouncement] = useState('');
const carousel = useCarousel({
slideCount: count,
loop: true,
allowMouseDrag: true,
// Room between slides, so the next one never peeks in
spacing: '4rem',
translations: { item: slideLabel },
onPageChange: ({ page }) => setAnnouncement(slideLabel(page, count)),
});
const control = useRecipe({ key: 'carouselControl' });
const previous = () => carousel.scrollPrev(reducedMotion);
const next = () => carousel.scrollNext(reducedMotion);
return (
<Carousel.RootProvider
value={carousel}
aria-label="Reviews"
aria-roledescription="carrousel"
gap={0}
>
{/* Our own live region announces changes, so the item group's
built-in one is switched off to avoid hearing it twice */}
<Carousel.ItemGroup aria-live="off">
{testimonials.map((testimonial, index) => (
// The photo's sand block sticks out 1.5rem to the left
// and below (FramedImage); the item group clips
// everything outside a slide, so each slide makes room
<Carousel.Item
key={testimonial.id}
index={index}
ps={{ base: 0, sm: '1.5rem' }}
pb={{ base: 0, sm: '1.5rem' }}
>
<TestimonialSlide testimonial={testimonial} />
</Carousel.Item>
))}
</Carousel.ItemGroup>
<Flex
justifyContent="center"
alignItems="center"
gap={6}
mt="clamp(2.5rem, 5vw, 4rem)"
onKeyDown={(event) => {
if (event.key === 'ArrowLeft') previous();
else if (event.key === 'ArrowRight') next();
else return;
event.preventDefault();
}}
>
<chakra.button
type="button"
aria-label="Vorige review"
data-testid="testimonials-prev"
css={control({ kind: 'arrow' })}
onClick={previous}
>
<Icon icon={leftOutlined} aria-hidden />
</chakra.button>
<Flex gap={1}>
{testimonials.map((testimonial, index) => (
<chakra.button
key={testimonial.id}
type="button"
aria-label={`Review ${index + 1}`}
aria-current={
carousel.page === index ? 'true' : undefined
}
data-testid={`testimonials-dot-${index + 1}`}
css={control({ kind: 'dot' })}
onClick={() =>
carousel.scrollTo(index, reducedMotion)
}
/>
))}
</Flex>
<chakra.button
type="button"
aria-label="Volgende review"
data-testid="testimonials-next"
css={control({ kind: 'arrow' })}
onClick={next}
>
<Icon icon={rightOutlined} aria-hidden />
</chakra.button>
</Flex>
<Box aria-live="polite" data-testid="testimonials-status">
<VisuallyHidden>{announcement}</VisuallyHidden>
</Box>
</Carousel.RootProvider>
);
}