Files
SlpSoftware/aidlc-docs/features/redesign-modern-timetravel/construction/plans/packages-block-code-generation-plan.md
T
SluijsensandClaude Sonnet 5.5 9661b64635 Pakketblok: elk aantal pakketten, filterchips, swipe-rij op mobiel en optionele banner
Pure logica (splitsen, chips, filter, labels), useSwipeRow en usePackageFilter,
ContactPreselect voor het formulier, kaarten in stijl B en tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 10:34:09 +01:00

36 lines
4.5 KiB
Markdown

# Code Generation Plan — packages-block (U3)
Single source of truth for U3 Code Generation. Inputs: Functional Design in `construction/packages-block/functional-design/` (BR-U3-1..12), `unit-of-work.md` (U3), requirements FR-7..FR-12 (B part), canvas `PakkettenModern.dc.html`, U1/U2 results.
## Unit context
- **Workspace root** `K:\Development\SlpSoftware\Projects\SlpSoftware`, branch `feature/redesign-modern-timetravel`; modify in place; one commit; no push.
- **Dependencies**: U1, U2. **External**: `category` in the public offerings response (CMS-U1, done on the CMS branch, not deployed): the UI works without it (no chips). **Blocks**: U4 (preselect context), U5 (shared logic).
- **Not in U3**: contact form (U4), E styling (U5), CMS changes.
## Files
- M `src/features/landing/data/content.ts` (`category?`, `packagesSettings`), `src/features/landing/hooks/usePackagesQuery.ts` (type only), `src/features/landing/components/PackagesSection.tsx`, `PackageCard.tsx`, `PackageCardSkeleton.tsx`, `src/features/landing/__tests__/PackagesSection.test.tsx`
- C `src/shared/packages/{packageLogic.ts,usePackageFilter.ts,useSwipeRow.ts}`, `src/shared/contact/ContactPreselectContext.tsx`
- C `src/features/landing/components/{FilterChips,PackageList,SwipeDots,PackageBanner,PackagesStates}.tsx`
- C tests: `src/shared/packages/__tests__/{packageLogic.test.ts,useSwipeRow.test.tsx}`, `src/features/landing/__tests__/PackagesBlock.test.tsx`
- Docs: `construction/packages-block/code/summary.md`
## Steps
- [x] **Step 1 — Pure logic** (`packageLogic.ts`): `splitPackages`, `deriveChips`, `filterCards`, `resultLabel`, `initialIndex`, `activeIndexFromScroll`; types for `Chip`, `PackagesSettings`. Table-driven tests incl. boundary 3/4, missing category, unknown banner slug, label singular/plural.
- [x] **Step 2 — Content/settings**: `PackageCardData.category?/categoryId?/displayOrder?`; `packagesSettings` (`bannerSlugs: []`, `chipThreshold: 4`, `bannerFallback`); heading text unchanged (live copy).
- [x] **Step 3 — Hooks**: `usePackageFilter` (active chip, reset when category disappears), `useSwipeRow` (initial/instant position, rAF-throttled scroll listener, `scrollToIndex` smooth unless reduced motion), `ContactPreselectContext` (provider + `useContactPreselect`, key increments; default no-op outside provider so U3 works standalone); provider mounted in `RootLayout`.
- [x] **Step 4 — Components**: `FilterChips` (buttons, `aria-pressed`, group label), `PackageList` (one render path: `flex snap-x snap-mandatory overflow-x-auto` below `sm`, `grid` 3/2 columns from `sm`; scroll container `tabIndex=0 role=group aria-label=Pakketten`), `SwipeDots` (buttons with labels, `aria-current`, hidden at 1 card and on `sm+`), `PackageCard` restyled to B (square, white/dark card, featured brand block with "Meest gekozen" badge, price in wide Archivo, feature list with squares, CTA ink button / white on featured; CTA sets preselect + scrolls), `PackageBanner` (black block), `PackagesStates` (skeletons incl. swipe row, error with retry, empty), `PackagesSection` rewritten (alt background, heading, intro, chips, status line, list, banner).
- [x] **Step 5 — Tests**: the nine acceptance tests of `frontend-components.md` (3 vs 6 packages, categories, banner via settings and fallback, label/announcement, swipe row roles/classes/initial position/dots/scroll sync with mocked layout, CTA preselect, loading/error-retry/empty, pure functions, accessibility attributes); update `PackagesSection.test.tsx` for the new markup.
- [x] **Step 6 — Build and test (automatic, Step 13.5)**: `pnpm lint`, `pnpm test`, `pnpm build`; fix until green; report real counts.
- [x] **Step 7 — Docs and commit**: `construction/packages-block/code/summary.md` (files, behaviour, settings, how a site enables the banner, hand-offs for U4/U5, CMS note: `category` shows once the CMS-U1 API is deployed); one commit (Dutch message, `Co-Authored-By`), no push.
## Explicitly NOT touched
Contact section/form, nav/hero/about/process (U2), theme code (U1), `src/variants/e`, CMS repos.
## Risks
- jsdom has no layout: swipe sync tests mock `offsetLeft`/`clientWidth`/`scrollLeft`; real scroll feel needs a browser check by the user.
- Until the CMS API is deployed the live API has no `category`: chips stay hidden (by design).
- The mock data of 6 packages in tests uses the categories Websites and Onderhoud.
## Traceability
FR-7..FR-12 (B), NFR-1, NFR-2; BR-U3-1..12; Security Baseline: no new external requests, no `dangerouslySetInnerHTML`, plain-text rendering of API strings.