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
@@ -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.