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:
+45
@@ -0,0 +1,45 @@
|
||||
# Business Logic Model — Unit 4: Lieve woorden
|
||||
|
||||
## Navigation flow
|
||||
|
||||
```mermaid
|
||||
sequenceDiagram
|
||||
box rgba(246,224,94,0.4) Visitor
|
||||
participant V as Visitor
|
||||
end
|
||||
box rgba(99,179,237,0.4) Testimonials
|
||||
participant C as Carousel
|
||||
participant L as LiveRegion
|
||||
end
|
||||
V->>C: Next button, dot, arrow key or swipe
|
||||
C->>C: Compute target page, looping at the ends
|
||||
C->>C: Scroll to the target slide, instantly under reduced motion
|
||||
C->>L: Page changed to n
|
||||
L-->>V: Announces Review n van m
|
||||
```
|
||||
|
||||
Text alternative: a navigation action makes the carousel compute the target page (looping), scroll to it (instantly under reduced motion) and report the new page to a polite live region, which announces "Review n van m".
|
||||
|
||||
The carousel state (current page, scrolling, dragging, looping) is Chakra's `Carousel` (Ark UI); this unit does not reimplement it. Our own logic is limited to the pure functions below and wiring `onPageChange` to the live region.
|
||||
|
||||
## Pure functions (`web/src/lib/`)
|
||||
|
||||
| Function | Input → output | Rules |
|
||||
|---|---|---|
|
||||
| `visibleTestimonials(items: Testimonial[]): Testimonial[]` | raw list → shown list | BR-REV-01 |
|
||||
| `slideLabel(index: number, count: number): string` | `(1, 2)` → `'Review 2 van 2'` (index is zero-based) | BR-REV-08/09 |
|
||||
|
||||
## Testable properties (PBT-01)
|
||||
|
||||
| Function | Category | Property |
|
||||
|---|---|---|
|
||||
| `visibleTestimonials` | Invariant | Every result meets the invariants; ids unique |
|
||||
| `visibleTestimonials` | Invariant | Result is a subsequence of the input |
|
||||
| `visibleTestimonials` | Idempotency | Applying it twice equals applying it once |
|
||||
| `visibleTestimonials` | Oracle | Valid, unique input comes back unchanged |
|
||||
| `slideLabel` | Round-trip | The two numbers parsed back from the label are `index + 1` and `count` |
|
||||
| `slideLabel` | Invariant | For `0 ≤ index < count` the label has the form `Review n van m` with `1 ≤ n ≤ m` |
|
||||
|
||||
The looping and paging itself is Chakra's (tested upstream); our component tests cover the behaviour at our boundary: loop from last to first, announcement text, controls hidden for one review, nothing rendered for none. PBT-06 (stateful) is N/A because the state machine is not ours.
|
||||
|
||||
Generators (PBT-07) in `src/test/arbitraries.ts`: `testimonial` (valid; slug ids, non-blank texts, image with positive size), `uniqueTestimonials`, `anyTestimonial` (incl. blank quote/author/shoot, empty src, zero size, duplicate ids).
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
# Business Rules — Unit 4: Lieve woorden
|
||||
|
||||
## Rules
|
||||
|
||||
| ID | Rule | Source |
|
||||
|---|---|---|
|
||||
| BR-REV-01 | Only testimonials that meet the invariants are shown; duplicates by id keep the first; order is kept. | domain-entities.md |
|
||||
| BR-REV-02 | No valid testimonial → the section is not rendered. One → it is shown without arrows, dots or carousel semantics. Two or more → carousel. | FR-HP-05 |
|
||||
| BR-REV-03 | One review is visible at a time; there is no autoplay. | FR-HP-05, design Q2 |
|
||||
| BR-REV-04 | Navigation: previous/next buttons, one dot per review, arrow keys when focus is in the carousel, and swiping (and mouse dragging) on the slides. | FR-HP-05 |
|
||||
| BR-REV-05 | At the ends the carousel loops: "next" on the last review goes to the first, "previous" on the first to the last. The buttons are never disabled. | Q1 = A |
|
||||
| BR-REV-06 | A change slides horizontally (the slides lie side by side; a swipe follows the finger). Under `prefers-reduced-motion` the change is immediate, without animation. | Q2 = A |
|
||||
| BR-REV-07 | Every slide has the height of the tallest one, so the page below does not move when the review changes. | Q3 = A |
|
||||
| BR-REV-08 | Every manual change is announced once, politely, as "Review n van m". Nothing is announced on page load. | NFR-HP-01 |
|
||||
| BR-REV-09 | Each slide is labelled "Review n van m"; the buttons are "Vorige review" / "Volgende review"; each dot is "Review n", and the current dot is marked as current. | NFR-HP-01 |
|
||||
| BR-REV-10 | Off-screen slides are hidden from assistive technology and not focusable. | NFR-HP-01 |
|
||||
| BR-REV-11 | The quote is shown as a blockquote with the author as its caption; the large quotation mark is decorative and hidden from assistive technology. | design |
|
||||
|
||||
## Decision flow: what is rendered (BR-REV-01/02)
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
In["Testimonials from content"] --> Filter["Keep valid, first of each id"]
|
||||
Filter --> Count{"How many remain?"}
|
||||
Count -->|"none"| Nothing["Section not rendered"]
|
||||
Count -->|"one"| Single["Single review, no controls"]
|
||||
Count -->|"two or more"| Carousel["Carousel with arrows, dots, keyboard and swipe, looping"]
|
||||
|
||||
classDef input fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000;
|
||||
classDef decision fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000;
|
||||
classDef outcome fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
|
||||
class In,Filter input;
|
||||
class Count decision;
|
||||
class Nothing,Single,Carousel outcome;
|
||||
```
|
||||
|
||||
Text alternative: after filtering, no testimonials means no section, one means a single review without controls, two or more means a looping carousel with arrows, dots, keyboard and swipe.
|
||||
|
||||
## Decision flow: navigation (BR-REV-05/06/08)
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
Act["Visitor uses arrow, dot, key or swipe"] --> Target{"Past the last or before the first?"}
|
||||
Target -->|"yes"| Wrap["Wrap around to the other end"]
|
||||
Target -->|"no"| Go["Go to the chosen review"]
|
||||
Wrap --> Motion{"Prefers reduced motion?"}
|
||||
Go --> Motion
|
||||
Motion -->|"yes"| Jump["Switch immediately"]
|
||||
Motion -->|"no"| Slide["Slide horizontally"]
|
||||
Jump --> Say["Announce Review n van m once"]
|
||||
Slide --> Say
|
||||
|
||||
classDef input fill:#f6e05e,stroke:#c05621,stroke-width:1px,color:#000;
|
||||
classDef decision fill:#63b3ed,stroke:#2b6cb0,stroke-width:1px,color:#000;
|
||||
classDef outcome fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
|
||||
class Act input;
|
||||
class Target,Motion decision;
|
||||
class Wrap,Go,Jump,Slide,Say outcome;
|
||||
```
|
||||
|
||||
Text alternative: any navigation action wraps around at the ends, then either switches immediately (reduced motion) or slides, and is announced once as "Review n van m".
|
||||
|
||||
## Misuse considerations (SECURITY-11)
|
||||
Testimonials are static content (later from the CMS) and rendered as text by React; no HTML from content is interpreted.
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
# Domain Entities — Unit 4: Lieve woorden
|
||||
|
||||
## Relationships
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
List["Testimonial list"]
|
||||
Item["Testimonial"]
|
||||
Image["ContentImage"]
|
||||
Slide["Carousel slide"]
|
||||
|
||||
List -->|"contains, in display order"| Item
|
||||
Item -->|"has one photo"| Image
|
||||
Item -->|"shown as"| Slide
|
||||
|
||||
classDef entity fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000;
|
||||
classDef value fill:#FF9800,stroke:#e65100,stroke-width:1px,color:#000;
|
||||
classDef ui fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
|
||||
class List,Item entity;
|
||||
class Image value;
|
||||
class Slide ui;
|
||||
```
|
||||
|
||||
Text alternative: the testimonial list holds testimonials in display order; each has one photo and is shown as one carousel slide (blue = data, orange = value, green = UI).
|
||||
|
||||
## Testimonial
|
||||
|
||||
| Field | Type | Required | Description |
|
||||
|---|---|---|---|
|
||||
| `id` | string | yes | Stable, unique key (e.g. `majella-mark`) |
|
||||
| `shoot` | string | yes | Shoot type as a label (e.g. "Trouwshoot") |
|
||||
| `quote` | string | yes | The review text, without quotation marks (the design adds a decorative one) |
|
||||
| `author` | string | yes | Names as they should appear (e.g. "Majella & Mark") |
|
||||
| `image` | ContentImage | yes | Photo for the review, with alt text and size |
|
||||
|
||||
### Invariants
|
||||
- `id` unique within the list.
|
||||
- `shoot`, `quote` and `author` non-empty after trimming.
|
||||
- `image.src` non-empty; `image.width` and `image.height` positive.
|
||||
- List order is the display order.
|
||||
|
||||
Testimonials that break an invariant are skipped; of two with the same id the first is kept (same approach as packages and socials).
|
||||
|
||||
## Initial data (live site, 2026-10-19)
|
||||
|
||||
| id | shoot | author | quote (start) | photo |
|
||||
|---|---|---|---|---|
|
||||
| `majella-mark` | Trouwshoot | Majella & Mark | "Super mooie foto's door Andrea gemaakt op onze trouwdag en pré-wedding shoot. …" | live `IMG_2497-5.jpg` (rings), alt "Bruidegom schuift de trouwring om de vinger van de bruid" |
|
||||
| `demi-kevin` | Newbornshoot | Demi & Kevin | "Heel tevreden met de newbornshoot. …" | live `5-F41A4650-scaled.jpg` (baby's fist), alt "Vuistje van een pasgeboren baby tussen gebreide dekens" |
|
||||
|
||||
Full texts: requirements FR-HP-05.
|
||||
|
||||
## Section content (`HomeContent.testimonials`)
|
||||
|
||||
| Field | Value |
|
||||
|---|---|
|
||||
| `title` | "Lieve woorden" |
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
# Frontend Components — Unit 4: Lieve woorden
|
||||
|
||||
## Hierarchy
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
Route["routes/index.tsx"] --> T["home/Testimonials"]
|
||||
T --> Section["HomeSection tone alt"]
|
||||
T --> Heading["SectionHeading"]
|
||||
T --> Root["Carousel.Root loop"]
|
||||
Root --> Group["Carousel.ItemGroup"]
|
||||
Group --> Item["Carousel.Item x n"]
|
||||
Item --> Slide["home/Testimonials/TestimonialSlide"]
|
||||
Slide --> Framed["FramedImage 4 by 5"]
|
||||
Root --> Control["Carousel.Control: Prev, Indicators, Next"]
|
||||
T --> Live["Live region"]
|
||||
Lib["lib: visibleTestimonials, slideLabel"] -.-> T
|
||||
|
||||
classDef root fill:#4CAF50,stroke:#2e7d32,stroke-width:1px,color:#000;
|
||||
classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000;
|
||||
classDef logic fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000;
|
||||
class Route root;
|
||||
class T,Section,Heading,Root,Group,Item,Slide,Framed,Control,Live ui;
|
||||
class Lib logic;
|
||||
```
|
||||
|
||||
Text alternative: the home route renders Testimonials, which uses HomeSection, SectionHeading, a looping Chakra Carousel with one item per review (each a TestimonialSlide with a FramedImage) and a control bar with previous, dots and next, plus a live region; pure helpers supply the shown reviews and labels.
|
||||
|
||||
## Testimonials
|
||||
- **Props**: `{ content: HomeContent['testimonials']; testimonials: Testimonial[] }`
|
||||
- **Behaviour**: `visibleTestimonials`; none → `null`; one → the `TestimonialSlide` directly (no carousel); two or more → `Carousel.Root` with `slideCount`, `loop`, `allowMouseDrag`, one slide per page.
|
||||
- **Layout**: `HomeSection` with `tone="alt"`, `data-testid="testimonials"`, centred `SectionHeading`. Controls centred below the slides, margin `clamp(2.5rem, 5vw, 4rem)`.
|
||||
- **Equal height** (BR-REV-07): items stretch in the item group's row, so all slides take the tallest height; content vertically centred within.
|
||||
- **Reduced motion** (BR-REV-06): the item group's scrolling is instant (`scroll-behavior: auto`).
|
||||
- **Announcements** (BR-REV-08): a `VisuallyHidden` polite live region, empty on load, set to `slideLabel(page, count)` in `onPageChange`. Any live region Chakra adds itself is checked so only one announcement is made.
|
||||
- **Controls**: `Carousel.PrevTrigger` / `NextTrigger` with Dutch `aria-label`s and arrow icons from the offline icon set (as the hero), 48 px square, `line` border, `ink` border on hover/focus; `Carousel.Indicator` per page, 44 px hit area around an 8 px dot (`accent.deep` outline, filled when current).
|
||||
- **Test ids**: `testimonials`, `testimonials-prev`, `testimonials-next`, `testimonials-dot-{n}`, `testimonial-{id}`.
|
||||
|
||||
## TestimonialSlide
|
||||
- **Props**: `{ testimonial: Testimonial }`
|
||||
- **Layout**: grid `5fr 7fr` from `lg` with gap `clamp(2rem, 6vw, 5.5rem)`, centred vertically; stacked below `lg` with the photo max 420 px wide.
|
||||
- **Photo**: `FramedImage` with aspect `4 / 5` (the source photos are cropped to 4:5 when prepared).
|
||||
- **Text**: decorative quotation mark (Marcellus, `clamp(5rem, 9vw, 7.5rem)`, `accent`, `aria-hidden`); shoot as eyebrow (`accent.deep`); `figure` > `Blockquote` (Marcellus, `clamp(1.35rem, 2.2vw, 1.75rem)`, line-height 1.5, `ink`) > `figcaption` with "— " + author in small caps (`ink.soft`).
|
||||
|
||||
## Accessibility (NFR-HP-01)
|
||||
- Region named by the h2 "Lieve woorden"; the carousel has `aria-roledescription` "carrousel" and a label "Reviews"; slides "Review n van m" (BR-REV-09).
|
||||
- Hidden slides are inert to keyboard and screen readers (BR-REV-10).
|
||||
- Focus ring from the theme on all controls; targets ≥ 44 px.
|
||||
- Axe clean; Lighthouse accessibility stays 1.0.
|
||||
Reference in New Issue
Block a user