diff --git a/web/src/components/CallToAction/CallToAction.test.tsx b/web/src/components/CallToAction/CallToAction.test.tsx
new file mode 100644
index 0000000..d3d6263
--- /dev/null
+++ b/web/src/components/CallToAction/CallToAction.test.tsx
@@ -0,0 +1,69 @@
+import { screen } from '@testing-library/react';
+import { describe, expect, it } from 'vitest';
+import LinkButton from '@/components/LinkButton';
+import RichParagraph from '@/components/RichParagraph/RichParagraph';
+import { axeResults } from '@/test/axe';
+import { renderWithProviders } from '@/test/renderWithProviders';
+import CallToAction from './CallToAction';
+
+describe('CallToAction', () => {
+ it('is a section named by its heading, with the lead and the action', async () => {
+ const { container } = await renderWithProviders(
+
+ }
+ data-testid="cta"
+ >
+
+ Boek je shoot
+
+ ,
+ );
+
+ const section = screen.getByRole('region', {
+ name: 'Benieuwd naar de prijzen?',
+ });
+ expect(section).toBe(screen.getByTestId('cta'));
+ expect(screen.getByRole('heading', { level: 2 })).toHaveAccessibleName(
+ 'Benieuwd naar de prijzen?',
+ );
+ expect(
+ screen.getByRole('link', { name: 'de pakketten' }),
+ ).toHaveAttribute('href', '/#prijzen');
+ expect(
+ screen.getByRole('link', { name: 'Boek je shoot' }),
+ ).toHaveAttribute('href', '/#contact');
+ expect(await axeResults(container)).toHaveNoViolations();
+ });
+
+ it('wraps a plain-text lead in a paragraph', async () => {
+ await renderWithProviders(
+
+ Contact
+ ,
+ );
+ expect(screen.getByText('Stuur me een bericht.').tagName).toBe('P');
+ });
+
+ it('leaves out the lead when there is none', async () => {
+ await renderWithProviders(
+
+ Contact
+ ,
+ );
+ expect(screen.queryByRole('paragraph')).toBeNull();
+ });
+});
diff --git a/web/src/components/CallToAction/CallToAction.tsx b/web/src/components/CallToAction/CallToAction.tsx
new file mode 100644
index 0000000..7469b47
--- /dev/null
+++ b/web/src/components/CallToAction/CallToAction.tsx
@@ -0,0 +1,50 @@
+import type { ReactNode } from 'react';
+import { Box, Heading, Text } from '@chakra-ui/react';
+import PageSection from '@/components/PageSection/PageSection';
+import Reveal from '@/components/Reveal/Reveal';
+
+type CallToActionProps = {
+ title: string;
+ // Id of the h2, which names the section
+ titleId: string;
+ // Plain text, or a paragraph with links in it (e.g. RichParagraph)
+ lead?: ReactNode;
+ 'data-testid'?: string;
+ // The action below the text, e.g. a LinkButton
+ children: ReactNode;
+};
+
+// Closing block of a page (design .section--alt.section--tight with a narrow,
+// centred column): a heading, a short lead and one action. The page chooses
+// the action and any link in the lead.
+export default function CallToAction({
+ title,
+ titleId,
+ lead,
+ 'data-testid': testId,
+ children,
+}: CallToActionProps) {
+ return (
+
+
+
+ {title}
+
+ {lead && (
+ // design .lead.mt-sm
+
+ {typeof lead === 'string' ? {lead} : lead}
+
+ )}
+ {/* design .mt-lg */}
+ {children}
+
+
+ );
+}
diff --git a/web/src/components/FramedImage/FramedImage.test.tsx b/web/src/components/FramedImage/FramedImage.test.tsx
index a87751d..f9c9174 100644
--- a/web/src/components/FramedImage/FramedImage.test.tsx
+++ b/web/src/components/FramedImage/FramedImage.test.tsx
@@ -1,6 +1,7 @@
import { screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { axeResults } from '@/test/axe';
+import { cssRulesFor } from '@/test/cssRules';
import { renderWithProviders } from '@/test/renderWithProviders';
import FramedImage from './FramedImage';
@@ -35,4 +36,32 @@ describe('FramedImage', () => {
expect(img).toHaveAttribute('fetchpriority', 'high');
expect(img).toHaveAttribute('width', '1200');
});
+
+ // The block is a ::before on the photo's wrapper
+ const frameRule = (img: Element) =>
+ cssRulesFor(img.parentElement!).find((rule) =>
+ rule.includes('::before {'),
+ );
+
+ it('puts a sand block behind the photo by default', async () => {
+ await renderWithProviders(
+ ,
+ );
+ expect(frameRule(screen.getByRole('img'))).toContain(
+ 'background: var(--slp-colors-sand)',
+ );
+ });
+
+ it('colours the block with the given token', async () => {
+ await renderWithProviders(
+ ,
+ );
+ expect(frameRule(screen.getByRole('img'))).toContain(
+ 'background: var(--slp-colors-frame-rust)',
+ );
+ });
});
diff --git a/web/src/components/FramedImage/FramedImage.tsx b/web/src/components/FramedImage/FramedImage.tsx
index 44a53d8..41c75aa 100644
--- a/web/src/components/FramedImage/FramedImage.tsx
+++ b/web/src/components/FramedImage/FramedImage.tsx
@@ -1,6 +1,6 @@
import { Box, Image, type ImageProps } from '@chakra-ui/react';
import DeferredImage from '@/components/DeferredImage/DeferredImage';
-import type { ContentImage } from '@/content/types';
+import type { ContentImage, FrameColor } from '@/content/types';
type FramedImageProps = {
image: ContentImage;
@@ -9,16 +9,19 @@ type FramedImageProps = {
// For a photo at the top of a page, likely the largest paint: load it
// straight away with high priority instead of after the page has loaded
priority?: boolean;
+ // Colour token of the block behind the photo
+ frameColor?: FrameColor;
};
-// A photo with a soft sand-coloured block offset behind its lower left
-// corner (design .about__media). The block is pure decoration (a CSS
-// pseudo-element), so assistive technology never announces it. On phones it
-// is left out, since it would stick out past the page edge.
+// A photo with a soft coloured block (sand by default) offset behind its
+// lower left corner (design .about__media). The block is pure decoration (a
+// CSS pseudo-element), so assistive technology never announces it. On phones
+// it is left out, since it would stick out past the page edge.
export default function FramedImage({
image,
aspectRatio,
priority = false,
+ frameColor = 'sand',
}: FramedImageProps) {
const style: ImageProps = {
display: 'block',
@@ -43,7 +46,7 @@ export default function FramedImage({
bottom: '-1.5rem',
width: '55%',
height: '55%',
- bg: 'sand',
+ bg: frameColor,
zIndex: -1,
}}
>
diff --git a/web/src/components/MediaText/MediaText.test.tsx b/web/src/components/MediaText/MediaText.test.tsx
index 7fb84e7..d68fa34 100644
--- a/web/src/components/MediaText/MediaText.test.tsx
+++ b/web/src/components/MediaText/MediaText.test.tsx
@@ -2,6 +2,7 @@ import { screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import type { ContentImage } from '@/content/types';
import { axeResults } from '@/test/axe';
+import { cssRulesFor } from '@/test/cssRules';
import { renderWithProviders } from '@/test/renderWithProviders';
import MediaText from './MediaText';
@@ -43,4 +44,44 @@ describe('MediaText', () => {
Node.DOCUMENT_POSITION_FOLLOWING,
).toBeTruthy();
});
+
+ const photoColumnRules = () =>
+ cssRulesFor(screen.getByRole('img').closest('[data-reveal]')!);
+
+ it('keeps the photo in the first column by default', async () => {
+ await renderWithProviders(
+
+ Hoi! Ik ben Andrea
+ ,
+ );
+ expect(photoColumnRules().join()).not.toContain('order');
+ });
+
+ it('moves the photo to the second column from lg when reversed, without changing the reading order', async () => {
+ await renderWithProviders(
+
+ Newborn
+ ,
+ );
+ expect(photoColumnRules()).toContainEqual(
+ expect.stringMatching(/min-width: 64rem.*order: 2;/),
+ );
+ const photo = screen.getByRole('img');
+ const heading = screen.getByRole('heading');
+ expect(
+ photo.compareDocumentPosition(heading) &
+ Node.DOCUMENT_POSITION_FOLLOWING,
+ ).toBeTruthy();
+ });
+
+ it('passes the frame colour on to the photo', async () => {
+ await renderWithProviders(
+
+ Gezin
+ ,
+ );
+ expect(
+ cssRulesFor(screen.getByRole('img').parentElement!).join(),
+ ).toContain('var(--slp-colors-accent)');
+ });
});
diff --git a/web/src/components/MediaText/MediaText.tsx b/web/src/components/MediaText/MediaText.tsx
index f40c7b9..a4254ad 100644
--- a/web/src/components/MediaText/MediaText.tsx
+++ b/web/src/components/MediaText/MediaText.tsx
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react';
import { Grid } from '@chakra-ui/react';
import FramedImage from '@/components/FramedImage/FramedImage';
import Reveal from '@/components/Reveal/Reveal';
-import type { ContentImage } from '@/content/types';
+import type { ContentImage, FrameColor } from '@/content/types';
type MediaTextProps = {
image: ContentImage;
@@ -10,18 +10,25 @@ type MediaTextProps = {
aspectRatio: string;
// The photo is at the top of the page and should not wait (FramedImage)
priority?: boolean;
+ // Photo in the right-hand column from `lg` (design .about--reverse).
+ // Only the visual order changes: the photo stays first in the DOM.
+ reverse?: boolean;
+ // Colour of the block behind the photo (FramedImage)
+ frameColor?: FrameColor;
'data-testid'?: string;
// The text column; each page fills in its own heading and text
children: ReactNode;
};
// A framed photo next to a text column (design .about), used on the
-// homepage and the about page. Stacked on phones and tablets, two equal
-// columns from `lg`; both columns fade in on scroll.
+// homepage, the about page and the shoot types page. Stacked on phones and
+// tablets, two equal columns from `lg`; both columns fade in on scroll.
export default function MediaText({
image,
aspectRatio,
priority,
+ reverse = false,
+ frameColor,
'data-testid': testId,
children,
}: MediaTextProps) {
@@ -32,11 +39,12 @@ export default function MediaText({
alignItems="center"
data-testid={testId}
>
-
+
{children}
diff --git a/web/src/components/about/RichParagraph/RichParagraph.test.tsx b/web/src/components/RichParagraph/RichParagraph.test.tsx
similarity index 100%
rename from web/src/components/about/RichParagraph/RichParagraph.test.tsx
rename to web/src/components/RichParagraph/RichParagraph.test.tsx
diff --git a/web/src/components/about/RichParagraph/RichParagraph.tsx b/web/src/components/RichParagraph/RichParagraph.tsx
similarity index 100%
rename from web/src/components/about/RichParagraph/RichParagraph.tsx
rename to web/src/components/RichParagraph/RichParagraph.tsx
diff --git a/web/src/components/about/AboutIntro/AboutIntro.tsx b/web/src/components/about/AboutIntro/AboutIntro.tsx
index 0754610..ee68aee 100644
--- a/web/src/components/about/AboutIntro/AboutIntro.tsx
+++ b/web/src/components/about/AboutIntro/AboutIntro.tsx
@@ -1,5 +1,5 @@
import { Stack } from '@chakra-ui/react';
-import RichParagraph from '@/components/about/RichParagraph/RichParagraph';
+import RichParagraph from '@/components/RichParagraph/RichParagraph';
import MediaText from '@/components/MediaText/MediaText';
import PageSection from '@/components/PageSection/PageSection';
import SectionHeading from '@/components/SectionHeading/SectionHeading';
diff --git a/web/src/components/home/Pricing/Pricing.test.tsx b/web/src/components/home/Pricing/Pricing.test.tsx
index 03636bb..64ee492 100644
--- a/web/src/components/home/Pricing/Pricing.test.tsx
+++ b/web/src/components/home/Pricing/Pricing.test.tsx
@@ -32,6 +32,16 @@ describe('Pricing', () => {
expect(await axeResults(container)).toHaveNoViolations();
});
+ it('can be linked to as /#prijzen', async () => {
+ await renderWithProviders(
+ ,
+ );
+ expect(screen.getByRole('region', { name: 'Prijzen' })).toHaveAttribute(
+ 'id',
+ 'prijzen',
+ );
+ });
+
it('keeps the decorations away from assistive technology', async () => {
const { container } = await renderWithProviders(
,
diff --git a/web/src/components/home/Pricing/Pricing.tsx b/web/src/components/home/Pricing/Pricing.tsx
index b1d2a84..1aaf42e 100644
--- a/web/src/components/home/Pricing/Pricing.tsx
+++ b/web/src/components/home/Pricing/Pricing.tsx
@@ -32,7 +32,12 @@ export default function Pricing({ content, packages }: PricingProps) {
if (shown.length === 0) return null;
return (
-
+
{content.decorations.map((decoration, index) => (
`.${name}`);
+ const matches = (rule: CSSStyleRule) =>
+ classes.some((name) => rule.selectorText.includes(name));
+
+ const found: string[] = [];
+ const walk = (rules: CSSRuleList, prefix: string) => {
+ for (const rule of rules) {
+ if (rule instanceof CSSStyleRule && matches(rule)) {
+ found.push(prefix + rule.cssText);
+ } else if (rule instanceof CSSMediaRule) {
+ walk(rule.cssRules, `@media ${rule.conditionText} `);
+ }
+ }
+ };
+ for (const sheet of document.styleSheets) {
+ walk(sheet.cssRules, '');
+ }
+ return found;
+}