Adds the inception docs and design for the homepage sections
Refreshes the shared reverse engineering docs, adds the requirements, application design and units for the homepage-sections feature, and updates the static design: live prices and form fields, the new Lieve woorden block and the coming-soon gate over the contact form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+115
@@ -0,0 +1,115 @@
|
||||
# Component Methods — homepage-sections
|
||||
|
||||
Signatures and data shapes. Detailed rules (validation messages, limits, carousel behaviour, spam thresholds) follow in Functional Design per unit.
|
||||
|
||||
## Content types (`content/types.ts`, additions)
|
||||
|
||||
```ts
|
||||
// An image as the API will deliver it; src is a URL (bundled asset today)
|
||||
interface ContentImage {
|
||||
src: string;
|
||||
alt: string;
|
||||
width: number;
|
||||
height: number;
|
||||
}
|
||||
|
||||
interface PricingPackage {
|
||||
id: string; // stable slug, e.g. 'newborn'; used in ?pakket= and as the shoot value
|
||||
name: string; // 'Newborn'
|
||||
price: number; // whole euros, e.g. 185
|
||||
features: string[]; // '1-2 uur fotografie', ...
|
||||
}
|
||||
|
||||
interface Testimonial {
|
||||
id: string;
|
||||
shoot: string; // label, e.g. 'Newbornshoot'
|
||||
quote: string;
|
||||
author: string; // 'Demi & Kevin'
|
||||
image: ContentImage;
|
||||
}
|
||||
|
||||
interface HomeContent {
|
||||
intro: { title: string; lead: string; photos: ContentImage[] };
|
||||
about: {
|
||||
eyebrow: string;
|
||||
title: string;
|
||||
paragraphs: string[];
|
||||
image: ContentImage;
|
||||
link: { label: string; to: RoutePath };
|
||||
};
|
||||
pricing: { title: string; lead: string };
|
||||
testimonials: { title: string };
|
||||
contact: { title: string; lead: string };
|
||||
instagram: { title: string; handle: string; photos: ContentImage[] };
|
||||
}
|
||||
|
||||
// SiteContent gains:
|
||||
interface SiteContent {
|
||||
// ...existing fields
|
||||
contactForm: { enabled: boolean };
|
||||
}
|
||||
```
|
||||
|
||||
Content modules (design Q2 = A): `content/packages.ts` → `PricingPackage[]`, `content/testimonials.ts` → `Testimonial[]`, `content/homeContent.ts` → `HomeContent`.
|
||||
|
||||
## Contact types (`contact/types.ts`)
|
||||
|
||||
```ts
|
||||
interface ContactValues { // what the visitor typed
|
||||
naam: string;
|
||||
email: string;
|
||||
shoot: string; // '' | a package id | 'overig'
|
||||
bericht: string;
|
||||
}
|
||||
|
||||
type ContactField = keyof ContactValues;
|
||||
type ContactErrors = Partial<Record<ContactField, string>>;
|
||||
|
||||
interface ContactPayload { // what goes to POST /api/contact
|
||||
naam: string;
|
||||
email: string;
|
||||
shoot: string;
|
||||
bericht: string;
|
||||
}
|
||||
|
||||
interface ShootOption { value: string; label: string }
|
||||
```
|
||||
|
||||
## Components (props)
|
||||
|
||||
| Component | Props |
|
||||
|---|---|
|
||||
| `HomeSection` | `{ labelledBy: string; id?: string; tone?: 'paper' \| 'alt'; width?: 'default' \| 'narrow'; spacing?: 'default' \| 'tight'; children: ReactNode }` |
|
||||
| `SectionHeading` | `{ id: string; title: string; eyebrow?: string; lead?: string; align?: 'center' \| 'start' }` |
|
||||
| `Reveal` | `{ children: ReactNode; delay?: number }` |
|
||||
| `FramedImage` | `{ image: ContentImage; aspectRatio: string }` |
|
||||
| `IntroGallery` | `{ content: HomeContent['intro'] }` |
|
||||
| `AboutBlock` | `{ content: HomeContent['about'] }` |
|
||||
| `Pricing` | `{ content: HomeContent['pricing']; packages: PricingPackage[] }` |
|
||||
| `PriceCard` | `{ pkg: PricingPackage }` |
|
||||
| `Testimonials` | `{ content: HomeContent['testimonials']; testimonials: Testimonial[] }` |
|
||||
| `ContactSection` | `{ content: HomeContent['contact']; packages: PricingPackage[]; enabled: boolean; email: EmailAddress; preselected?: string }` |
|
||||
| `ContactFormGate` | `{ enabled: boolean; email: EmailAddress; children: ReactNode }` |
|
||||
| `ContactForm` | `{ idPrefix: string; options: ShootOption[]; initialShoot?: string; submit?: (payload: ContactPayload) => Promise<void> }` (`submit` defaults to `submitContactForm`; injectable for tests) |
|
||||
| `InstagramGrid` | `{ content: HomeContent['instagram']; profileUrl: string }` |
|
||||
|
||||
## Hooks
|
||||
|
||||
- `useReveal<T extends Element>(): { ref: RefObject<T>; visible: boolean }` — `visible` starts `true` when reduced motion is on or IntersectionObserver is missing; otherwise flips to `true` once and stops observing.
|
||||
|
||||
## Pure helpers (`lib/`, 100% coverage, property-based tests)
|
||||
|
||||
| Function | Purpose |
|
||||
|---|---|
|
||||
| `formatPrice(euros: number): string` | `185` → `'€ 185'` (nl-NL, no decimals) |
|
||||
| `shootOptions(packages: PricingPackage[]): ShootOption[]` | package names in order + `{ value: 'overig', label: 'Overig' }` |
|
||||
| `packageFromSearch(value: unknown, packages: PricingPackage[]): string \| undefined` | returns the id only if it matches a package |
|
||||
| `validateContact(values: ContactValues, options: ShootOption[]): ContactErrors` | required fields, e-mail format, max lengths, shoot must be a known option |
|
||||
| `toContactPayload(values: ContactValues): ContactPayload` | trims fields |
|
||||
| `isLikelySpam(input: { honeypot: string; shownAt: number; now: number }): boolean` | honeypot filled or submitted too fast |
|
||||
| `slideLabel(index: number, count: number): string` | `'Review 2 van 3'` for the live region and slide `aria-label` |
|
||||
|
||||
## Services / adapters
|
||||
|
||||
- `submitContactForm(payload: ContactPayload): Promise<void>` (`contact/submitContactForm.ts`) — today rejects with a generic error (no back-end); later `POST /api/contact`.
|
||||
- Route search: `validateSearch: (search) => ({ pakket: typeof search.pakket === 'string' ? search.pakket : undefined })` on `/`; the page then resolves it with `packageFromSearch`.
|
||||
Reference in New Issue
Block a user