Lets the price banner work with empty fields

Only the banner title is required; description, price, price note, features
and the button label are left out when empty (the button then says Neem contact
op).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-12 09:42:35 +01:00
co-authored by Claude Sonnet 5.5
parent 4cae76b21d
commit f9180f231f
5 changed files with 74 additions and 21 deletions
+14 -10
View File
@@ -10,6 +10,8 @@ type PriceBannerProps = {
// layout=banner in the CMS), for an offer or an announcement. It is not a
// bookable package: the button only leads to the contact form, without a
// chosen package. The price is free text from the CMS ("€ 99 i.p.v. € 150").
// Only the title is required; whatever is empty is left out. Without a button
// label the button says "Neem contact op".
export default function PriceBanner({ banner }: PriceBannerProps) {
const linkButton = useRecipe({ key: 'linkButton' });
@@ -60,23 +62,25 @@ export default function PriceBanner({ banner }: PriceBannerProps) {
)}
</Box>
<Box textAlign={{ base: 'start', md: 'center' }}>
<Text
fontFamily="heading"
fontSize="1.75rem"
lineHeight="1.1"
color="white"
>
{banner.priceText}
</Text>
{banner.priceText && (
<Text
fontFamily="heading"
fontSize="1.75rem"
lineHeight="1.1"
color="white"
>
{banner.priceText}
</Text>
)}
{banner.priceNote && (
<Text fontSize="sm" opacity={0.85} mb={4}>
<Text fontSize="sm" opacity={0.85}>
{banner.priceNote}
</Text>
)}
<Box
asChild
css={linkButton({ variant: 'light', size: 'fit' })}
mt={banner.priceNote ? 0 : 4}
mt={banner.priceText || banner.priceNote ? 4 : 0}
>
<Link to="/" hash="contact" data-testid="price-banner-cta">
{banner.ctaLabel ?? 'Neem contact op'}
@@ -63,6 +63,27 @@ describe('Pricing', () => {
expect(await axeResults(container)).toHaveNoViolations();
});
it('hides every empty field of the banner', async () => {
const { container } = await renderWithProviders(
<Pricing
content={content}
packages={packages}
banner={{ title: 'Past er niets bij?', features: [] }}
/>,
);
const shown = screen.getByTestId('price-banner');
expect(
within(shown).getByRole('heading', { level: 3 }),
).toHaveTextContent('Past er niets bij?');
expect(shown.querySelectorAll('ul, li')).toHaveLength(0);
// Only the heading and the button have text
expect(shown.querySelectorAll('p')).toHaveLength(0);
expect(
within(shown).getByRole('link', { name: 'Neem contact op' }),
).toBeInTheDocument();
expect(await axeResults(container)).toHaveNoViolations();
});
it('shows no banner without one', async () => {
await renderWithProviders(
<Pricing content={content} packages={packages} banner={null} />,