Adds the Prijzen section to the homepage

Shows the three live packages as cards with their price and what is
included. Each card links to the contact section with ?pakket=<id>, so
the contact form can preselect it. Invalid packages from the CMS are
skipped and the pakket value is only accepted when it names a package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 01:07:36 +02:00
co-authored by Claude Opus 5.5
parent 0b54a67dc4
commit 30dab1af42
32 changed files with 1250 additions and 6 deletions
@@ -5,7 +5,7 @@
- **Feature Slug**: homepage-sections
- **Project Type**: Brownfield
- **Start Date**: 2026-10-19T19:19:38Z
- **Current Stage**: CONSTRUCTION - Unit 2 Over mij - Code Generation (awaiting approval)
- **Current Stage**: CONSTRUCTION - Unit 3 Prijzen - Code Generation (awaiting approval)
- **Branch**: feature/homepage-sections
## Workspace State
@@ -62,11 +62,11 @@
- [x] Units Generation - EXECUTE (approved)
### 🟢 CONSTRUCTION PHASE
- [ ] Functional Design - EXECUTE (Prijzen, Lieve woorden, Contact) / SKIP (Lifestyle fotografie, Over mij, Instagram)
- [ ] Functional Design - EXECUTE (Prijzen ✅, Lieve woorden, Contact) / SKIP (Lifestyle fotografie, Over mij, Instagram)
- [ ] NFR Requirements - SKIP
- [ ] NFR Design - SKIP
- [ ] Infrastructure Design - SKIP
- [ ] Code Generation - EXECUTE (per unit) — Unit 1 Lifestyle fotografie ✅ (approved)
- [ ] Code Generation - EXECUTE (per unit) — Unit 1 Lifestyle fotografie ✅, Unit 2 Over mij ✅ (desktop review deferred by user)
- [ ] Build and Test - EXECUTE
### 🟡 OPERATIONS PHASE
@@ -74,8 +74,8 @@
## Current Status
- **Lifecycle Phase**: CONSTRUCTION
- **Current Stage**: Unit 2 Over mij — Code Generation complete, awaiting approval
- **Next Stage**: Unit 3 Prijzen — Functional Design
- **Current Stage**: Unit 3 Prijzen — Code Generation complete, awaiting approval
- **Next Stage**: Unit 3 Prijzen — Code Generation
## Reverse Engineering Status
- [x] Reverse Engineering - Artifacts refreshed on 2026-10-19T19:19:38Z at commit 38c5c3e (approved 2026-10-19T19:31:00Z)
@@ -305,3 +305,103 @@ Nou is het nog een statische site zonder back-end dus het contactformulier kan n
**Context**: CONSTRUCTION - Unit 2 Code Generation (complete, awaiting approval)
---
## Unit 2 Over mij — Approval
**Timestamp**: 2026-10-20T01:25:00Z
**User Input**: "Op mobiel ziet het er goed uit. Op desktop kan ik nu niet goed zien. Dus als ik daar issues mee heb zal ik het later via bugfixes oppakken.. ga verder"
**AI Response**: "Unit 2 approved (desktop review deferred by the user; issues will come in as bug fixes). Proceeding to Unit 3 Prijzen — Functional Design."
**Context**: CONSTRUCTION - Unit 2 complete; Unit 3 start
---
## Unit 3 Prijzen — Functional Design Plan and Questions
**Timestamp**: 2026-10-20T01:30:00Z
**User Input**: (none — AI-initiated)
**AI Response**: "Created construction/plans/prijzen-functional-design-plan.md (7 steps) and prijzen-fd-questions.md with 5 questions: VAT note, accessible names for the three 'Boek je shoot' links, second click behaviour, keeping ?pakket in the URL, package without a price."
**Context**: CONSTRUCTION - Unit 3 Functional Design (awaiting answers)
---
## Unit 3 Prijzen — Functional Design Answers
**Timestamp**: 2026-10-20T01:40:00Z
**User Input**: "1C
2b, mits dat past anders 2a. De knop moet 1 regel blijven. In ieder geval op desktop
3a
4b
5a"
**AI Response**: "Recorded answers in prijzen-fd-questions.md. Interpretation: Q1 C — Andrea uses the KOR, no VAT note. Q2 — deterministic rule: visible 'Boek {name}' when the name is short enough to stay on one line down to a 320px phone (≤ 14 characters), otherwise 'Boek je shoot' with the package name as visually hidden text; button never wraps. Q3 A — last click wins. Q4 B — ?pakket is removed from the URL (history replace, keeping #contact) as soon as the form has taken over the value; a reload no longer keeps the choice. Q5 A — price required. Generating functional design artifacts."
**Context**: CONSTRUCTION - Unit 3 Functional Design (answers received)
---
## Unit 3 Prijzen — Functional Design Complete
**Timestamp**: 2026-10-20T01:55:00Z
**User Input**: (none — generation)
**AI Response**: "Generated construction/prijzen/functional-design/: domain-entities.md (PricingPackage invariants, initial live data, KOR note), business-rules.md (BR-PRICE-01..03, BR-BOOK-01..03 with the 14-character label rule, BR-PARAM-01..04, two decision flowcharts, misuse notes), business-logic-model.md (booking sequence, four pure functions incl. new visiblePackages and bookLabel, 11 PBT properties, generators), frontend-components.md (Pricing, PriceCard, route validateSearch, accessibility). Prompt: Request Changes or Continue to Code Generation."
**Context**: CONSTRUCTION - Unit 3 Functional Design (awaiting approval)
---
## Unit 3 Prijzen — Functional Design Approval
**Timestamp**: 2026-10-20T02:00:00Z
**User Input**: "Ga verder"
**AI Response**: "Functional design approved. Proceeding to Code Generation Part 1 (planning) for unit 3."
**Context**: CONSTRUCTION - Unit 3 Functional Design approved
---
## Unit 3 Prijzen — Code Generation Plan
**Timestamp**: 2026-10-20T02:05:00Z
**User Input**: (none — AI-initiated)
**AI Response**: "Created construction/plans/prijzen-code-generation-plan.md (17 steps): decorations copied, content types and data, four pure helpers with PBT, arbitraries, linkButton 'fit' size (nowrap, smaller phone padding), PriceCard, Pricing, route validateSearch, app tests, pnpm check with visual check at 1440/390/320, summary, commit. Prompt: approve plan or request changes."
**Context**: CONSTRUCTION - Unit 3 Code Generation Part 1 (awaiting plan approval)
---
## Unit 3 Prijzen — Plan Approval
**Timestamp**: 2026-10-20T02:08:00Z
**User Input**: "Approve plan"
**AI Response**: "Plan approved. Starting Code Generation Part 2."
**Context**: CONSTRUCTION - Unit 3 Code Generation Part 2 (start)
---
## Unit 3 Prijzen — Code Generation Complete
**Timestamp**: 2026-10-20T03:05:00Z
**User Input**: (none — generation)
**AI Response**: "Executed all 17 steps. Step 13.5: tsc rejected search on chakra(Link) (route generics lost) — switched the card link to TanStack's typed Link with the linkButton recipe via asChild; two test assertions corrected (NBSP normalisation, alt='' role); ESLint no-irregular-whitespace from escapes written as literal characters — rewritten as escapes, src scanned. Visual check found the second decoration covered by the last card — moved into the section's bottom padding. Final pnpm check green: 170 tests, 100% coverage on new lib files, Lighthouse home mobile 0.83–0.89, desktop 1.0, a11y/BP/SEO 1.0. Committed locally (not pushed)."
**Context**: CONSTRUCTION - Unit 3 Code Generation (complete, awaiting approval)
---
@@ -0,0 +1,62 @@
# Code Generation Plan — Unit 3: Prijzen
**This plan is the single source of truth for Code Generation of unit 3.**
## Unit context
- **Requirements**: FR-HP-04, FR-HP-11, FR-HP-12, NFR-HP-01/02/03/04/05/06
- **Functional design**: [prijzen/functional-design/](../prijzen/functional-design/) — BR-PRICE-01…03, BR-BOOK-01…03, BR-PARAM-01 (BR-PARAM-02…04 are carried out in unit 5)
- **Depends on**: unit 1 (`HomeSection`, `SectionHeading`, `Reveal`, `DeferredImage`, `ContentImage`)
- **Introduces for unit 5**: `PricingPackage`, `content/packages.ts`, `visiblePackages`, `packageFromSearch`, `pakket` search on `/`
- **PBT**: full enforcement — properties from business-logic-model.md for all four helpers; generators per PBT-07.
- Conventions as in units 1–2.
## Steps
### Assets and content
- [x] **Step 1** — Copy `design/andreaslop-static/assets/img/deco-1.png` (143×112, 15 KB) and `deco-2.png` (239×224, 42 KB) unchanged to `web/src/assets/home/`.
- [x] **Step 2** — `content/types.ts`: `PricingPackage { id; name; price; features }`; `HomeContent.pricing { title; lead; decorations: ContentImage[] }`.
- [x] **Step 3** — `content/packages.ts`: the three live packages in live order (domain-entities.md). `content/homeContent.ts`: pricing title "Prijzen", lead "Pakketten", two decorations with `alt=""` and their sizes.
### Pure helpers (each with example-based and property-based tests)
- [x] **Step 4** — `lib/formatPrice.ts` (+ test): `Intl.NumberFormat('nl-NL', { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 })`; ensures a non-breaking space after `€` (BR-PRICE-01). Properties: digit round-trip, prefix and no regular space.
- [x] **Step 5** — `lib/visiblePackages.ts` (+ test): invariants filter and first-wins de-duplication (BR-PRICE-02). Properties: every result valid, unique ids, subsequence, idempotent, oracle for valid unique input.
- [x] **Step 6** — `lib/bookLabel.ts` (+ test): `BOOK_LABEL_MAX_NAME = 14`; `{ visible: 'Boek <name>' }` or `{ visible: 'Boek je shoot', hidden: ': <name>' }` (BR-BOOK-02). Properties: name always in the full text; visible form exactly per the length rule.
- [x] **Step 7** — `lib/packageFromSearch.ts` (+ test): string only, trimmed, case-insensitive match → the package's id (BR-PARAM-01). Properties: result is undefined or a given id; any-case/whitespace oracle; non-strings undefined; idempotent.
- [x] **Step 8** — `test/arbitraries.ts`: `pricingPackage` (valid), `uniquePackages`, `anyPackage` (incl. invalid: empty name, price 0 / negative / fractional / NaN, bad id, duplicates).
### Styling
- [x] **Step 9** — `recipes/linkButton.ts`: new `size` variant `fit` — `white-space: nowrap`, horizontal padding 1.25 rem on phones and the design's 2.4 rem from `sm` (BR-BOOK-03); default size unchanged so the hero button stays as it is. Verify at an emulated 320 px phone that "Boek Zwangerschap" stays on one line inside the card.
### Components
- [x] **Step 10** — `components/home/Pricing/PriceCard.tsx`: `article` with h3, formatted price (`accent.deep`), feature list, `LinkButton` (`size="fit"`) to `/` with `search={{ pakket: id }}` and `hash="contact"`, label per `bookLabel` with `VisuallyHidden`; hover lift/border/shadow, none under reduced motion; `data-testid`s per frontend-components.md.
- [x] **Step 11** — `components/home/Pricing/Pricing.tsx`: `HomeSection` (plain), decorations (`DeferredImage`, `aria-hidden`, positioned behind content), `SectionHeading` with lead, grid of `PriceCard`s from `visiblePackages` (1 column max 460 px centred below `lg`, 3 from `lg`), staggered `Reveal`; renders nothing when no package is valid.
- [x] **Step 12** — `components/home/Pricing/Pricing.test.tsx` and `PriceCard.test.tsx`: region "Prijzen", three cards in order with h3, price `€ 175` etc., features as list items, link names "Boek Zwangerschap" / "Boek Newborn" / "Boek Gezin" with `href="/?pakket=<id>#contact"`, long name → "Boek je shoot" + hidden name, invalid packages skipped, empty list → no section, decorations hidden from assistive technology, axe clean.
### Route
- [x] **Step 13** — `routes/index.tsx`: `validateSearch` → `{ pakket?: string }` (string kept, everything else dropped); render `Pricing` after `AboutBlock` with `homeContent.pricing` and `packages`.
- [x] **Step 14** — `app.test.tsx`: "Prijzen" in the page-order check; `/?pakket=newborn` and `/?pakket=123` both render the homepage without errors.
### Verification and wrap-up
- [x] **Step 15** — `pnpm check` (coverage 100% for the new `lib/` files, Lighthouse); visual check desktop 1440 and phones 390 and 320.
- [x] **Step 16** — `construction/prijzen/code/code-summary.md`.
- [x] **Step 17** — Commit ("Adds the Prijzen section to the homepage" + attribution). Not pushed.
## Requirement / rule traceability
| Item | Steps |
|---|---|
| FR-HP-04 | 2, 3, 10–14 |
| BR-PRICE-01 | 4, 10 |
| BR-PRICE-02 | 5, 11 |
| BR-PRICE-03 | — (no note rendered) |
| BR-BOOK-01 | 10, 12 |
| BR-BOOK-02 | 6, 10, 12 |
| BR-BOOK-03 | 9, 15 |
| BR-PARAM-01 | 7, 13, 14 |
| NFR-HP-01 | 10–12, 15 |
| NFR-HP-03 / PBT | 4–8, 12, 14, 15 |
| NFR-HP-05 | 1, 11, 15 |
| NFR-HP-06 | 2, 3 |
## Extension compliance (planned)
- **Security**: `pakket` never reflected, only known ids come out (SECURITY-05 spirit for client input, SECURITY-11 misuse noted); no new dependencies or external resources.
- **PBT**: PBT-01 done in functional design; PBT-02 (round-trip formatPrice), PBT-03 (invariants), PBT-04 (idempotency), PBT-05 (oracles), PBT-07 (domain generators), PBT-08/09 (existing seed setup), PBT-10 (example tests alongside). PBT-06 N/A (no stateful component in this unit).
@@ -0,0 +1,50 @@
# Functional Design Questions — Unit 3: Prijzen
Vul per vraag de letter in na `[Answer]:`. Past geen enkele optie, kies dan de laatste (Anders) en licht toe. Waar ik een voorkeur heb staat **(aanbevolen)**.
## Vraag 1: BTW bij de prijzen
Voor consumenten moeten prijzen in Nederland inclusief btw getoond worden. Op de live site staat er niets bij.
- A) De prijzen zijn inclusief btw; zet er een korte regel onder de kaarten: "Alle prijzen zijn inclusief btw." (aanbevolen, als Andrea btw rekent)
- B) De prijzen zijn inclusief btw; geen extra regel, net als nu op de live site
- C) Andrea valt onder de kleineondernemersregeling (KOR) en rekent geen btw; geen regel nodig
- X) Anders (beschrijf hieronder na de [Answer]:-tag)
[Answer]: C
## Vraag 2: Drie keer "Boek je shoot"
Elke kaart heeft een knop met dezelfde tekst. Een schermlezer die alle links opsomt, hoort dan drie keer "Boek je shoot" zonder te weten welk pakket.
- A) Zichtbaar blijft "Boek je shoot"; voor schermlezers komt de naam van het pakket erbij ("Boek je shoot: Newborn"), via verborgen tekst. (aanbevolen)
- B) De zichtbare tekst wordt "Boek Newborn", "Boek Zwangerschap", enzovoort
- C) Zo laten, drie keer dezelfde tekst
- X) Anders (beschrijf hieronder na de [Answer]:-tag)
[Answer]: B, mits dat past, anders A. De knop moet 1 regel blijven, in ieder geval op desktop.
## Vraag 3: Nog een keer klikken
Een bezoeker klikt "Boek je shoot" bij Newborn, kiest in het formulier zelf toch "Gezin", scrolt terug en klikt "Boek je shoot" bij Zwangerschap.
- A) De laatste klik wint: het formulier springt naar Zwangerschap. De bezoeker heeft immers net opnieuw gekozen. (aanbevolen)
- B) Wat de bezoeker zelf in het formulier koos, blijft staan; een klik vult alleen een lege keuze in
- X) Anders (beschrijf hieronder na de [Answer]:-tag)
[Answer]: A
## Vraag 4: `?pakket=` in de adresbalk
Na een klik staat bijvoorbeeld `andreaslop.nl/?pakket=newborn#contact` in de adresbalk.
- A) Laten staan. De link is te delen ("boek een newbornshoot"), en een refresh houdt de keuze vast. (aanbevolen)
- B) Na het invullen van het formulier weghalen, zodat de adresbalk weer `andreaslop.nl/` toont; delen kan dan niet meer
- X) Anders (beschrijf hieronder na de [Answer]:-tag)
[Answer]: B
## Vraag 5: Pakket zonder prijs
Straks levert de API de pakketten. Wat als Andrea een pakket zonder vaste prijs toevoegt (bijv. een bruiloft)?
- A) Prijs is altijd verplicht; een pakket zonder prijs kan niet (de API controleert dat). Eenvoudigst. (aanbevolen)
- B) Prijs is optioneel; zonder prijs toont de kaart "Prijs op aanvraag"
- X) Anders (beschrijf hieronder na de [Answer]:-tag)
[Answer]: A
@@ -0,0 +1,11 @@
# Functional Design Plan — Unit 3: Prijzen
Scope: FR-HP-04 (cards, link with package), the package data that unit 5 reuses, and the `pakket` search parameter on `/`. Questions: [prijzen-fd-questions.md](prijzen-fd-questions.md).
- [x] 1. Collect and analyze answers (follow-up questions if needed)
- [x] 2. `domain-entities.md` — `PricingPackage`, its invariants (unique id slug, positive whole-euro price, non-empty features) and its relation to the contact form's shoot options
- [x] 3. `business-rules.md` — price formatting, `pakket` search parameter (accepted values, unknown/invalid values, multiple values, case), link targets, what happens on a second "Boek je shoot" click, VAT note, accessible link names; decision flowchart
- [x] 4. `business-logic-model.md` — flow from "Boek je shoot" via the URL to the preselected form value (unit 5 consumes it), and the pure functions `formatPrice` and `packageFromSearch`
- [x] 5. `frontend-components.md` — `Pricing`, `PriceCard`, decorations; props, states (hover, focus, reduced motion), responsive layout, accessibility
- [x] 6. PBT-01 property identification for `formatPrice` and `packageFromSearch` (invariants, oracle, idempotency where relevant)
- [x] 7. Validate against FR-HP-04, NFR-HP-01/02/03/06 and the Security/PBT extensions
@@ -0,0 +1,51 @@
# Code Summary — Unit 3: Prijzen
Plan: [prijzen-code-generation-plan.md](../../plans/prijzen-code-generation-plan.md). Functional design: [../functional-design/](../functional-design/). Branch: `feature/homepage-sections`.
## Files
### Created
| File | Purpose |
|---|---|
| `web/src/assets/home/deco-1.png`, `deco-2.png` | Design decorations, unchanged (15 KB, 42 KB) |
| `web/src/content/packages.ts` | The three live packages (Zwangerschap 175, Newborn 185, Gezin 175) |
| `web/src/lib/formatPrice.ts` + test | `€ 175` with a non-breaking space (BR-PRICE-01) |
| `web/src/lib/visiblePackages.ts` + test | `isValidPackage` + filter with first-wins de-duplication (BR-PRICE-02) |
| `web/src/lib/bookLabel.ts` + test | "Boek <name>" up to 14 characters, else "Boek je shoot" + hidden name (BR-BOOK-02) |
| `web/src/lib/packageFromSearch.ts` + test | `?pakket=` → known id or undefined (BR-PARAM-01) |
| `web/src/components/home/Pricing/Pricing.tsx` + test | The section: decorations, heading, card grid |
| `web/src/components/home/Pricing/PriceCard.tsx` + test | One package card with the booking link |
### Modified
| File | Change |
|---|---|
| `web/src/content/types.ts` | `PricingPackage`; `HomeContent.pricing` |
| `web/src/content/homeContent.ts` | Pricing title, lead, decorations |
| `web/src/recipes/linkButton.ts` | `size: 'fit'` — no wrapping, smaller side padding on phones (BR-BOOK-03); default unchanged |
| `web/src/theme.ts` | Shadow token `lift` for the card hover |
| `web/src/test/arbitraries.ts` | `pricingPackage`, `uniquePackages`, `anyPackage` |
| `web/src/routes/index.tsx` | `validateSearch` keeps `pakket` only as a string; renders `Pricing` after `AboutBlock` |
| `web/src/app.test.tsx` | "Prijzen" in the page order; `?pakket=newborn`, `?pakket=123` and `?pakket=<script>` render without errors and without reflecting the value |
## Notes and deviations
- **Typed link**: the shared `RouterLink` (`chakra(Link)`) drops TanStack Router's route generics, so `search={{ pakket }}` would not type-check. The card uses the router's own `Link` with the `linkButton` recipe applied via Chakra's `asChild`, so the search parameter is checked against the homepage route.
- **Second decoration**: the design positions it relative to the whole section; in the content box the last card covered it, so it was moved into the section's bottom padding (found in the visual check).
- **Literal special spaces**: an editing tool turned ` `/` ` escapes into the characters themselves, which ESLint rejects (`no-irregular-whitespace`); they were written back as escapes and `src` was scanned for others.
## Property-based tests (PBT)
| Function | Properties |
|---|---|
| `formatPrice` | digit round-trip; starts with `€` + NBSP, no breaking space |
| `visiblePackages` | only valid + unique ids; subsequence; idempotent; oracle on valid unique input |
| `bookLabel` | name always in the full text; visible form follows the 14-character rule |
| `packageFromSearch` | result undefined or a given id; any case/whitespace oracle; non-strings undefined; idempotent |
## Verification (`pnpm check`)
- Lint ✅, Prettier ✅, build ✅
- Tests: 38 files, **170 passed**; 100% coverage on the new `lib/` files (threshold)
- Lighthouse home: mobile **0.83–0.89** across runs (LCP 2.3–3.9 s), desktop **1.0**; accessibility, best practices, SEO **1.0**
- Visual check (CDP): 1440 three cards with decorations; 390 and 320 one column; "Boek Zwangerschap" stays on one line at 320 px
## Extension compliance
- **Security Baseline**: `pakket` never reflected (tested with a script-like value); only known ids come out; no new dependencies or external resources. Other rules N/A.
- **PBT**: PBT-02/03/04/05 covered per the table, PBT-07 domain generators, PBT-08/09 existing setup, PBT-10 example tests alongside; PBT-06 N/A (no stateful component).
@@ -0,0 +1,53 @@
# Business Logic Model — Unit 3: Prijzen
## Booking flow (across units 3 and 5)
```mermaid
sequenceDiagram
box rgba(246,224,94,0.4) Visitor
participant V as Visitor
end
box rgba(99,179,237,0.4) Homepage
participant Card as PriceCard
participant Route as RouteIndex
participant Form as ContactForm
end
V->>Card: Clicks Boek Newborn
Card->>Route: Navigate to the homepage with pakket newborn and hash contact
Route->>Route: packageFromSearch checks the value against the shown packages
Route->>Form: Preselected package id newborn
Route-->>V: Scrolls to the contact section
Form->>Form: Selects newborn, replacing any earlier choice
Form->>Route: Remove pakket from the URL with history replace
```
Text alternative: a click on a price card navigates to the homepage with the package in the URL; the route validates it and hands it to the contact form, scrolls to the contact section, and after the form has selected the package the parameter is removed from the URL.
## Pure functions (`web/src/lib/`)
| Function | Input → output | Rules |
|---|---|---|
| `formatPrice(euros: number): string` | `185` → `'€ 185'` | BR-PRICE-01 |
| `visiblePackages(packages: PricingPackage[]): PricingPackage[]` | raw list → shown list | BR-PRICE-02 |
| `bookLabel(name: string): { visible: string; hidden?: string }` | `'Newborn'` → `{ visible: 'Boek Newborn' }`; a 15+ character name → `{ visible: 'Boek je shoot', hidden: ': <name>' }` | BR-BOOK-02 |
| `packageFromSearch(value: unknown, packages: PricingPackage[]): string \| undefined` | `'Newborn '` → `'newborn'`; `'onbekend'` → `undefined` | BR-PARAM-01 |
The route's `validateSearch` only keeps `pakket` when it is a string (anything else becomes `undefined`); `packageFromSearch` does the matching against the shown packages.
## Testable properties (PBT-01)
| Function | Category | Property |
|---|---|---|
| `formatPrice` | Round-trip | For any positive integer `n`, removing everything but digits from `formatPrice(n)` gives back `n` |
| `formatPrice` | Invariant | Output starts with `€` followed by a non-breaking space and contains no regular space |
| `visiblePackages` | Invariant | Every result meets all invariants; ids are unique |
| `visiblePackages` | Invariant | The result is a subsequence of the input (order kept, nothing invented) |
| `visiblePackages` | Idempotency | `visiblePackages(visiblePackages(x))` equals `visiblePackages(x)` |
| `visiblePackages` | Oracle | A list of only valid, unique packages comes back unchanged |
| `bookLabel` | Invariant | The visible text plus the hidden text always contains the name; the visible text is `Boek <name>` exactly when the name has ≤ 14 characters, otherwise `Boek je shoot` |
| `packageFromSearch` | Invariant | The result is `undefined` or the id of one of the given packages |
| `packageFromSearch` | Oracle | For every package, its id in any letter case and with surrounding spaces returns that id |
| `packageFromSearch` | Invariant | Non-string input always gives `undefined` |
| `packageFromSearch` | Idempotency | Feeding the result back in gives the same result |
Generators (PBT-07) are added to `src/test/arbitraries.ts`: a valid `pricingPackage` (slug ids, Dutch-like names, 1–5 features, prices 1–5000), a list with unique ids, and an `anyPackage` mix that includes invalid ones (empty name, price 0 / negative / fractional / NaN, bad id, duplicates).
@@ -0,0 +1,65 @@
# Business Rules — Unit 3: Prijzen
## Rules
| ID | Rule | Source |
|---|---|---|
| BR-PRICE-01 | A price is shown as `€` + non-breaking space + the amount in Dutch notation without decimals: `€ 175`, `€ 1.250`. The non-breaking space keeps the price on one line. | Live site, NFR-HP-01 |
| BR-PRICE-02 | Only packages that meet the invariants (domain-entities.md) are shown; invalid ones are skipped, duplicates by id keep the first. The order of the list is kept. | Q5 = A, robustness for API data |
| BR-PRICE-03 | No VAT note (KOR). | Q1 = C |
| BR-BOOK-01 | Each card has one link to the contact section of the homepage with the package id: `/?pakket=<id>#contact`. | FR-HP-04, design Q4 |
| BR-BOOK-02 | The visible link text is `Boek <name>` when the name has at most **14 characters**; otherwise `Boek je shoot` with the package name added as visually hidden text (`Boek je shoot: <name>` for screen readers). 14 characters is what fits on one line in the button down to a 320 px phone. | Q2 = B if it fits, else A |
| BR-BOOK-03 | The button text never wraps (one line on every screen width); on phones the button uses less horizontal padding so the longest allowed label still fits. | Q2 |
| BR-PARAM-01 | `pakket` is accepted only as a string that matches a shown package id, compared case-insensitively and trimmed; the result is the package's own id. Anything else (unknown id, empty, number, array, missing) is ignored without an error. | design Q4, security (no reflection of input) |
| BR-PARAM-02 | When the form has taken over the package, `pakket` is removed from the address bar with a history *replace* (the `#contact` hash stays, no extra history entry, no scroll jump). Reloading the page therefore no longer preselects. | Q4 = B |
| BR-PARAM-03 | Every "Boek" click selects that package in the form, also when the visitor had chosen something else in the form before: the last click wins. | Q3 = A |
| BR-PARAM-04 | Applying, ignoring and removing `pakket` happen the same way whether the form is switched on or covered by the coming-soon gate. | FR-HP-07 |
BR-PARAM-02/03/04 are carried out by the contact form (unit 5); this unit defines them and delivers `packageFromSearch` and the links.
## Decision flow: link label (BR-BOOK-02)
```mermaid
graph TD
Start["Package name"] --> Len{"At most 14 characters?"}
Len -->|"yes"| Short["Visible: Boek name"]
Len -->|"no"| Long["Visible: Boek je shoot"]
Long --> Hidden["Hidden for screen readers: colon and name"]
Short --> Done["Accessible name always contains the package name"]
Hidden --> Done
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 Start input;
class Len decision;
class Short,Long,Hidden,Done outcome;
```
Text alternative: a name of at most 14 characters gives the visible label "Boek" plus the name; a longer one gives "Boek je shoot" with the name as hidden text; either way the accessible name contains the package name.
## Decision flow: `pakket` parameter (BR-PARAM-01…03)
```mermaid
graph TD
In["Search parameter pakket"] --> IsString{"Is it a string?"}
IsString -->|"no"| Ignore["Ignore, no preselection"]
IsString -->|"yes"| Match{"Trimmed, lowercase, equals a shown package id?"}
Match -->|"no"| Ignore
Match -->|"yes"| Select["Form selects that package, replacing any earlier choice"]
Select --> Clean["Remove pakket from the URL with history replace, keep hash contact"]
Ignore --> CleanAlso["Remove pakket from the URL as well"]
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 input;
class IsString,Match decision;
class Ignore,Select,Clean,CleanAlso outcome;
```
Text alternative: a non-string or unknown `pakket` is ignored; a matching one selects that package in the form (replacing an earlier choice); in both cases the parameter is then removed from the URL with a history replace, keeping `#contact`.
## Misuse considerations (SECURITY-11)
- `pakket` is never rendered or reflected; only a known id from our own list can come out of `packageFromSearch`.
- Crafted values (very long strings, script, unicode look-alikes) simply match nothing.
@@ -0,0 +1,64 @@
# Domain Entities — Unit 3: Prijzen
## Relationships
```mermaid
graph TD
Package["PricingPackage"]
List["Package list"]
Card["Price card"]
Option["Shoot option"]
Param["pakket search parameter"]
List -->|"contains, in display order"| Package
Package -->|"shown as"| Card
Package -->|"becomes"| Option
Card -->|"links with id as"| Param
Param -->|"preselects"| Option
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 Package,List entity;
class Param,Option value;
class Card ui;
```
Text alternative: the package list holds packages in display order; each package is shown as a price card and becomes a shoot option in the contact form; a card links with the package id as the `pakket` parameter, which preselects that option (blue = data, orange = derived value, green = UI).
## PricingPackage
| Field | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | Stable slug, lowercase letters, digits and hyphens (e.g. `newborn`). Used in `?pakket=` and as the shoot value in the contact payload. |
| `name` | string | yes | Display name (e.g. "Newborn"); also the label of the shoot option |
| `price` | number | yes | Whole euros, > 0 (Q5 = A: no package without a price) |
| `features` | string[] | yes | What is included; at least one item |
### Invariants
- `id` is unique within the list and matches `^[a-z0-9-]+$`.
- `name` is non-empty after trimming.
- `price` is a finite integer > 0.
- `features` has ≥ 1 non-empty item.
- The list order is the display order (live: Zwangerschap, Newborn, Gezin).
Packages that break an invariant are left out of the page rather than breaking it (same approach as `visibleSocials`); the API is the place that rejects them at input (Q5 = A).
## Initial data (live site, 2026-10-19)
| id | name | price | features |
|---|---|---|---|
| `zwangerschap` | Zwangerschap | 175 | 1 uur fotografie · Minstens 30 zorgvuldig nabewerkte foto's · Persoonlijke online fotogalerij |
| `newborn` | Newborn | 185 | 1-2 uur fotografie · Minstens 40 zorgvuldig nabewerkte foto's · Persoonlijke online fotogalerij |
| `gezin` | Gezin | 175 | 1 uur fotografie · Minstens 30 zorgvuldig nabewerkte foto's · Persoonlijke online fotogalerij |
## Section content (`HomeContent.pricing`)
| Field | Value |
|---|---|
| `title` | "Prijzen" |
| `lead` | "Pakketten" |
| `decorations` | two decorative images from the design (`deco-1.png`, `deco-2.png`), `alt=""` |
## VAT
Andrea uses the small business scheme (KOR) and charges no VAT, so prices are shown as they are, without a VAT note (Q1 = C).
@@ -0,0 +1,48 @@
# Frontend Components — Unit 3: Prijzen
## Hierarchy
```mermaid
graph TD
Route["routes/index.tsx"] --> Pricing["home/Pricing"]
Pricing --> Section["HomeSection"]
Pricing --> Deco["Decorations x2"]
Pricing --> Heading["SectionHeading"]
Pricing --> Card["home/Pricing/PriceCard x n"]
Card --> Link["Book link: Chakra Link with linkButton style around RouterLink"]
Lib["lib: formatPrice, visiblePackages, bookLabel"] -.-> Pricing
Lib -.-> Card
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 Pricing,Section,Deco,Heading,Card,Link ui;
class Lib logic;
```
Text alternative: the home route renders Pricing, which uses HomeSection, two decorations, SectionHeading and one PriceCard per shown package; each card has a book link; the pure helpers supply the shown packages, prices and link labels.
## Pricing
- **Props**: `{ content: HomeContent['pricing']; packages: PricingPackage[] }`
- **Behaviour**: renders `visiblePackages(packages)`; if none remain, the section is not rendered at all (no empty heading).
- **Layout**: `HomeSection` on `paper` (plain), `data-testid="pricing"`, heading centred with lead. Cards in a grid: 1 column, centred, max 460 px below `lg`; 3 columns from `lg`; gap `gridGap`.
- **Decorations**: two decorative images (`alt=""`, `aria-hidden`), absolutely positioned (top-left 8% / 2%, bottom-right 6% / 3%), `clamp(90px, 10vw, 160px)` wide, opacity 0.55, behind the content, not clickable; loaded deferred.
- **Reveal**: heading and each card fade in, cards staggered by 0.08 s.
## PriceCard
- **Props**: `{ pkg: PricingPackage }`
- **Markup**: `article` with `h3` (name), price paragraph, `ul` of features, book link. `data-testid="price-card-<id>"`, link `data-testid="price-card-<id>-book"`.
- **Style**: white background, 1 px `line` border, centred text, padding `clamp(2rem, 3.5vw, 3rem) clamp(1.5rem, 3vw, 2.5rem)`; name in heading font 1.75 rem; price in heading font 2.25 rem, `accent.deep` (contrast, NFR-HP-01); features small text `ink.soft` between two hairlines, gap 0.75 rem; link aligned to the bottom (cards in a row get equal button positions).
- **Hover** (whole card, decorative): lift 6 px, `accent` border, `shadow-md`; transition `interaction`; no lift under reduced motion.
- **Book link**: the outline `linkButton` style; text per `bookLabel` (BR-BOOK-02) with `VisuallyHidden` for the hidden part; `white-space: nowrap`; horizontal padding 1.25 rem on phones, the design's 2.4 rem from `sm` (BR-BOOK-03). Target `/` with `search={{ pakket: id }}` and `hash="contact"`.
## Route (`/`)
- `validateSearch`: `{ pakket?: string }` — keeps a string, drops anything else (BR-PARAM-01, first half).
- Passes `homeContent.pricing` and `packages` to `Pricing`. Resolving and applying the value, and removing it from the URL, follow in unit 5.
## Accessibility (NFR-HP-01)
- Region named by the h2 "Prijzen"; each card has an h3; features are a real list.
- Every link has a unique accessible name containing the package name.
- Decorations are hidden from assistive technology.
- Focus ring from the theme on the link; touch target ≥ 44 px high.
+14
View File
@@ -132,6 +132,7 @@ describe('homepage', () => {
screen.getByRole('region', {
name: 'Lifestyle fotograaf met een passie voor storytelling',
}),
screen.getByRole('region', { name: 'Prijzen' }),
];
let previous: Element = hero;
@@ -147,6 +148,19 @@ describe('homepage', () => {
});
});
describe('homepage ?pakket=', () => {
it.each(['/?pakket=newborn', '/?pakket=123', '/?pakket=%3Cscript%3E'])(
'%s renders the homepage without errors',
async (path) => {
await renderApp(path);
expect(
await screen.findByRole('region', { name: 'Prijzen' }),
).toBeInTheDocument();
expect(document.body).not.toHaveTextContent('<script>');
},
);
});
describe('pagina-register', () => {
it('bevat precies de routes van de route tree', async () => {
const { router } = await renderApp('/');
Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

@@ -0,0 +1,45 @@
import { screen, within } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import packages from '@/content/packages';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import PriceCard from './PriceCard';
const newborn = packages[1];
describe('PriceCard', () => {
it('shows the name, price, features and a booking link with the package', async () => {
const { container } = await renderWithProviders(
<PriceCard pkg={newborn} />,
);
const card = screen.getByTestId('price-card-newborn');
expect(
within(card).getByRole('heading', { level: 3 }),
).toHaveTextContent('Newborn');
// Raw text: Testing Library's matchers would turn the non-breaking
// space into a normal one
expect(card.textContent).toContain('€\u00a0185');
expect(
within(card)
.getAllByRole('listitem')
.map((item) => item.textContent),
).toEqual(newborn.features);
const link = within(card).getByRole('link', { name: 'Boek Newborn' });
expect(link).toHaveAttribute('href', '/?pakket=newborn#contact');
expect(await axeResults(container)).toHaveNoViolations();
});
it('uses "Boek je shoot" with the name for screen readers when the name is long', async () => {
await renderWithProviders(
<PriceCard
pkg={{ ...newborn, id: 'bruiloft', name: 'Bruiloft en feest' }}
/>,
);
const link = screen.getByRole('link', {
name: 'Boek je shoot: Bruiloft en feest',
});
expect(link).toHaveTextContent('Boek je shoot');
expect(link).toHaveAttribute('href', '/?pakket=bruiloft#contact');
});
});
@@ -0,0 +1,98 @@
import {
Box,
Heading,
List,
Text,
useRecipe,
VisuallyHidden,
} from '@chakra-ui/react';
import { Link } from '@tanstack/react-router';
import type { PricingPackage } from '@/content/types';
import { bookLabel } from '@/lib/bookLabel';
import { formatPrice } from '@/lib/formatPrice';
type PriceCardProps = {
pkg: PricingPackage;
};
// One package (design .price-card): name, price, what is included and a
// link that takes the visitor to the contact form with this package chosen.
export default function PriceCard({ pkg }: PriceCardProps) {
const label = bookLabel(pkg.name);
const linkButton = useRecipe({ key: 'linkButton' });
return (
<Box
as="article"
data-testid={`price-card-${pkg.id}`}
display="flex"
flexDirection="column"
h="100%"
px="clamp(1.5rem, 3vw, 2.5rem)"
py="clamp(2rem, 3.5vw, 3rem)"
bg="white"
borderWidth="1px"
borderColor="line"
textAlign="center"
transitionProperty="transform, box-shadow, border-color"
transitionDuration="interaction"
transitionTimingFunction="smooth"
_hover={{
transform: 'translateY(-6px)',
borderColor: 'accent',
boxShadow: 'lift',
}}
_motionReduce={{ _hover: { transform: 'none' } }}
>
<Heading as="h3" fontSize="1.75rem" mb={3}>
{pkg.name}
</Heading>
{/* accent.deep instead of the design's accent: meets 4.5:1 (NFR-HP-01) */}
<Text
fontFamily="heading"
fontSize="2.25rem"
lineHeight="1"
color="accent.deep"
mb={6}
>
{formatPrice(pkg.price)}
</Text>
<List.Root
listStyleType="none"
display="grid"
gap={3}
mb={8}
py={6}
borderBlockWidth="1px"
borderColor="line"
color="ink.soft"
fontSize="sm"
>
{pkg.features.map((feature) => (
<List.Item key={feature}>{feature}</List.Item>
))}
</List.Root>
{/* The router's own Link keeps the route types, so search is
checked against the homepage's ?pakket=; the button style
goes on via asChild */}
<Box
asChild
css={linkButton({ size: 'fit' })}
alignSelf="center"
mt="auto"
>
<Link
to="/"
search={{ pakket: pkg.id }}
hash="contact"
data-testid={`price-card-${pkg.id}-book`}
>
{label.visible}
{label.hidden && (
<VisuallyHidden>{label.hidden}</VisuallyHidden>
)}
</Link>
</Box>
</Box>
);
}
@@ -0,0 +1,67 @@
import { screen, within } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import homeContent from '@/content/homeContent';
import packages from '@/content/packages';
import { axeResults } from '@/test/axe';
import { renderWithProviders } from '@/test/renderWithProviders';
import Pricing from './Pricing';
const content = homeContent.pricing;
describe('Pricing', () => {
it('shows the heading and one card per package, in order', async () => {
const { container } = await renderWithProviders(
<Pricing content={content} packages={packages} />,
);
const section = screen.getByRole('region', { name: 'Prijzen' });
expect(within(section).getByText('Pakketten')).toBeInTheDocument();
expect(
within(section)
.getAllByRole('heading', { level: 3 })
.map((heading) => heading.textContent),
).toEqual(['Zwangerschap', 'Newborn', 'Gezin']);
expect(
within(section)
.getAllByRole('link')
.map((link) => link.getAttribute('href')),
).toEqual([
'/?pakket=zwangerschap#contact',
'/?pakket=newborn#contact',
'/?pakket=gezin#contact',
]);
expect(await axeResults(container)).toHaveNoViolations();
});
it('keeps the decorations away from assistive technology', async () => {
const { container } = await renderWithProviders(
<Pricing content={content} packages={packages} />,
);
// The only images here are the decorations: empty alt and aria-hidden
expect(screen.queryAllByRole('img')).toHaveLength(0);
const images = container.querySelectorAll('img');
expect(images).toHaveLength(content.decorations.length);
images.forEach((image) => {
expect(image).toHaveAttribute('alt', '');
expect(image).toHaveAttribute('aria-hidden', 'true');
});
});
it('skips invalid packages', async () => {
await renderWithProviders(
<Pricing
content={content}
packages={[{ ...packages[0], price: 0 }, packages[1]]}
/>,
);
expect(
screen
.getAllByRole('heading', { level: 3 })
.map((h) => h.textContent),
).toEqual(['Newborn']);
});
it('leaves the section out when no package is valid', async () => {
await renderWithProviders(<Pricing content={content} packages={[]} />);
expect(screen.queryByRole('region', { name: 'Prijzen' })).toBeNull();
});
});
@@ -0,0 +1,73 @@
import { Box, Grid } from '@chakra-ui/react';
import DeferredImage from '@/components/DeferredImage/DeferredImage';
import HomeSection from '@/components/HomeSection/HomeSection';
import Reveal from '@/components/Reveal/Reveal';
import SectionHeading from '@/components/SectionHeading/SectionHeading';
import type { HomeContent, PricingPackage } from '@/content/types';
import { visiblePackages } from '@/lib/visiblePackages';
import PriceCard from './PriceCard';
const TITLE_ID = 'pricing-title';
const STAGGER = 0.08;
// Where the two decorations sit (design .pricing__deco--1 and --2). The
// design measures from the whole section; here they sit in the content box,
// so the second one moves down into the section's bottom padding, or the
// last card would cover it.
const decorationPositions = [
{ top: '8%', left: '2%' },
{ bottom: 'calc(-0.6 * {spacing.sectionY})', right: '2%' },
];
type PricingProps = {
content: HomeContent['pricing'];
packages: PricingPackage[];
};
// "Prijzen": the shoot packages as cards (design .pricing). One column on
// phones and tablets, three from `lg`. Without a valid package the section
// is left out entirely.
export default function Pricing({ content, packages }: PricingProps) {
const shown = visiblePackages(packages);
if (shown.length === 0) return null;
return (
<HomeSection labelledBy={TITLE_ID} data-testid="pricing">
<Box position="relative" isolation="isolate">
{content.decorations.map((decoration, index) => (
<DeferredImage
key={decoration.src}
image={decoration}
aria-hidden="true"
position="absolute"
zIndex={-1}
w="clamp(90px, 10vw, 160px)"
h="auto"
opacity={0.55}
pointerEvents="none"
{...decorationPositions[index % 2]}
/>
))}
<Reveal>
<SectionHeading
id={TITLE_ID}
title={content.title}
lead={content.lead}
/>
</Reveal>
<Grid
templateColumns={{ base: '1fr', lg: 'repeat(3, 1fr)' }}
gap="gridGap"
maxW={{ base: '460px', lg: 'none' }}
mx="auto"
>
{shown.map((pkg, index) => (
<Reveal key={pkg.id} delay={index * STAGGER} h="100%">
<PriceCard pkg={pkg} />
</Reveal>
))}
</Grid>
</Box>
</HomeSection>
);
}
+10
View File
@@ -6,6 +6,8 @@ import intro2 from '../assets/home/intro-2.jpg';
import intro3 from '../assets/home/intro-3.jpg';
import intro4 from '../assets/home/intro-4.jpg';
import andrea from '../assets/home/andrea.jpg';
import deco1 from '../assets/home/deco-1.png';
import deco2 from '../assets/home/deco-2.png';
// Static content of the homepage sections until the CMS API exists; the API
// will then deliver this object.
@@ -56,6 +58,14 @@ const homeContent: HomeContent = {
},
link: { label: 'Lees mijn verhaal', to: '/over-mij' },
},
pricing: {
title: 'Prijzen',
lead: 'Pakketten',
decorations: [
{ src: deco1, alt: '', width: 143, height: 112 },
{ src: deco2, alt: '', width: 239, height: 224 },
],
},
};
export default homeContent;
+38
View File
@@ -0,0 +1,38 @@
import type { PricingPackage } from './types';
// The shoot packages until the CMS API exists (live site, October 2026), in
// display order. Andrea uses the small business scheme (KOR): no VAT.
const packages: PricingPackage[] = [
{
id: 'zwangerschap',
name: 'Zwangerschap',
price: 175,
features: [
'1 uur fotografie',
"Minstens 30 zorgvuldig nabewerkte foto's",
'Persoonlijke online fotogalerij',
],
},
{
id: 'newborn',
name: 'Newborn',
price: 185,
features: [
'1-2 uur fotografie',
"Minstens 40 zorgvuldig nabewerkte foto's",
'Persoonlijke online fotogalerij',
],
},
{
id: 'gezin',
name: 'Gezin',
price: 175,
features: [
'1 uur fotografie',
"Minstens 30 zorgvuldig nabewerkte foto's",
'Persoonlijke online fotogalerij',
],
},
];
export default packages;
+15
View File
@@ -31,6 +31,15 @@ export interface ContentImage {
height: number;
}
// A priced shoot offer. id is a stable slug: it goes into ?pakket= and is
// the shoot value the contact form sends.
export interface PricingPackage {
id: string;
name: string;
price: number; // whole euros
features: string[];
}
// Content of the homepage sections below the hero
export interface HomeContent {
intro: {
@@ -46,6 +55,12 @@ export interface HomeContent {
// A route, so a wrong link is a type error
link: { label: string; to: RoutePath };
};
pricing: {
title: string;
lead: string;
// Purely decorative illustrations, alt=""
decorations: ContentImage[];
};
}
export interface HeroSlide {
+33
View File
@@ -0,0 +1,33 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { BOOK_LABEL_MAX_NAME, bookLabel } from './bookLabel';
describe('bookLabel', () => {
it('puts short names in the visible text', () => {
expect(bookLabel('Newborn')).toEqual({ visible: 'Boek Newborn' });
expect(bookLabel('Zwangerschap')).toEqual({
visible: 'Boek Zwangerschap',
});
});
it('falls back to "Boek je shoot" with a hidden name for long names', () => {
expect(bookLabel('Bruiloft en feest')).toEqual({
visible: 'Boek je shoot',
hidden: ': Bruiloft en feest',
});
});
it('always names the package and follows the length rule (invariant)', () => {
fc.assert(
fc.property(fc.string({ maxLength: 40 }), (name) => {
const label = bookLabel(name);
expect(`${label.visible}${label.hidden ?? ''}`).toContain(name);
if (name.length <= BOOK_LABEL_MAX_NAME) {
expect(label).toEqual({ visible: `Boek ${name}` });
} else {
expect(label.visible).toBe('Boek je shoot');
}
}),
);
});
});
+19
View File
@@ -0,0 +1,19 @@
// Longest package name that still fits as "Boek <name>" on one line in the
// card's button down to a 320px phone (BR-BOOK-02, BR-BOOK-03)
export const BOOK_LABEL_MAX_NAME = 14;
export interface BookLabel {
visible: string;
// Extra text for screen readers only
hidden?: string;
}
// Text of a card's booking link. Short names go in the visible text; for
// longer ones the button says "Boek je shoot" and the name is added for
// screen readers, so every link still names its package.
export function bookLabel(name: string): BookLabel {
if (name.length <= BOOK_LABEL_MAX_NAME) {
return { visible: `Boek ${name}` };
}
return { visible: 'Boek je shoot', hidden: `: ${name}` };
}
+32
View File
@@ -0,0 +1,32 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import { formatPrice } from './formatPrice';
const NBSP = '\u00a0';
describe('formatPrice', () => {
it('formats whole euros the Dutch way', () => {
expect(formatPrice(175)).toBe(`€${NBSP}175`);
expect(formatPrice(1250)).toBe(`€${NBSP}1.250`);
});
it('gives back the amount from its digits (round-trip)', () => {
fc.assert(
fc.property(fc.integer({ min: 1, max: 1_000_000 }), (price) => {
expect(Number(formatPrice(price).replace(/\D/g, ''))).toBe(
price,
);
}),
);
});
it('starts with the euro sign and a non-breaking space, and has no breaking space (invariant)', () => {
fc.assert(
fc.property(fc.integer({ min: 1, max: 1_000_000 }), (price) => {
const text = formatPrice(price);
expect(text.startsWith(`€${NBSP}`)).toBe(true);
expect(/[ \t\n\u202f]/.test(text)).toBe(false);
}),
);
});
});
+12
View File
@@ -0,0 +1,12 @@
const euros = new Intl.NumberFormat('nl-NL', {
style: 'currency',
currency: 'EUR',
maximumFractionDigits: 0,
});
// A price in whole euros as shown on the cards: "€ 175", "€ 1.250". Any space
// the browser puts in (some use a narrow one) becomes a non-breaking space,
// so the price never wraps (BR-PRICE-01).
export function formatPrice(price: number): string {
return euros.format(price).replace(/\s/g, '\u00a0');
}
+95
View File
@@ -0,0 +1,95 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import packages from '../content/packages';
import { uniquePackages } from '../test/arbitraries';
import { packageFromSearch } from './packageFromSearch';
// Random upper/lower case per letter, plus spaces around
const mangled = (id: string) =>
fc
.tuple(
fc.array(fc.boolean(), {
minLength: id.length,
maxLength: id.length,
}),
fc.constantFrom('', ' ', ' '),
fc.constantFrom('', ' ', '\t'),
)
.map(
([upper, before, after]) =>
before +
[...id]
.map((char, i) => (upper[i] ? char.toUpperCase() : char))
.join('') +
after,
);
describe('packageFromSearch', () => {
it('finds a package by id, ignoring case and spaces', () => {
expect(packageFromSearch('newborn', packages)).toBe('newborn');
expect(packageFromSearch(' Gezin ', packages)).toBe('gezin');
});
it('ignores unknown or non-text values', () => {
expect(packageFromSearch('bruiloft', packages)).toBeUndefined();
expect(packageFromSearch('', packages)).toBeUndefined();
expect(packageFromSearch(123, packages)).toBeUndefined();
expect(packageFromSearch(['newborn'], packages)).toBeUndefined();
expect(packageFromSearch(undefined, packages)).toBeUndefined();
});
it('only returns undefined or one of the given ids (invariant)', () => {
fc.assert(
fc.property(fc.anything(), uniquePackages, (value, list) => {
const result = packageFromSearch(value, list);
expect(
result === undefined ||
list.some((pkg) => pkg.id === result),
).toBe(true);
}),
);
});
it('finds every package in any letter case with spaces around (oracle)', () => {
fc.assert(
fc.property(
uniquePackages
.filter((list) => list.length > 0)
.chain((list) =>
fc
.integer({ min: 0, max: list.length - 1 })
.chain((i) =>
mangled(list[i].id).map(
(value) =>
[list, list[i].id, value] as const,
),
),
),
([list, id, value]) => {
expect(packageFromSearch(value, list)).toBe(id);
},
),
);
});
it('never matches a value that is not text (invariant)', () => {
fc.assert(
fc.property(
fc.anything().filter((value) => typeof value !== 'string'),
uniquePackages,
(value, list) => {
expect(packageFromSearch(value, list)).toBeUndefined();
},
),
);
});
it('gives the same id when its result is fed back in (idempotent)', () => {
fc.assert(
fc.property(fc.string(), uniquePackages, (value, list) => {
const once = packageFromSearch(value, list);
expect(packageFromSearch(once, list)).toBe(once);
}),
);
});
});
+14
View File
@@ -0,0 +1,14 @@
import type { PricingPackage } from '../content/types.ts';
// The package id from ?pakket=, if it names one of the given packages.
// Letter case and surrounding spaces do not matter; anything else (unknown
// id, number, array, missing) is ignored. Only our own ids can come out, so
// the value from the URL is never reflected on the page (BR-PARAM-01).
export function packageFromSearch(
value: unknown,
packages: readonly PricingPackage[],
): string | undefined {
if (typeof value !== 'string') return undefined;
const wanted = value.trim().toLowerCase();
return packages.find((pkg) => pkg.id === wanted)?.id;
}
+73
View File
@@ -0,0 +1,73 @@
import fc from 'fast-check';
import { describe, expect, it } from 'vitest';
import packages from '../content/packages';
import { anyPackage, uniquePackages } from '../test/arbitraries';
import { isValidPackage, visiblePackages } from './visiblePackages';
const valid = packages[0];
describe('visiblePackages', () => {
it('keeps the live packages as they are', () => {
expect(visiblePackages(packages)).toEqual(packages);
});
it('skips packages that break an invariant', () => {
const broken = [
{ ...valid, id: 'Hoofdletters' },
{ ...valid, id: 'leeg-naam', name: ' ' },
{ ...valid, id: 'gratis', price: 0 },
{ ...valid, id: 'negatief', price: -10 },
{ ...valid, id: 'centen', price: 12.5 },
{ ...valid, id: 'geen-getal', price: Number.NaN },
{ ...valid, id: 'niets', features: [] },
{ ...valid, id: 'lege-regel', features: ['1 uur', ' '] },
];
expect(visiblePackages([...broken, valid])).toEqual([valid]);
});
it('keeps the first of two packages with the same id', () => {
const second = { ...valid, name: 'Dubbel' };
expect(visiblePackages([valid, second])).toEqual([valid]);
});
it('only returns valid packages with unique ids (invariant)', () => {
fc.assert(
fc.property(fc.array(anyPackage), (input) => {
const result = visiblePackages(input);
expect(result.every(isValidPackage)).toBe(true);
const ids = result.map((pkg) => pkg.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(anyPackage), (input) => {
const result = visiblePackages(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(anyPackage), (input) => {
const once = visiblePackages(input);
expect(visiblePackages(once)).toEqual(once);
}),
);
});
it('returns valid, unique packages unchanged (oracle)', () => {
fc.assert(
fc.property(uniquePackages, (input) => {
expect(visiblePackages(input)).toEqual(input);
}),
);
});
});
+29
View File
@@ -0,0 +1,29 @@
import type { PricingPackage } from '../content/types.ts';
const SLUG = /^[a-z0-9-]+$/;
// Whether a package meets the invariants in domain-entities.md
export function isValidPackage(pkg: PricingPackage): boolean {
return (
SLUG.test(pkg.id) &&
pkg.name.trim() !== '' &&
Number.isInteger(pkg.price) &&
pkg.price > 0 &&
pkg.features.length > 0 &&
pkg.features.every((feature) => feature.trim() !== '')
);
}
// The packages that can be shown: invalid ones from the CMS are skipped
// rather than breaking the page, and of two packages with the same id the
// first wins. The order stays the same (BR-PRICE-02).
export function visiblePackages(
packages: readonly PricingPackage[],
): PricingPackage[] {
const seen = new Set<string>();
return packages.filter((pkg) => {
if (!isValidPackage(pkg) || seen.has(pkg.id)) return false;
seen.add(pkg.id);
return true;
});
}
+10
View File
@@ -51,9 +51,19 @@ const linkButtonRecipe = defineRecipe({
},
},
},
size: {
default: {},
// Never wraps; less side padding on phones so a longer label
// still fits inside a card (BR-BOOK-03)
fit: {
whiteSpace: 'nowrap',
px: { base: '1.25rem', sm: '2.4rem' },
},
},
},
defaultVariants: {
variant: 'outline',
size: 'default',
},
});
+9
View File
@@ -1,13 +1,21 @@
import { createFileRoute } from '@tanstack/react-router';
import Hero from '../components/Hero/Hero';
import AboutBlock from '../components/home/AboutBlock/AboutBlock';
import Pricing from '../components/home/Pricing/Pricing';
import IntroGallery from '../components/home/IntroGallery/IntroGallery';
import heroContent from '../content/heroContent';
import homeContent from '../content/homeContent';
import packages from '../content/packages';
import siteContent from '../content/siteContent';
import { pageHead } from '../seo';
// ?pakket= from a "Boek" link on a price card. Only text is kept; whether it
// names a real package is checked against the shown packages (BR-PARAM-01).
type HomeSearch = { pakket?: string };
export const Route = createFileRoute('/')({
validateSearch: (search: Record<string, unknown>): HomeSearch =>
typeof search.pakket === 'string' ? { pakket: search.pakket } : {},
head: () => pageHead('/'),
component: Index,
});
@@ -19,6 +27,7 @@ function Index() {
<Hero content={heroContent} socials={siteContent.socials} />
<IntroGallery content={homeContent.intro} />
<AboutBlock content={homeContent.about} />
<Pricing content={homeContent.pricing} packages={packages} />
</>
);
}
+49 -1
View File
@@ -1,5 +1,9 @@
import fc from 'fast-check';
import type { EmailAddress, SocialLink } from '../content/types';
import type {
EmailAddress,
PricingPackage,
SocialLink,
} from '../content/types';
// Gedeelde generators voor de property-based tests (fast-check)
@@ -47,3 +51,47 @@ export const anyEmail: fc.Arbitrary<EmailAddress> = fc.oneof(
validEmail,
fc.record({ user: fc.string(), domain: fc.string() }),
);
// Package ids: a few fixed ones so lists contain duplicates, plus random slugs
const packageId = fc.oneof(
fc.constantFrom('newborn', 'gezin', 'zwangerschap'),
fc.stringMatching(/^[a-z0-9-]{1,16}$/),
);
const nonBlank = fc
.string({ minLength: 1, maxLength: 30 })
.filter((text) => text.trim() !== '');
// A package that meets every invariant
export const pricingPackage: fc.Arbitrary<PricingPackage> = fc.record({
id: packageId,
name: nonBlank,
price: fc.integer({ min: 1, max: 5000 }),
features: fc.array(nonBlank, { minLength: 1, maxLength: 5 }),
});
// Valid packages with unique ids, as a well-behaved CMS would deliver them
export const uniquePackages = fc.uniqueArray(pricingPackage, {
selector: (pkg) => pkg.id,
maxLength: 6,
});
// Valid and broken packages mixed, as a CMS might deliver them
export const anyPackage: fc.Arbitrary<PricingPackage> = fc.oneof(
pricingPackage,
fc.record({
id: fc.oneof(
packageId,
fc.constantFrom('', 'Newborn', 'met spatie', 'a/b'),
fc.string(),
),
name: fc.oneof(nonBlank, fc.constantFrom('', ' ')),
price: fc.oneof(
fc.integer({ min: 1, max: 5000 }),
fc.constantFrom(0, -5, 12.5, Number.NaN, Infinity),
),
features: fc.oneof(
fc.array(nonBlank, { maxLength: 3 }),
fc.constant<string[]>(['', 'x']),
),
}),
);
+6
View File
@@ -95,6 +95,12 @@ const config = defineConfig({
// Binnen de header: de hamburger boven het logo en menu
menuToggle: { value: 1 },
},
shadows: {
// Soft shadow under a lifted card on hover (design --shadow-md)
lift: {
value: '0 12px 40px color-mix(in srgb, {colors.ink} 12%, transparent)',
},
},
gradients: {
// Donker verloop over hero-foto's, zodat witte tekst leesbaar blijft
scrim: {