# 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, smooth `scrollTo` unless reduced motion). - **Contact hand-over** (`src/shared/contact/`): `ContactPreselectContext`/`Provider`/`useContactPreselect` (`subject` = package slug, `key` increments per click); the provider is mounted in `RootLayout`; 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 below `sm`, grid 2 columns from `sm`, 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 }`; `PackageCardData` gains optional `category`, `categoryId`, `displayOrder`. - **Token tweak**: B light `--color-surface-2` is 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 lint` 0 errors (same 2 warnings); `pnpm build` OK (JS 453 kB, CSS 57.8 kB). Snap utilities and the `min-[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 `category` yet 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 when `key` changes; unknown subject ignored). - U5: reuse `packageLogic`, `usePackageFilter`, `useSwipeRow`, `ContactPreselect*`; only the presentation (2006 style) is new. - CMS: optional future `layout` field on offerings (additive, not needed now).