Files
AndreaSlopFotografie/aidlc-docs/features/homepage-sections/construction/plans/prijzen-code-generation-plan.md
SluijsensandClaude Opus 5.5 30dab1af42 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>
2026-10-20 01:07:36 +02:00

5.6 KiB
Raw Permalink Blame History

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/ — 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

  • 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/.
  • Step 2 — content/types.ts: PricingPackage { id; name; price; features }; HomeContent.pricing { title; lead; decorations: ContentImage[] }.
  • 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)

  • 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.
  • 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.
  • 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.
  • 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.
  • Step 8 — test/arbitraries.ts: pricingPackage (valid), uniquePackages, anyPackage (incl. invalid: empty name, price 0 / negative / fractional / NaN, bad id, duplicates).

Styling

  • 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

  • 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-testids per frontend-components.md.
  • Step 11 — components/home/Pricing/Pricing.tsx: HomeSection (plain), decorations (DeferredImage, aria-hidden, positioned behind content), SectionHeading with lead, grid of PriceCards from visiblePackages (1 column max 460 px centred below lg, 3 from lg), staggered Reveal; renders nothing when no package is valid.
  • 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

  • Step 13 — routes/index.tsx: validateSearch → { pakket?: string } (string kept, everything else dropped); render Pricing after AboutBlock with homeContent.pricing and packages.
  • 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

  • Step 15 — pnpm check (coverage 100% for the new lib/ files, Lighthouse); visual check desktop 1440 and phones 390 and 320.
  • Step 16 — construction/prijzen/code/code-summary.md.
  • 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).