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
+44
View File
@@ -0,0 +1,44 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { slideLabel } from './slideLabel';
// A position within a carousel: 1 to 20 slides, index within range
const position = fc
.integer({ min: 1, max: 20 })
.chain((count) =>
fc
.integer({ min: 0, max: count - 1 })
.map((index) => ({ index, count })),
);
describe('slideLabel', () => {
it('counts from one', () => {
expect(slideLabel(0, 2)).toBe('Review 1 van 2');
expect(slideLabel(1, 2)).toBe('Review 2 van 2');
});
it('gives back its numbers (round-trip)', () => {
fc.assert(
fc.property(position, ({ index, count }) => {
const [, n, m] =
/^Review (\d+) van (\d+)$/.exec(slideLabel(index, count)) ??
[];
expect(Number(n)).toBe(index + 1);
expect(Number(m)).toBe(count);
}),
);
});
it('always reads "Review n van m" with 1 <= n <= m (invariant)', () => {
fc.assert(
fc.property(position, ({ index, count }) => {
const match = /^Review (\d+) van (\d+)$/.exec(
slideLabel(index, count),
);
expect(match).not.toBeNull();
const [n, m] = [Number(match?.[1]), Number(match?.[2])];
expect(n >= 1 && n <= m).toBe(true);
}),
);
});
});
+5
View File
@@ -0,0 +1,5 @@
// Name of a review in the carousel and what is announced when it changes,
// e.g. "Review 2 van 3". index is zero-based (BR-REV-08, BR-REV-09).
export function slideLabel(index: number, count: number): string {
return `Review ${index + 1} van ${count}`;
}
+73
View File
@@ -0,0 +1,73 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import testimonials from '../content/testimonials';
import { anyTestimonial, uniqueTestimonials } from '../test/arbitraries';
import { isValidTestimonial, visibleTestimonials } from './visibleTestimonials';
const valid = testimonials[0];
describe('visibleTestimonials', () => {
it('keeps the live reviews as they are', () => {
expect(visibleTestimonials(testimonials)).toEqual(testimonials);
});
it('skips reviews that break an invariant', () => {
const broken = [
{ ...valid, id: ' ' },
{ ...valid, id: 'zonder-shoot', shoot: '' },
{ ...valid, id: 'zonder-tekst', quote: ' ' },
{ ...valid, id: 'zonder-naam', author: '' },
{ ...valid, id: 'zonder-foto', image: { ...valid.image, src: '' } },
{ ...valid, id: 'nul-breed', image: { ...valid.image, width: 0 } },
{ ...valid, id: 'nul-hoog', image: { ...valid.image, height: 0 } },
];
expect(visibleTestimonials([...broken, valid])).toEqual([valid]);
});
it('keeps the first of two reviews with the same id', () => {
expect(
visibleTestimonials([valid, { ...valid, author: 'Dubbel' }]),
).toEqual([valid]);
});
it('only returns valid reviews with unique ids (invariant)', () => {
fc.assert(
fc.property(fc.array(anyTestimonial), (input) => {
const result = visibleTestimonials(input);
expect(result.every(isValidTestimonial)).toBe(true);
const ids = result.map((item) => item.id);
expect(new Set(ids).size).toBe(ids.length);
}),
);
});
it('is a subsequence of the input in the same order (invariant)', () => {
fc.assert(
fc.property(fc.array(anyTestimonial), (input) => {
const result = visibleTestimonials(input);
let i = 0;
for (const item of input) {
if (item === result[i]) i++;
}
return i === result.length;
}),
);
});
it('is idempotent', () => {
fc.assert(
fc.property(fc.array(anyTestimonial), (input) => {
const once = visibleTestimonials(input);
expect(visibleTestimonials(once)).toEqual(once);
}),
);
});
it('returns valid, unique reviews unchanged (oracle)', () => {
fc.assert(
fc.property(uniqueTestimonials, (input) => {
expect(visibleTestimonials(input)).toEqual(input);
}),
);
});
});
+29
View File
@@ -0,0 +1,29 @@
import type { Testimonial } from '../content/types.ts';
const filled = (text: string) => text.trim() !== '';
// Whether a review meets the invariants in domain-entities.md
export function isValidTestimonial(item: Testimonial): boolean {
return (
filled(item.id) &&
filled(item.shoot) &&
filled(item.quote) &&
filled(item.author) &&
filled(item.image.src) &&
item.image.width > 0 &&
item.image.height > 0
);
}
// The reviews that can be shown: broken ones from the CMS are skipped, and of
// two with the same id the first wins. The order stays the same (BR-REV-01).
export function visibleTestimonials(
items: readonly Testimonial[],
): Testimonial[] {
const seen = new Set<string>();
return items.filter((item) => {
if (!isValidTestimonial(item) || seen.has(item.id)) return false;
seen.add(item.id);
return true;
});
}