Redesigns the testimonials section #16
@@ -1,6 +1,8 @@
|
|||||||
import { screen } from '@testing-library/react';
|
import { screen } from '@testing-library/react';
|
||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import CallToAction from '@/components/CallToAction/CallToAction';
|
||||||
import { axeResults } from '@/test/axe';
|
import { axeResults } from '@/test/axe';
|
||||||
|
import { cssRulesFor } from '@/test/cssRules';
|
||||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||||
import SectionHeading from './SectionHeading';
|
import SectionHeading from './SectionHeading';
|
||||||
|
|
||||||
@@ -50,4 +52,34 @@ describe('SectionHeading', () => {
|
|||||||
).toHaveAttribute('id', 'about-title');
|
).toHaveAttribute('id', 'about-title');
|
||||||
expect(screen.getByText('Over mij')).toBeInTheDocument();
|
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(<SectionHeading id="t" title={title} />);
|
||||||
|
|
||||||
|
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(
|
||||||
|
<CallToAction title="Benieuwd naar de prijzen?" titleId="cta-title">
|
||||||
|
<span>Actie</span>
|
||||||
|
</CallToAction>,
|
||||||
|
);
|
||||||
|
|
||||||
|
const rules = cssRulesFor(
|
||||||
|
screen.getByRole('heading', { level: 2 }),
|
||||||
|
).join();
|
||||||
|
expect(rules).not.toContain('text-transform: uppercase');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ type SectionHeadingProps = {
|
|||||||
focusable?: boolean;
|
focusable?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Heading block of a homepage section (design .section__head): optional
|
// Heading block of a section (design .section__head): optional small label,
|
||||||
// small label, the h2 and an optional intro sentence.
|
// 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({
|
export default function SectionHeading({
|
||||||
id,
|
id,
|
||||||
title,
|
title,
|
||||||
@@ -40,7 +41,7 @@ export default function SectionHeading({
|
|||||||
<Heading
|
<Heading
|
||||||
as="h2"
|
as="h2"
|
||||||
id={id}
|
id={id}
|
||||||
textStyle="sectionTitle"
|
textStyle="sectionHeading"
|
||||||
tabIndex={focusable ? -1 : undefined}
|
tabIndex={focusable ? -1 : undefined}
|
||||||
>
|
>
|
||||||
{title}
|
{title}
|
||||||
|
|||||||
+13
-1
@@ -197,7 +197,19 @@ const config = defineConfig({
|
|||||||
lineHeight: '1',
|
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
|
// design's 2.5rem at the owner's request, 30px at every width
|
||||||
sectionTitle: {
|
sectionTitle: {
|
||||||
value: {
|
value: {
|
||||||
|
|||||||
Reference in New Issue
Block a user