diff --git a/web/src/components/SectionHeading/SectionHeading.test.tsx b/web/src/components/SectionHeading/SectionHeading.test.tsx index 0b456d9..4faacc6 100644 --- a/web/src/components/SectionHeading/SectionHeading.test.tsx +++ b/web/src/components/SectionHeading/SectionHeading.test.tsx @@ -1,6 +1,8 @@ import { screen } from '@testing-library/react'; import { describe, expect, it } from 'vitest'; +import CallToAction from '@/components/CallToAction/CallToAction'; import { axeResults } from '@/test/axe'; +import { cssRulesFor } from '@/test/cssRules'; import { renderWithProviders } from '@/test/renderWithProviders'; import SectionHeading from './SectionHeading'; @@ -50,4 +52,34 @@ describe('SectionHeading', () => { ).toHaveAttribute('id', 'about-title'); expect(screen.getByText('Over mij')).toBeInTheDocument(); }); + + it('shows the title in letter-spaced capitals without changing its text', async () => { + const title = 'Lifestyle fotograaf met een passie voor storytelling'; + await renderWithProviders(); + + const heading = screen.getByRole('heading', { level: 2 }); + // The case is CSS only: the text and the accessible name stay as given + expect(heading).toHaveTextContent(title); + expect(heading).toHaveAccessibleName(title); + + const rules = cssRulesFor(heading).join(); + expect(rules).toContain('text-transform: uppercase'); + // The wide spacing is the shared "caps" token (0.22em) + expect(rules).toContain( + 'letter-spacing: var(--slp-letter-spacings-caps)', + ); + }); + + it('does not give the plain section titles of other blocks the new style', async () => { + await renderWithProviders( + + Actie + , + ); + + const rules = cssRulesFor( + screen.getByRole('heading', { level: 2 }), + ).join(); + expect(rules).not.toContain('text-transform: uppercase'); + }); }); diff --git a/web/src/components/SectionHeading/SectionHeading.tsx b/web/src/components/SectionHeading/SectionHeading.tsx index 28d4ed8..0a019bd 100644 --- a/web/src/components/SectionHeading/SectionHeading.tsx +++ b/web/src/components/SectionHeading/SectionHeading.tsx @@ -16,8 +16,9 @@ type SectionHeadingProps = { focusable?: boolean; }; -// Heading block of a homepage section (design .section__head): optional -// small label, the h2 and an optional intro sentence. +// Heading block of a section (design .section__head): optional small label, +// the h2 in letter-spaced capitals (the case is only CSS, the text stays as +// given) and an optional intro sentence. export default function SectionHeading({ id, title, @@ -40,7 +41,7 @@ export default function SectionHeading({ {title} diff --git a/web/src/theme.ts b/web/src/theme.ts index 6b02b10..2542842 100644 --- a/web/src/theme.ts +++ b/web/src/theme.ts @@ -197,7 +197,19 @@ const config = defineConfig({ lineHeight: '1', }, }, - // The h2 of a homepage section (SectionHeading); smaller than the + // The h2 of a section block (SectionHeading): letter-spaced + // capitals, as on the live site. 26px on phones, 30px from md. + sectionHeading: { + value: { + fontFamily: 'heading', + fontSize: { base: '1.625rem', md: '1.875rem' }, + lineHeight: '1.15', + letterSpacing: 'caps', + textTransform: 'uppercase', + }, + }, + // Plain h2 in blocks that do not use SectionHeading (call to + // action, packages, shoot and story blocks); smaller than the // design's 2.5rem at the owner's request, 30px at every width sectionTitle: { value: {