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>
3.6 KiB
3.6 KiB
Code Summary — packages-block (U3)
What was built
- Pure logic (
src/shared/packages/packageLogic.ts):splitPackages,deriveChips,filterCards,resultLabel,initialIndex,activeIndexFromScroll. - Hooks:
usePackageFilter(cards, banner packages, chips, active chip with fallback to "Alles", visible list, status label),useSwipeRow(start position on the featured card, rAF-throttled scroll sync for the dots, smoothscrollTounless reduced motion). - Contact hand-over (
src/shared/contact/):ContactPreselectContext/Provider/useContactPreselect(subject= package slug,keyincrements per click); the provider is mounted inRootLayout; U4 consumes it. - Components:
PackagesSection(B styling: alt background, heading, intro, chips + live status line, list, banner, states),FilterChips,PackageList(one render path: scroll-snap swipe row belowsm, grid 2 columns fromsm, 3 above 1000px),SwipeDots(buttons with labels,aria-current, mobile only, hidden at one card),PackageCard(flat block, featured in brand red with "Meest gekozen" badge, CTA sets preselect and scrolls to#contact),PackageBanner(black "Past er niets bij?" block),PackageCardSkeleton(square, 3 in the same container). - Settings (
content.ts):packagesSettings = { bannerSlugs: [], chipThreshold: 4, bannerTitle, bannerFallback };PackageCardDatagains optionalcategory,categoryId,displayOrder. - Token tweak: B light
--color-surface-2is now white (the card colour of the canvas). - Heading: "Drie manieren om te starten." with exactly three card packages, otherwise "Manieren om te starten."
How a site chooses card vs banner
Put the package slug in packagesSettings.bannerSlugs (e.g. ['maatwerk']): it is then shown as the black banner under the cards (always visible, independent of the active chip) and not as a card; with no matching package the fallback texts are used. SLP Software keeps the list empty, so Maatwerk is a normal card. A later additive API field layout: card | banner can replace the setting.
Verification (Step 13.5, real output)
- Before this unit (after U2): 13 files / 122 tests. After: 14 files / 154 tests passed;
pnpm lint0 errors (same 2 warnings);pnpm buildOK (JS 453 kB, CSS 57.8 kB). Snap utilities and themin-[1001px]breakpoint are generated. - Tests cover: pure logic (split, chip threshold 3 vs 4, blank categories, filter, singular/plural label, initial index, scroll-to-index), the live three packages (no chips/banner, Maatwerk a card, heading), loading/error with retry/empty, six packages with chips and counts and filtering, banner via setting (kept for every chip, fallback, CTA preselect), preselect key increments and scroll to
#contact, swipe row roles/classes/dots/click/reduced motion/scroll sync with mocked layout, accessibility attributes.
Notes for review
- No
categoryyet in the live API: chips stay hidden until the CMS-U1 API is deployed (by design); with the current three packages the block looks like before, in the new style. - Real swipe feel, card widths at 360px and the dark look need a browser check (no layout engine in the tests).
- Prettier touched two unrelated files; both were reverted.
Hand-offs
- U4: read
useContactPreselect()in the form (subject options = packages + "Overig"; apply whenkeychanges; unknown subject ignored). - U5: reuse
packageLogic,usePackageFilter,useSwipeRow,ContactPreselect*; only the presentation (2006 style) is new. - CMS: optional future
layoutfield on offerings (additive, not needed now).