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:
+62
@@ -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
|
||||
+11
@@ -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
|
||||
Reference in New Issue
Block a user