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>
4.3 KiB
4.3 KiB
Business Rules — packages-block (U3)
| Id | Rule |
|---|---|
| BR-U3-1 | The block works with any number of packages (0..n) from the API; nothing is hard-coded to three. Array order = display order; no client-side sorting. |
| BR-U3-2 | Split: packages whose slug is in packagesSettings.bannerSlugs are banner packages; all others are card packages. Default (empty list): everything is a card, so Maatwerk is a card at SLP Software. |
| BR-U3-3 | Chips appear only when the number of card packages is at least chipThreshold (4) and there is at least one category. Chips: "Alles" plus the distinct non-empty categories of card packages in order of first appearance, each with its count. Selecting a chip shows only that category; "Alles" shows all card packages. Packages without category show only under "Alles". Chip state is not persisted. |
| BR-U3-4 | Result count: below the chips a polite status line "N pakket(ten) met vaste prijs" (plus ", plus maatwerk" when a banner is shown); announced to screen readers when the filter changes. |
| BR-U3-5 | Layout: from the sm breakpoint up a grid (3 columns, 2 columns up to 1000px); below it a horizontal swipe row (CSS scroll-snap, snap-x snap-mandatory, cards ~85% wide so the next card peeks) for any number of packages. The row works without JavaScript; JS only drives the dots and the initial position. |
| BR-U3-6 | Banner: when banner packages exist (or bannerSlugs is non-empty without a match, using bannerFallback), a black banner is shown below the cards with title, text, price label/note and a CTA to #contact. The banner is always visible regardless of the active chip. With an empty bannerSlugs no banner is rendered. (Both presentations remain possible per site; a later additive API field layout: card | banner can replace the setting without changing the UI.) |
| BR-U3-7 | Featured: the featured package is styled with the brand colour and the "Meest gekozen" corner badge. In the swipe row the featured card is scrolled into view on first display (centered); if none is featured, the first card. After a filter change the row returns to its start (or the featured card if it is still visible). |
| BR-U3-8 | Dots (mobile only): one real <button> per visible card, aria-label="Pakket {n} van {total}: {title}", aria-current on the active one; clicking scrolls that card into view. The active dot follows the scroll position. Hidden when there is only one card. |
| BR-U3-9 | CTA "Kies …" (card) and the banner CTA: sets the preselect (subject = slug, key + 1) and scrolls to #contact. Without JavaScript the link still jumps to #contact. |
| BR-U3-10 | Loading: skeletons while loading — 3 in the grid, in the swipe row too (no layout shift). Error: message "Pakketten konden niet worden geladen." with a "Opnieuw proberen" button (refetch). Empty (0 packages): short text "Binnenkort meer informatie. Neem contact op voor een voorstel." and the banner when configured. |
| BR-U3-11 | Accessibility: section labelled by its heading; chips are buttons with aria-pressed; cards are articles with an h3; the price is plain text; focus order = chips → cards (links) → banner; all touch targets ≥ 44px; swipe row is focusable/keyboard scrollable (tabindex=0, role="group", aria-label="Pakketten"); animation (smooth scroll) respects reduced motion. |
| BR-U3-12 | Theme: B light/dark tokens; E styling is U5. Square corners, flat blocks, as in the canvas. |
Decision flow: split and chips
graph TD
S([Packages loaded]) --> SP{Slug in bannerSlugs}
SP -->|"yes"| B[Banner package]
SP -->|"no"| C[Card package]
C --> T{Card count at least threshold and a category exists}
T -->|"yes"| CH[Show chips and counts]
T -->|"no"| NC[No chips]
B --> BN[Show banner under the cards]
CH --> V[Filter cards by active chip]
NC --> V
classDef start fill:#CE93D8,stroke:#6A1B9A,color:#000;
classDef decision fill:#FFF59D,stroke:#F57F17,color:#000;
classDef step fill:#63b3ed,stroke:#2b6cb0,color:#000;
class S start;
class SP,T decision;
class B,C,CH,NC,BN,V step;
Text alternative: packages are split into cards and banner packages by slug; chips show when enough cards with categories exist; the active chip filters the cards; banner packages render under the cards.