From ba7288526b41a3cf518224938a33e5952923017a Mon Sep 17 00:00:00 2001 From: Sluijsens Date: Sun, 15 Nov 2026 14:15:23 +0100 Subject: [PATCH] Gives a featured package a quiet highlight and makes the optional CMS fields explicit A featured card gets a heidegroen top rule, border and a small "Uitgelicht" tab on its top edge; the tab sits on the border so the row keeps its layout. Tests and docs state that the site does not depend on description, price note or button label. Co-Authored-By: Claude Sonnet 5.5 --- docs/cms-integration.md | 2 ++ .../home/Pricing/PriceCard.test.tsx | 36 +++++++++++++++++++ web/src/components/home/Pricing/PriceCard.tsx | 30 +++++++++++++++- web/src/lib/offerings.test.ts | 16 +++++++++ 4 files changed, 83 insertions(+), 1 deletion(-) diff --git a/docs/cms-integration.md b/docs/cms-integration.md index 20f58ab..2606a60 100644 --- a/docs/cms-integration.md +++ b/docs/cms-integration.md @@ -12,6 +12,8 @@ Source: `GET /api/v1/offerings`. One list feeds the price cards on the home page 1. At build time `web/config/fetchOfferings.ts` (the first step of `pnpm build`) asks `OFFERINGS_URL` (10 s timeout, 2 attempts) and writes the gitignored `web/src/content/offerings.generated.json`. The packages are baked into the prerendered HTML (search engines see the prices, no layout jump). 2. Without `OFFERINGS_URL`, with a CMS that is down or with an unusable answer, the committed `web/src/content/offerings.snapshot.json` is used. The build never fails and never shows empty prices; the log says which source was used. Tests always use the snapshot. 3. After hydration `PackagesProvider` (`web/src/components/PackagesProvider/`) asks the CMS once and replaces the baked list only if the answer differs. A network error, time-out (8 s), bad status or invalid answer keeps what was baked. A change in the CMS therefore shows at once; the nightly build only matters for search engines. +- **Featured package** (the star in the CMS admin, field `featured`): the card gets a heidegroen rule along its top, a heidegroen border and a small "Uitgelicht" tab on the top edge (`PriceCard`). The tab is positioned on the border, so the cards of a row keep the same layout. Any number of cards may be featured. +- **Description, price note and button label** (`description`, `priceNote`, `ctaLabel`) are optional in the CMS and the site does not use them: they are not shown and a card never depends on them (empty, `null` or absent all give the same card; covered by tests). - **Scheduling in the CMS:** the API only returns packages that are live at the moment of the request (switched on and inside their from/to dates), so the site shows them and nothing else. The baked list reflects the moment of the build; the live refresh after hydration corrects it for every visitor, and the nightly build corrects it for search engines. A package that goes live or expires between two builds is therefore right in the browser but can be stale in the HTML until the next build. - **Keep the snapshot current** when the real packages change (prices, features), because production builds use it (see "Reverse proxy" below). diff --git a/web/src/components/home/Pricing/PriceCard.test.tsx b/web/src/components/home/Pricing/PriceCard.test.tsx index 77095ff..2278d08 100644 --- a/web/src/components/home/Pricing/PriceCard.test.tsx +++ b/web/src/components/home/Pricing/PriceCard.test.tsx @@ -42,4 +42,40 @@ describe('PriceCard', () => { expect(link).toHaveTextContent('Boek je shoot'); expect(link).toHaveAttribute('href', '/?pakket=bruiloft#contact'); }); + + it('marks a featured package with a tab and leaves others plain', async () => { + const { container } = await renderWithProviders( + <> + + + , + ); + const featured = screen.getByTestId('price-card-newborn'); + expect(featured).toHaveAttribute('data-featured', 'true'); + expect(within(featured).getByText('Uitgelicht')).toBeInTheDocument(); + const plain = screen.getByTestId(`price-card-${packages[0].id}`); + expect(plain).not.toHaveAttribute('data-featured'); + expect(within(plain).queryByText('Uitgelicht')).not.toBeInTheDocument(); + expect(await axeResults(container)).toHaveNoViolations(); + }); + + it('does not depend on the description, price note or button label', async () => { + await renderWithProviders( + , + ); + const card = screen.getByTestId('price-card-newborn'); + expect(card).not.toHaveTextContent('Een beschrijving'); + expect(card).not.toHaveTextContent('Een notitie'); + expect(card).not.toHaveTextContent('Een knop'); + expect( + within(card).getByRole('link', { name: 'Boek Newborn' }), + ).toBeInTheDocument(); + }); }); diff --git a/web/src/components/home/Pricing/PriceCard.tsx b/web/src/components/home/Pricing/PriceCard.tsx index ca7f9ac..55fa49c 100644 --- a/web/src/components/home/Pricing/PriceCard.tsx +++ b/web/src/components/home/Pricing/PriceCard.tsx @@ -17,6 +17,12 @@ type PriceCardProps = { // One package (design .price-card): name, price, what is included and a // link that takes the visitor to the contact form with this package chosen. +// A featured package (the star in the CMS) gets the quiet highlight of the +// banners: a heidegroen rule along the top, a heidegroen border and a small +// "Uitgelicht" tab on the top edge. The tab sits on the border instead of in +// the card, so the cards of a row keep the same layout. The package's +// description and price note from the CMS are not shown, so the card never +// depends on them. export default function PriceCard({ pkg }: PriceCardProps) { const label = bookLabel(pkg.name); const linkButton = useRecipe({ key: 'linkButton' }); @@ -25,6 +31,8 @@ export default function PriceCard({ pkg }: PriceCardProps) { + {pkg.featured && ( + + Uitgelicht + + )} {/* Smaller than the design's 1.75rem: stays clearly below the 30px section h2 (owner's request) */} diff --git a/web/src/lib/offerings.test.ts b/web/src/lib/offerings.test.ts index 9702d9d..95a1019 100644 --- a/web/src/lib/offerings.test.ts +++ b/web/src/lib/offerings.test.ts @@ -125,6 +125,22 @@ describe('mapOfferings', () => { }); }); +describe('mapOfferings without description, price note and button label', () => { + const bare = { slug: 'x', title: 'X', price: '€ 100', features: ['a'] }; + + it.each([ + ['absent', {}], + ['null', { description: null, priceNote: null, ctaLabel: null }], + ['empty', { description: '', priceNote: ' ', ctaLabel: '' }], + ])('still gives the card when they are %s', (_name, extra) => { + const mapped = mapOfferings([{ ...bare, ...extra }]); + expect(mapped?.packages).toHaveLength(1); + expect(mapped?.packages[0]).toMatchObject({ id: 'x', price: 100 }); + expect(mapped?.packages[0].description).toBeUndefined(); + expect(mapped?.packages[0].priceNote).toBeUndefined(); + }); +}); + describe('mapBanner', () => { it('neemt titel, tekst en een volledige link', () => { expect(