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 <noreply@anthropic.com>
This commit is contained in:
@@ -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(
|
||||
<>
|
||||
<PriceCard pkg={{ ...newborn, featured: true }} />
|
||||
<PriceCard pkg={packages[0]} />
|
||||
</>,
|
||||
);
|
||||
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(
|
||||
<PriceCard
|
||||
pkg={{
|
||||
...newborn,
|
||||
description: 'Een beschrijving',
|
||||
priceNote: 'Een notitie',
|
||||
ctaLabel: 'Een knop',
|
||||
}}
|
||||
/>,
|
||||
);
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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) {
|
||||
<Box
|
||||
as="article"
|
||||
data-testid={`price-card-${pkg.id}`}
|
||||
data-featured={pkg.featured ? 'true' : undefined}
|
||||
position="relative"
|
||||
display="flex"
|
||||
flexDirection="column"
|
||||
h="100%"
|
||||
@@ -32,11 +40,31 @@ export default function PriceCard({ pkg }: PriceCardProps) {
|
||||
py="clamp(2rem, 3.5vw, 3rem)"
|
||||
bg="white"
|
||||
borderWidth="1px"
|
||||
borderColor="line"
|
||||
borderColor={pkg.featured ? 'accent' : 'line'}
|
||||
// The rule is an inset shadow, so it adds no width to the border
|
||||
boxShadow={
|
||||
pkg.featured ? 'inset 0 3px 0 {colors.accent}' : undefined
|
||||
}
|
||||
// No hover effect on the card itself (owner's choice); only the
|
||||
// booking button reacts
|
||||
textAlign="center"
|
||||
>
|
||||
{pkg.featured && (
|
||||
<Text
|
||||
textStyle="eyebrow"
|
||||
position="absolute"
|
||||
top="0"
|
||||
left="50%"
|
||||
transform="translate(-50%, -50%)"
|
||||
px={3}
|
||||
py={1}
|
||||
bg="accent.deep"
|
||||
color="white"
|
||||
whiteSpace="nowrap"
|
||||
>
|
||||
Uitgelicht
|
||||
</Text>
|
||||
)}
|
||||
{/* Smaller than the design's 1.75rem: stays clearly below the
|
||||
30px section h2 (owner's request) */}
|
||||
<Heading as="h3" fontSize="1.5rem" mb={3}>
|
||||
|
||||
Reference in New Issue
Block a user