Adds the Over mij page #7
+49
@@ -0,0 +1,49 @@
|
|||||||
|
# Code Generation Plan — Unit 1: Shared blocks
|
||||||
|
|
||||||
|
Single source of truth for code generation of this unit. Workspace root: `K:\Development\SlpSoftware\Projects\AndreaSlopFotografie`; all code in `web/src/`. Branch `feature/over-mij-page`.
|
||||||
|
|
||||||
|
## Unit Context
|
||||||
|
- **Requirements**: FR-OM-09 (`HomeSection` → `PageSection`), FR-OM-10 (shared media+text block), NFR-OM-02 (reuse, tokens, English comments), NFR-OM-03 (tests)
|
||||||
|
- **Design**: [application-design.md](../../inception/application-design/application-design.md) — `Eyebrow` (Q2), `PageSection` + `flushTop`, `MediaText` layout-only (Q1)
|
||||||
|
- **Dependencies**: none on other units; unit 2 builds on everything here
|
||||||
|
- **Behavioural contract**: the homepage renders exactly as before — same DOM roles, names, texts, styles. Existing tests must pass unchanged except for renamed imports/names.
|
||||||
|
- **No business logic, no new pure helpers** → no property-based tests in this unit (PBT rules N/A: no properties to test in layout components). Example-based component tests + axe.
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
### Eyebrow
|
||||||
|
- [x] **Step 1** — Create `components/Eyebrow/Eyebrow.tsx`: Chakra `Text` with `textStyle="eyebrow"`, `color="accent.deep"`, `mb={4}`, an `as` prop (`'p' | 'span' | 'h2' | 'h3' | 'h4'`, default `p`) and pass-through `TextProps`. Comment: why `accent.deep` (4.5:1).
|
||||||
|
- [x] **Step 2** — Create `components/Eyebrow/Eyebrow.test.tsx`: renders a paragraph by default; with `as="h3"` it is a level-3 heading with that name and can carry an `id`; extra props (e.g. `mb`) pass through; axe clean.
|
||||||
|
- [x] **Step 3** — Switch the four identical inline labels to `Eyebrow` (same output): `SectionHeading`, `PageIntro`, `ContactForm/ContactFormGate`, `home/Testimonials/TestimonialSlide` (only its shoot label, not the author line). Remove the then-duplicated contrast comments where `Eyebrow` now carries the reason.
|
||||||
|
|
||||||
|
### PageSection
|
||||||
|
- [x] **Step 4** — Rename `components/HomeSection/` → `components/PageSection/` (`git mv` for the component and its test), rename the component and props type, update the doc comment to "a content section on any page".
|
||||||
|
- [x] **Step 5** — Add `spacing="flushTop"`: no top padding, bottom padding as `default` (design `.section--flush-top`).
|
||||||
|
- [x] **Step 6** — Update all importers: `home/AboutBlock`, `home/ContactSection`, `home/InstagramGrid`, `home/IntroGallery`, `home/Pricing/Pricing`, `home/Testimonials/Testimonials`.
|
||||||
|
- [x] **Step 7** — Update `PageSection.test.tsx`: renamed; add a case for `flushTop` (top padding 0, bottom padding kept).
|
||||||
|
|
||||||
|
### MediaText
|
||||||
|
- [x] **Step 8** — Create `components/MediaText/MediaText.tsx`: grid `1fr` → `1fr 1fr` from `lg`, gap `clamp(2rem, 6vw, 5.5rem)`, `alignItems="center"`; first column `Reveal` → `FramedImage image aspectRatio`; second column `Reveal` → `children`. Props: `image`, `aspectRatio`, `data-testid?`, `children`.
|
||||||
|
- [x] **Step 9** — Create `components/MediaText/MediaText.test.tsx`: shows the image with its alt text and the children; photo comes before the text in DOM order; axe clean.
|
||||||
|
- [x] **Step 10** — Switch `home/AboutBlock` to `PageSection` + `MediaText` (the text column keeps `SectionHeading`, the paragraphs and the link). `AboutBlock.test.tsx` passes unchanged.
|
||||||
|
|
||||||
|
### Verification and summary
|
||||||
|
- [x] **Step 11** — Search for leftovers: no `HomeSection` references in `web/` (code, tests, comments); no duplicate component files.
|
||||||
|
- [x] **Step 12** — Run `pnpm check` in `web/` (lint, format, typecheck/build, tests with coverage, audits, Lighthouse). Fix and rerun until green.
|
||||||
|
- [x] **Step 13** — Visual check of the homepage against master in the browser (desktop and phone width): About block, section headings, page intro of a placeholder page, contact notice, testimonial label — no visible difference.
|
||||||
|
- [x] **Step 14** — Update the shared reverse engineering docs where they name `HomeSection` (architecture, code-structure, api-documentation, component-inventory, code-quality-assessment: debt item resolved) and list `Eyebrow`, `MediaText`.
|
||||||
|
- [x] **Step 15** — Write `aidlc-docs/features/over-mij-page/construction/shared-blocks/code/code-summary.md` (created/modified files, tests, verification outcome).
|
||||||
|
- [ ] **Step 16** — Commit on `feature/over-mij-page` (no push until asked).
|
||||||
|
|
||||||
|
## Files
|
||||||
|
- **Created**: `components/Eyebrow/Eyebrow.tsx`, `Eyebrow.test.tsx`; `components/MediaText/MediaText.tsx`, `MediaText.test.tsx`
|
||||||
|
- **Renamed + modified**: `components/HomeSection/*` → `components/PageSection/PageSection.tsx`, `PageSection.test.tsx`
|
||||||
|
- **Modified**: `components/SectionHeading/SectionHeading.tsx`, `components/PageIntro/PageIntro.tsx`, `components/ContactForm/ContactFormGate.tsx`, `components/home/Testimonials/TestimonialSlide.tsx`, `components/home/AboutBlock/AboutBlock.tsx`, `components/home/{ContactSection,InstagramGrid,IntroGallery,Pricing/Pricing,Testimonials/Testimonials}.tsx`
|
||||||
|
- **Docs**: `aidlc-docs/_shared/reverse-engineering/*.md` (names), unit code summary
|
||||||
|
|
||||||
|
## Extension Compliance (unit 1)
|
||||||
|
| Rule | Status | Rationale |
|
||||||
|
|---|---|---|
|
||||||
|
| SECURITY-10 | Compliant | No new dependencies |
|
||||||
|
| Other SECURITY rules | N/A | Presentational refactor; no data, endpoints, headers or config |
|
||||||
|
| PBT-01..10 | N/A | No pure functions or business logic in this unit; example-based component tests cover the layout contract (PBT-10 complementary testing applies in unit 2) |
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Code Summary — Unit 1: Shared blocks
|
||||||
|
|
||||||
|
Plan: [shared-blocks-code-generation-plan.md](../../plans/shared-blocks-code-generation-plan.md). Requirements: FR-OM-09, FR-OM-10, NFR-OM-02, NFR-OM-03.
|
||||||
|
|
||||||
|
## Created
|
||||||
|
- `web/src/components/Eyebrow/Eyebrow.tsx` — accent label (`textStyle="eyebrow"`, `accent.deep`, `mb={4}`), `as` prop for `p`/`span`/`h2`–`h4`, other `TextProps` pass through
|
||||||
|
- `web/src/components/Eyebrow/Eyebrow.test.tsx` — paragraph by default; as h3 a heading that names a region; props pass through; axe
|
||||||
|
- `web/src/components/MediaText/MediaText.tsx` — framed photo next to a text column (`children`), stacked below `lg`, both columns in `Reveal`
|
||||||
|
- `web/src/components/MediaText/MediaText.test.tsx` — photo and text shown, photo first in DOM order; axe
|
||||||
|
|
||||||
|
## Renamed and modified
|
||||||
|
- `web/src/components/HomeSection/HomeSection.tsx` → `web/src/components/PageSection/PageSection.tsx` — renamed component/props; new `spacing="flushTop"` (no top padding, bottom padding as default)
|
||||||
|
- `HomeSection.test.tsx` → `PageSection.test.tsx` — renamed; new case for `flushTop`
|
||||||
|
|
||||||
|
## Modified
|
||||||
|
- `components/SectionHeading/SectionHeading.tsx`, `components/PageIntro/PageIntro.tsx`, `components/ContactForm/ContactFormGate.tsx`, `components/home/Testimonials/TestimonialSlide.tsx` — inline label replaced by `Eyebrow` (contrast comment now lives in `Eyebrow`)
|
||||||
|
- `components/home/AboutBlock/AboutBlock.tsx` — uses `PageSection` + `MediaText`
|
||||||
|
- `components/home/{ContactSection,InstagramGrid,IntroGallery,Pricing/Pricing,Testimonials/Testimonials}.tsx` — import `PageSection`
|
||||||
|
- `aidlc-docs/_shared/reverse-engineering/*.md` — names updated (`PageSection`, `MediaText`, `Eyebrow`); `HomeSection` debt item removed
|
||||||
|
|
||||||
|
## Verification
|
||||||
|
- **Leftovers**: no `HomeSection` in `web/` source, tests or comments
|
||||||
|
- **`pnpm check`**: lint, format, typecheck/build, 55 test files / 250 tests, coverage thresholds, audits — passed. Lighthouse failed in the first run (mobile performance `/` 0.71, `/over-mij` 0.87) because a second production build was running at the same time on the same machine; rerun alone: passed — mobile `/` 0.82 (budget 0.8), other pages 0.94–0.95; desktop 0.99–1; accessibility 1 everywhere
|
||||||
|
- **Homepage unchanged**: master and branch production builds compared in headless Chrome at 1440, 768 and 390 px (reduced motion, after scrolling through the page): tag, ids, `aria-labelledby`, alt, text, position, size and 21 computed styles of every element in `<main>` — 233/233 elements identical on `/`, identical on `/over-mij` and `/contact` (placeholders with `PageIntro`). The same comparison of master against itself is also identical, so the method is stable. (Byte-for-byte screenshots were not usable: they already differ between two runs of master, through image loading and timing.)
|
||||||
|
|
||||||
|
## Extension Compliance
|
||||||
|
| Rule | Status | Rationale |
|
||||||
|
|---|---|---|
|
||||||
|
| SECURITY-10 | Compliant | No new dependencies |
|
||||||
|
| Other SECURITY rules | N/A | Presentational refactor only |
|
||||||
|
| PBT-01..10 | N/A | No pure functions or business logic in this unit |
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { Box, chakra, Link, Text, useRecipe } from '@chakra-ui/react';
|
import { Box, chakra, Link, Text, useRecipe } from '@chakra-ui/react';
|
||||||
|
import Eyebrow from '@/components/Eyebrow/Eyebrow';
|
||||||
import type { EmailAddress } from '@/content/types';
|
import type { EmailAddress } from '@/content/types';
|
||||||
import { emailAddress } from '@/lib/emailAddress';
|
import { emailAddress } from '@/lib/emailAddress';
|
||||||
import { mailtoLink } from '@/lib/mailLink';
|
import { mailtoLink } from '@/lib/mailLink';
|
||||||
@@ -46,10 +47,7 @@ export default function ContactFormGate({
|
|||||||
textAlign="center"
|
textAlign="center"
|
||||||
data-testid="contact-gate-notice"
|
data-testid="contact-gate-notice"
|
||||||
>
|
>
|
||||||
{/* accent.deep instead of the design's accent: meets 4.5:1 */}
|
<Eyebrow>Binnenkort</Eyebrow>
|
||||||
<Text textStyle="eyebrow" color="accent.deep" mb={4}>
|
|
||||||
Binnenkort
|
|
||||||
</Text>
|
|
||||||
<Text color="ink.soft" mb={address ? 7 : 0}>
|
<Text color="ink.soft" mb={address ? 7 : 0}>
|
||||||
Het contactformulier komt binnenkort.
|
Het contactformulier komt binnenkort.
|
||||||
{address && (
|
{address && (
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import { screen } from '@testing-library/react';
|
||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import { axeResults } from '@/test/axe';
|
||||||
|
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||||
|
import Eyebrow from './Eyebrow';
|
||||||
|
|
||||||
|
describe('Eyebrow', () => {
|
||||||
|
it('is a paragraph by default', async () => {
|
||||||
|
const { container } = await renderWithProviders(
|
||||||
|
<Eyebrow>Over mij</Eyebrow>,
|
||||||
|
);
|
||||||
|
expect(screen.getByText('Over mij').tagName).toBe('P');
|
||||||
|
expect(screen.queryByRole('heading')).not.toBeInTheDocument();
|
||||||
|
expect(await axeResults(container)).toHaveNoViolations();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('can be a heading that a section refers to by id', async () => {
|
||||||
|
const { container } = await renderWithProviders(
|
||||||
|
<section aria-labelledby="story-title">
|
||||||
|
<Eyebrow as="h3" id="story-title">
|
||||||
|
Hoe het begon
|
||||||
|
</Eyebrow>
|
||||||
|
</section>,
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
screen.getByRole('heading', { level: 3, name: 'Hoe het begon' }),
|
||||||
|
).toHaveAttribute('id', 'story-title');
|
||||||
|
expect(
|
||||||
|
screen.getByRole('region', { name: 'Hoe het begon' }),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(await axeResults(container)).toHaveNoViolations();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('passes other props through', async () => {
|
||||||
|
await renderWithProviders(
|
||||||
|
<Eyebrow data-testid="label" textAlign="center">
|
||||||
|
Binnenkort
|
||||||
|
</Eyebrow>,
|
||||||
|
);
|
||||||
|
expect(screen.getByTestId('label')).toHaveTextContent('Binnenkort');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Text, type TextProps } from '@chakra-ui/react';
|
||||||
|
|
||||||
|
type EyebrowProps = Omit<TextProps, 'as'> & {
|
||||||
|
// A heading level makes the label a real heading that keeps the small
|
||||||
|
// label look, e.g. the story headings on the about page
|
||||||
|
as?: 'p' | 'span' | 'h2' | 'h3' | 'h4';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Small capitals label above a heading or text (design .eyebrow).
|
||||||
|
// accent.deep instead of the design's accent: meets 4.5:1 on paper and white.
|
||||||
|
export default function Eyebrow({ as = 'p', ...rest }: EyebrowProps) {
|
||||||
|
return (
|
||||||
|
<Text
|
||||||
|
as={as}
|
||||||
|
textStyle="eyebrow"
|
||||||
|
color="accent.deep"
|
||||||
|
mb={4}
|
||||||
|
{...rest}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import { screen } from '@testing-library/react';
|
||||||
|
import { describe, expect, it } from 'vitest';
|
||||||
|
import type { ContentImage } from '@/content/types';
|
||||||
|
import { axeResults } from '@/test/axe';
|
||||||
|
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||||
|
import MediaText from './MediaText';
|
||||||
|
|
||||||
|
const image: ContentImage = {
|
||||||
|
src: '/andrea.jpg',
|
||||||
|
alt: 'Andrea met haar camera',
|
||||||
|
width: 1200,
|
||||||
|
height: 800,
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('MediaText', () => {
|
||||||
|
it('shows the photo and the text column', async () => {
|
||||||
|
const { container } = await renderWithProviders(
|
||||||
|
<MediaText image={image} aspectRatio="4 / 3" data-testid="block">
|
||||||
|
<h2>Hoi! Ik ben Andrea</h2>
|
||||||
|
<p>Lifestyle fotograaf uit Huizen.</p>
|
||||||
|
</MediaText>,
|
||||||
|
);
|
||||||
|
expect(screen.getByRole('img')).toHaveAccessibleName(image.alt);
|
||||||
|
expect(
|
||||||
|
screen.getByRole('heading', { name: 'Hoi! Ik ben Andrea' }),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(
|
||||||
|
screen.getByText('Lifestyle fotograaf uit Huizen.'),
|
||||||
|
).toBeInTheDocument();
|
||||||
|
expect(await axeResults(container)).toHaveNoViolations();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('puts the photo before the text, also when stacked', async () => {
|
||||||
|
await renderWithProviders(
|
||||||
|
<MediaText image={image} aspectRatio="4 / 3">
|
||||||
|
<h2>Hoi! Ik ben Andrea</h2>
|
||||||
|
</MediaText>,
|
||||||
|
);
|
||||||
|
const photo = screen.getByRole('img');
|
||||||
|
const heading = screen.getByRole('heading');
|
||||||
|
expect(
|
||||||
|
photo.compareDocumentPosition(heading) &
|
||||||
|
Node.DOCUMENT_POSITION_FOLLOWING,
|
||||||
|
).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
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';
|
||||||
|
|
||||||
|
type MediaTextProps = {
|
||||||
|
image: ContentImage;
|
||||||
|
// CSS aspect ratio of the visible crop, e.g. '4 / 3'
|
||||||
|
aspectRatio: string;
|
||||||
|
'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.
|
||||||
|
export default function MediaText({
|
||||||
|
image,
|
||||||
|
aspectRatio,
|
||||||
|
'data-testid': testId,
|
||||||
|
children,
|
||||||
|
}: MediaTextProps) {
|
||||||
|
return (
|
||||||
|
<Grid
|
||||||
|
templateColumns={{ base: '1fr', lg: '1fr 1fr' }}
|
||||||
|
gap="clamp(2rem, 6vw, 5.5rem)"
|
||||||
|
alignItems="center"
|
||||||
|
data-testid={testId}
|
||||||
|
>
|
||||||
|
<Reveal>
|
||||||
|
<FramedImage image={image} aspectRatio={aspectRatio} />
|
||||||
|
</Reveal>
|
||||||
|
<Reveal>{children}</Reveal>
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { Container, Heading, Text } from '@chakra-ui/react';
|
import { Container, Heading, Text } from '@chakra-ui/react';
|
||||||
|
import Eyebrow from '@/components/Eyebrow/Eyebrow';
|
||||||
|
|
||||||
type PageIntroProps = {
|
type PageIntroProps = {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -21,12 +22,7 @@ export default function PageIntro({
|
|||||||
pb={{ base: 8, md: 12, lg: 16 }}
|
pb={{ base: 8, md: 12, lg: 16 }}
|
||||||
textAlign="center"
|
textAlign="center"
|
||||||
>
|
>
|
||||||
{eyebrow && (
|
{eyebrow && <Eyebrow>{eyebrow}</Eyebrow>}
|
||||||
// accent.deep i.p.v. accent uit het design: haalt 4.5:1 (NFR-01)
|
|
||||||
<Text textStyle="eyebrow" color="accent.deep" mb={4}>
|
|
||||||
{eyebrow}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
<Heading as="h1" textStyle="pageTitle" mb={4}>
|
<Heading as="h1" textStyle="pageTitle" mb={4}>
|
||||||
{title}
|
{title}
|
||||||
</Heading>
|
</Heading>
|
||||||
|
|||||||
+30
-8
@@ -2,14 +2,14 @@ import { screen } from '@testing-library/react';
|
|||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
import { axeResults } from '@/test/axe';
|
import { axeResults } from '@/test/axe';
|
||||||
import { renderWithProviders } from '@/test/renderWithProviders';
|
import { renderWithProviders } from '@/test/renderWithProviders';
|
||||||
import HomeSection from './HomeSection';
|
import PageSection from './PageSection';
|
||||||
|
|
||||||
describe('HomeSection', () => {
|
describe('PageSection', () => {
|
||||||
it('is a region named by its heading', async () => {
|
it('is a region named by its heading', async () => {
|
||||||
const { container } = await renderWithProviders(
|
const { container } = await renderWithProviders(
|
||||||
<HomeSection labelledBy="about-title" data-testid="about">
|
<PageSection labelledBy="about-title" data-testid="about">
|
||||||
<h2 id="about-title">Over mij</h2>
|
<h2 id="about-title">Over mij</h2>
|
||||||
</HomeSection>,
|
</PageSection>,
|
||||||
);
|
);
|
||||||
expect(screen.getByRole('region', { name: 'Over mij' })).toBe(
|
expect(screen.getByRole('region', { name: 'Over mij' })).toBe(
|
||||||
screen.getByTestId('about'),
|
screen.getByTestId('about'),
|
||||||
@@ -19,7 +19,7 @@ describe('HomeSection', () => {
|
|||||||
|
|
||||||
it('passes the anchor id through for every tone, width and spacing', async () => {
|
it('passes the anchor id through for every tone, width and spacing', async () => {
|
||||||
await renderWithProviders(
|
await renderWithProviders(
|
||||||
<HomeSection
|
<PageSection
|
||||||
labelledBy="contact-title"
|
labelledBy="contact-title"
|
||||||
id="contact"
|
id="contact"
|
||||||
tone="alt"
|
tone="alt"
|
||||||
@@ -27,7 +27,7 @@ describe('HomeSection', () => {
|
|||||||
spacing="tight"
|
spacing="tight"
|
||||||
>
|
>
|
||||||
<h2 id="contact-title">Contact</h2>
|
<h2 id="contact-title">Contact</h2>
|
||||||
</HomeSection>,
|
</PageSection>,
|
||||||
);
|
);
|
||||||
expect(screen.getByRole('region', { name: 'Contact' })).toHaveAttribute(
|
expect(screen.getByRole('region', { name: 'Contact' })).toHaveAttribute(
|
||||||
'id',
|
'id',
|
||||||
@@ -35,13 +35,35 @@ describe('HomeSection', () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('has no space above when it sits flush below a page head', async () => {
|
||||||
|
await renderWithProviders(
|
||||||
|
<>
|
||||||
|
<PageSection labelledBy="flush-title" data-testid="flush">
|
||||||
|
<h2 id="flush-title">Hoi!</h2>
|
||||||
|
</PageSection>
|
||||||
|
<PageSection
|
||||||
|
labelledBy="next-title"
|
||||||
|
spacing="flushTop"
|
||||||
|
data-testid="flush-top"
|
||||||
|
>
|
||||||
|
<h2 id="next-title">Verder</h2>
|
||||||
|
</PageSection>
|
||||||
|
</>,
|
||||||
|
);
|
||||||
|
const regular = getComputedStyle(screen.getByTestId('flush'));
|
||||||
|
const flush = getComputedStyle(screen.getByTestId('flush-top'));
|
||||||
|
expect(flush.paddingTop).toBe('0px');
|
||||||
|
expect(flush.paddingBottom).toBe(regular.paddingBottom);
|
||||||
|
expect(regular.paddingTop).not.toBe('0px');
|
||||||
|
});
|
||||||
|
|
||||||
it('leaves out the content column at full width', async () => {
|
it('leaves out the content column at full width', async () => {
|
||||||
await renderWithProviders(
|
await renderWithProviders(
|
||||||
<HomeSection labelledBy="insta-title" width="full">
|
<PageSection labelledBy="insta-title" width="full">
|
||||||
<h2 id="insta-title" data-testid="child">
|
<h2 id="insta-title" data-testid="child">
|
||||||
Instagram
|
Instagram
|
||||||
</h2>
|
</h2>
|
||||||
</HomeSection>,
|
</PageSection>,
|
||||||
);
|
);
|
||||||
// The heading is a direct child of the section, not of a Container
|
// The heading is a direct child of the section, not of a Container
|
||||||
expect(screen.getByTestId('child').parentElement).toBe(
|
expect(screen.getByTestId('child').parentElement).toBe(
|
||||||
+12
-7
@@ -1,7 +1,7 @@
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { Box, Container } from '@chakra-ui/react';
|
import { Box, Container } from '@chakra-ui/react';
|
||||||
|
|
||||||
type HomeSectionProps = {
|
type PageSectionProps = {
|
||||||
// Id of the heading that names this section for assistive technology
|
// Id of the heading that names this section for assistive technology
|
||||||
labelledBy: string;
|
labelledBy: string;
|
||||||
id?: string;
|
id?: string;
|
||||||
@@ -9,14 +9,16 @@ type HomeSectionProps = {
|
|||||||
// full: no content column, for edge-to-edge content; the section then
|
// full: no content column, for edge-to-edge content; the section then
|
||||||
// places its own Container around what should stay in the column
|
// places its own Container around what should stay in the column
|
||||||
width?: 'default' | 'narrow' | 'full';
|
width?: 'default' | 'narrow' | 'full';
|
||||||
spacing?: 'default' | 'tight';
|
// flushTop: no space above, for the first block right below a page head
|
||||||
|
// (design .section--flush-top)
|
||||||
|
spacing?: 'default' | 'tight' | 'flushTop';
|
||||||
'data-testid'?: string;
|
'data-testid'?: string;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Frame of a homepage section (design .section): vertical rhythm, an
|
// Frame of a content section on any page (design .section): vertical
|
||||||
// optional alternate background and the content column.
|
// rhythm, an optional alternate background and the content column.
|
||||||
export default function HomeSection({
|
export default function PageSection({
|
||||||
labelledBy,
|
labelledBy,
|
||||||
id,
|
id,
|
||||||
tone = 'paper',
|
tone = 'paper',
|
||||||
@@ -24,7 +26,9 @@ export default function HomeSection({
|
|||||||
spacing = 'default',
|
spacing = 'default',
|
||||||
'data-testid': testId,
|
'data-testid': testId,
|
||||||
children,
|
children,
|
||||||
}: HomeSectionProps) {
|
}: PageSectionProps) {
|
||||||
|
const padding = spacing === 'tight' ? 'sectionYTight' : 'sectionY';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
as="section"
|
as="section"
|
||||||
@@ -35,7 +39,8 @@ export default function HomeSection({
|
|||||||
// An anchor target (#contact) lands right below the fixed header,
|
// An anchor target (#contact) lands right below the fixed header,
|
||||||
// which has shrunk to its sticky height by the time it gets there
|
// which has shrunk to its sticky height by the time it gets there
|
||||||
scrollMarginTop={id ? 'header.sticky' : undefined}
|
scrollMarginTop={id ? 'header.sticky' : undefined}
|
||||||
py={spacing === 'tight' ? 'sectionYTight' : 'sectionY'}
|
pt={spacing === 'flushTop' ? 0 : padding}
|
||||||
|
pb={padding}
|
||||||
>
|
>
|
||||||
{width === 'full' ? (
|
{width === 'full' ? (
|
||||||
children
|
children
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { Box, Heading, Text } from '@chakra-ui/react';
|
import { Box, Heading, Text } from '@chakra-ui/react';
|
||||||
|
import Eyebrow from '@/components/Eyebrow/Eyebrow';
|
||||||
|
|
||||||
type SectionHeadingProps = {
|
type SectionHeadingProps = {
|
||||||
// Referenced by the section's aria-labelledby
|
// Referenced by the section's aria-labelledby
|
||||||
@@ -35,12 +36,7 @@ export default function SectionHeading({
|
|||||||
mb={spacing === 'compact' ? 6 : 'sectionHeadGap'}
|
mb={spacing === 'compact' ? 6 : 'sectionHeadGap'}
|
||||||
textAlign={centered ? 'center' : 'start'}
|
textAlign={centered ? 'center' : 'start'}
|
||||||
>
|
>
|
||||||
{eyebrow && (
|
{eyebrow && <Eyebrow>{eyebrow}</Eyebrow>}
|
||||||
// accent.deep instead of the design's accent: meets 4.5:1 (NFR-HP-01)
|
|
||||||
<Text textStyle="eyebrow" color="accent.deep" mb={4}>
|
|
||||||
{eyebrow}
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
<Heading
|
<Heading
|
||||||
as="h2"
|
as="h2"
|
||||||
id={id}
|
id={id}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { Grid, Link, Stack, Text } from '@chakra-ui/react';
|
import { Link, Stack, Text } from '@chakra-ui/react';
|
||||||
import FramedImage from '@/components/FramedImage/FramedImage';
|
import MediaText from '@/components/MediaText/MediaText';
|
||||||
import HomeSection from '@/components/HomeSection/HomeSection';
|
import PageSection from '@/components/PageSection/PageSection';
|
||||||
import Reveal from '@/components/Reveal/Reveal';
|
|
||||||
import RouterLink from '@/components/RouterLink';
|
import RouterLink from '@/components/RouterLink';
|
||||||
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
||||||
import type { HomeContent } from '@/content/types';
|
import type { HomeContent } from '@/content/types';
|
||||||
@@ -16,40 +15,31 @@ type AboutBlockProps = {
|
|||||||
// link to the about page (design .about). Stacked on phones and tablets.
|
// link to the about page (design .about). Stacked on phones and tablets.
|
||||||
export default function AboutBlock({ content }: AboutBlockProps) {
|
export default function AboutBlock({ content }: AboutBlockProps) {
|
||||||
return (
|
return (
|
||||||
<HomeSection labelledBy={TITLE_ID} tone="alt" data-testid="about-block">
|
<PageSection labelledBy={TITLE_ID} tone="alt" data-testid="about-block">
|
||||||
<Grid
|
<MediaText image={content.image} aspectRatio="4 / 3">
|
||||||
templateColumns={{ base: '1fr', lg: '1fr 1fr' }}
|
<SectionHeading
|
||||||
gap="clamp(2rem, 6vw, 5.5rem)"
|
id={TITLE_ID}
|
||||||
alignItems="center"
|
eyebrow={content.eyebrow}
|
||||||
>
|
title={content.title}
|
||||||
<Reveal>
|
align="start"
|
||||||
<FramedImage image={content.image} aspectRatio="4 / 3" />
|
spacing="compact"
|
||||||
</Reveal>
|
/>
|
||||||
<Reveal>
|
<Stack gap={4} color="ink.soft">
|
||||||
<SectionHeading
|
{content.paragraphs.map((paragraph) => (
|
||||||
id={TITLE_ID}
|
<Text key={paragraph}>{paragraph}</Text>
|
||||||
eyebrow={content.eyebrow}
|
))}
|
||||||
title={content.title}
|
<Text>
|
||||||
align="start"
|
<Link variant="underline" asChild>
|
||||||
spacing="compact"
|
<RouterLink
|
||||||
/>
|
to={content.link.to}
|
||||||
<Stack gap={4} color="ink.soft">
|
data-testid="about-block-link"
|
||||||
{content.paragraphs.map((paragraph) => (
|
>
|
||||||
<Text key={paragraph}>{paragraph}</Text>
|
{content.link.label}
|
||||||
))}
|
</RouterLink>
|
||||||
<Text>
|
</Link>
|
||||||
<Link variant="underline" asChild>
|
</Text>
|
||||||
<RouterLink
|
</Stack>
|
||||||
to={content.link.to}
|
</MediaText>
|
||||||
data-testid="about-block-link"
|
</PageSection>
|
||||||
>
|
|
||||||
{content.link.label}
|
|
||||||
</RouterLink>
|
|
||||||
</Link>
|
|
||||||
</Text>
|
|
||||||
</Stack>
|
|
||||||
</Reveal>
|
|
||||||
</Grid>
|
|
||||||
</HomeSection>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { Box, useMediaQuery } from '@chakra-ui/react';
|
|||||||
import { useNavigate } from '@tanstack/react-router';
|
import { useNavigate } from '@tanstack/react-router';
|
||||||
import { DEFERRED_LOAD_MARGIN } from '@/components/DeferredImage/DeferredImage';
|
import { DEFERRED_LOAD_MARGIN } from '@/components/DeferredImage/DeferredImage';
|
||||||
import ContactFormGate from '@/components/ContactForm/ContactFormGate';
|
import ContactFormGate from '@/components/ContactForm/ContactFormGate';
|
||||||
import HomeSection from '@/components/HomeSection/HomeSection';
|
import PageSection from '@/components/PageSection/PageSection';
|
||||||
import Reveal from '@/components/Reveal/Reveal';
|
import Reveal from '@/components/Reveal/Reveal';
|
||||||
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
||||||
import type {
|
import type {
|
||||||
@@ -109,7 +109,7 @@ export default function ContactSection({
|
|||||||
const placeholder = <Box minH={FORM_PLACEHOLDER_HEIGHT} />;
|
const placeholder = <Box minH={FORM_PLACEHOLDER_HEIGHT} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HomeSection
|
<PageSection
|
||||||
labelledBy={TITLE_ID}
|
labelledBy={TITLE_ID}
|
||||||
id="contact"
|
id="contact"
|
||||||
width="narrow"
|
width="narrow"
|
||||||
@@ -146,6 +146,6 @@ export default function ContactSection({
|
|||||||
</Box>
|
</Box>
|
||||||
</ContactFormGate>
|
</ContactFormGate>
|
||||||
</Reveal>
|
</Reveal>
|
||||||
</HomeSection>
|
</PageSection>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Box, chakra, Container, Link, VisuallyHidden } from '@chakra-ui/react';
|
import { Box, chakra, Container, Link, VisuallyHidden } from '@chakra-ui/react';
|
||||||
import DeferredImage from '@/components/DeferredImage/DeferredImage';
|
import DeferredImage from '@/components/DeferredImage/DeferredImage';
|
||||||
import HomeSection from '@/components/HomeSection/HomeSection';
|
import PageSection from '@/components/PageSection/PageSection';
|
||||||
import Reveal from '@/components/Reveal/Reveal';
|
import Reveal from '@/components/Reveal/Reveal';
|
||||||
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
||||||
import type { HomeContent } from '@/content/types';
|
import type { HomeContent } from '@/content/types';
|
||||||
@@ -22,7 +22,7 @@ export default function InstagramGrid({
|
|||||||
profileUrl,
|
profileUrl,
|
||||||
}: InstagramGridProps) {
|
}: InstagramGridProps) {
|
||||||
return (
|
return (
|
||||||
<HomeSection
|
<PageSection
|
||||||
labelledBy={TITLE_ID}
|
labelledBy={TITLE_ID}
|
||||||
spacing="tight"
|
spacing="tight"
|
||||||
width="full"
|
width="full"
|
||||||
@@ -112,6 +112,6 @@ export default function InstagramGrid({
|
|||||||
))}
|
))}
|
||||||
</chakra.ul>
|
</chakra.ul>
|
||||||
</Reveal>
|
</Reveal>
|
||||||
</HomeSection>
|
</PageSection>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { chakra, useBreakpointValue } from '@chakra-ui/react';
|
|||||||
import DeferredImage, {
|
import DeferredImage, {
|
||||||
DEFERRED_LOAD_MARGIN,
|
DEFERRED_LOAD_MARGIN,
|
||||||
} from '@/components/DeferredImage/DeferredImage';
|
} from '@/components/DeferredImage/DeferredImage';
|
||||||
import HomeSection from '@/components/HomeSection/HomeSection';
|
import PageSection from '@/components/PageSection/PageSection';
|
||||||
import Reveal from '@/components/Reveal/Reveal';
|
import Reveal from '@/components/Reveal/Reveal';
|
||||||
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
||||||
import type { HomeContent } from '@/content/types';
|
import type { HomeContent } from '@/content/types';
|
||||||
@@ -33,7 +33,7 @@ export default function IntroGallery({ content }: IntroGalleryProps) {
|
|||||||
const scrollable = useBreakpointValue({ base: true, sm: false }) ?? false;
|
const scrollable = useBreakpointValue({ base: true, sm: false }) ?? false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HomeSection labelledBy={TITLE_ID} data-testid="intro-gallery">
|
<PageSection labelledBy={TITLE_ID} data-testid="intro-gallery">
|
||||||
<Reveal>
|
<Reveal>
|
||||||
<SectionHeading
|
<SectionHeading
|
||||||
id={TITLE_ID}
|
id={TITLE_ID}
|
||||||
@@ -99,6 +99,6 @@ export default function IntroGallery({ content }: IntroGalleryProps) {
|
|||||||
))}
|
))}
|
||||||
</chakra.ul>
|
</chakra.ul>
|
||||||
</Reveal>
|
</Reveal>
|
||||||
</HomeSection>
|
</PageSection>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Box, Grid } from '@chakra-ui/react';
|
import { Box, Grid } from '@chakra-ui/react';
|
||||||
import DeferredImage from '@/components/DeferredImage/DeferredImage';
|
import DeferredImage from '@/components/DeferredImage/DeferredImage';
|
||||||
import HomeSection from '@/components/HomeSection/HomeSection';
|
import PageSection from '@/components/PageSection/PageSection';
|
||||||
import Reveal from '@/components/Reveal/Reveal';
|
import Reveal from '@/components/Reveal/Reveal';
|
||||||
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
||||||
import type { HomeContent, PricingPackage } from '@/content/types';
|
import type { HomeContent, PricingPackage } from '@/content/types';
|
||||||
@@ -32,7 +32,7 @@ export default function Pricing({ content, packages }: PricingProps) {
|
|||||||
if (shown.length === 0) return null;
|
if (shown.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HomeSection labelledBy={TITLE_ID} data-testid="pricing">
|
<PageSection labelledBy={TITLE_ID} data-testid="pricing">
|
||||||
<Box position="relative" isolation="isolate">
|
<Box position="relative" isolation="isolate">
|
||||||
{content.decorations.map((decoration, index) => (
|
{content.decorations.map((decoration, index) => (
|
||||||
<DeferredImage
|
<DeferredImage
|
||||||
@@ -68,6 +68,6 @@ export default function Pricing({ content, packages }: PricingProps) {
|
|||||||
))}
|
))}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Box>
|
</Box>
|
||||||
</HomeSection>
|
</PageSection>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Box, chakra, Grid, Text } from '@chakra-ui/react';
|
import { Box, chakra, Grid, Text } from '@chakra-ui/react';
|
||||||
|
import Eyebrow from '@/components/Eyebrow/Eyebrow';
|
||||||
import FramedImage from '@/components/FramedImage/FramedImage';
|
import FramedImage from '@/components/FramedImage/FramedImage';
|
||||||
import type { Testimonial } from '@/content/types';
|
import type { Testimonial } from '@/content/types';
|
||||||
|
|
||||||
@@ -44,10 +45,7 @@ export default function TestimonialSlide({
|
|||||||
>
|
>
|
||||||
“
|
“
|
||||||
</Text>
|
</Text>
|
||||||
{/* accent.deep instead of the design's accent: meets 4.5:1 (NFR-HP-01) */}
|
<Eyebrow>{testimonial.shoot}</Eyebrow>
|
||||||
<Text textStyle="eyebrow" color="accent.deep" mb={4}>
|
|
||||||
{testimonial.shoot}
|
|
||||||
</Text>
|
|
||||||
{/* Plain elements, not Chakra's Blockquote: its slot recipe
|
{/* Plain elements, not Chakra's Blockquote: its slot recipe
|
||||||
would pull shared code into the chunk the hero waits for */}
|
would pull shared code into the chunk the hero waits for */}
|
||||||
<chakra.figure display="flex" flexDirection="column" gap={7}>
|
<chakra.figure display="flex" flexDirection="column" gap={7}>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { lazy, Suspense } from 'react';
|
import { lazy, Suspense } from 'react';
|
||||||
import { Box } from '@chakra-ui/react';
|
import { Box } from '@chakra-ui/react';
|
||||||
import { DEFERRED_LOAD_MARGIN } from '@/components/DeferredImage/DeferredImage';
|
import { DEFERRED_LOAD_MARGIN } from '@/components/DeferredImage/DeferredImage';
|
||||||
import HomeSection from '@/components/HomeSection/HomeSection';
|
import PageSection from '@/components/PageSection/PageSection';
|
||||||
import Reveal from '@/components/Reveal/Reveal';
|
import Reveal from '@/components/Reveal/Reveal';
|
||||||
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
import SectionHeading from '@/components/SectionHeading/SectionHeading';
|
||||||
import type { HomeContent, Testimonial } from '@/content/types';
|
import type { HomeContent, Testimonial } from '@/content/types';
|
||||||
@@ -36,7 +36,7 @@ export default function Testimonials({
|
|||||||
if (shown.length === 0) return null;
|
if (shown.length === 0) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HomeSection
|
<PageSection
|
||||||
labelledBy={TITLE_ID}
|
labelledBy={TITLE_ID}
|
||||||
tone="alt"
|
tone="alt"
|
||||||
data-testid="testimonials"
|
data-testid="testimonials"
|
||||||
@@ -63,7 +63,7 @@ export default function Testimonials({
|
|||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Reveal>
|
</Reveal>
|
||||||
</HomeSection>
|
</PageSection>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user