# Frontend Components — Unit 5: Contact ## Hierarchy ```mermaid graph TD Route["routes/index.tsx"] --> Section["home/ContactSection"] Section --> Home["HomeSection id contact, narrow"] Section --> Heading["SectionHeading, focus target"] Section --> Gate["ContactForm/ContactFormGate"] Gate --> Form["ContactForm/ContactForm"] Gate --> Notice["Coming-soon notice with mail button"] Form --> Fields["Chakra Field: Input, NativeSelect, Textarea"] Form --> Honeypot["Honeypot field"] Form --> Slot["Robot-check slot, empty"] Form --> Status["Sending, failure and thank-you"] Logic["lib: reducer, validation, spam, mail link"] -.-> Form Logic -.-> Gate Adapter["contact/submitContactForm"] -.-> Form classDef root fill:#4CAF50,stroke:#2e7d32,stroke-width:1px,color:#000; classDef ui fill:#2196F3,stroke:#0d47a1,stroke-width:1px,color:#000; classDef logic fill:#9C27B0,stroke:#4a148c,stroke-width:1px,color:#000; classDef ext fill:#F44336,stroke:#b71c1c,stroke-width:1px,color:#000; class Route root; class Section,Home,Heading,Gate,Form,Notice,Fields,Honeypot,Slot,Status ui; class Logic logic; class Adapter ext; ``` Text alternative: the home route renders ContactSection (HomeSection with id contact, the heading as focus target, and the gate); the gate wraps the form and the coming-soon notice; the form has Chakra fields, a honeypot, an empty robot-check slot and status messages; pure helpers and the submit adapter support it. ## ContactSection (`components/home/ContactSection`) - **Props**: `{ content: HomeContent['contact']; packages: PricingPackage[]; enabled: boolean; email: EmailAddress; pakket?: string }` - **Behaviour**: resolves `pakket` with `packageFromSearch`; passes the selected id to the form (`preselect`) and the package name to the mail subject; removes `pakket` from the URL (router `navigate({ search: {}, hash: 'contact', replace: true, resetScroll: false })`); moves focus to the heading when `pakket` was present (BR-PARAM-02, BR-FOCUS-01). - **Layout**: `HomeSection` `id="contact"`, `width="narrow"`, plain background, centred `SectionHeading` "Contact" with lead; the heading has `tabIndex={-1}` for the programmatic focus (no visible ring, theme rule `[tabindex="-1"]:focus`). ## ContactFormGate (`components/ContactForm/ContactFormGate`) - **Props**: `{ enabled: boolean; email: EmailAddress; subject: string; children }` - **Off**: wraps children in a dimmed (`opacity 0.35`, slight blur), `inert`, non-selectable box; renders the notice centred over it: eyebrow "Binnenkort", the text with the address as an underline link, and an accent `LinkButton`-style anchor "Stuur een e-mail" (`mailtoLink`). White panel, hairline border, `shadow` from the design (a theme token). Invalid address → text only. - **On**: renders children only. ## ContactForm (`components/ContactForm/ContactForm`) - **Props**: `{ idPrefix: string; options: ShootOption[]; preselect?: { shoot: string; key: number }; mailSubject: string; email: EmailAddress; submit?: (payload) => Promise }` (`key` changes per "Boek" click so the same package can be applied again) - **State**: `useReducer(contactFormReducer)`; `shownAt` recorded when the form becomes usable. - **Fields**: Chakra `Field.Root` + `Field.Label` + control + `Field.ErrorText` (`invalid` from state); square inputs in the design style (theme), `autocomplete` name/email, `maxLength` per limit; the select has the placeholder "Kies een optie..." and the shoot options; the textarea min height 170 px with placeholder "Vul hier je bericht in". - **Honeypot**: label "Website" + input `name="website"`, off-screen, `aria-hidden`, `tabIndex={-1}`, `autoComplete="off"`. - **Robot-check slot**: an empty `div` with `data-robot-check` (FR-HP-09). - **Submit button**: accent `linkButton` style on a `button`, "(Aan)vraag versturen" / "Versturen…" while sending, disabled while sending. - **Failure**: a status box above the button (`role="alert"`) with the mail link. - **Sent**: the form is replaced by the thank-you (`role="status"`, `tabIndex={-1}`, focused). - **Layout**: name and e-mail side by side from `sm`, the rest full width; labels in the eyebrow style (`ink.soft` for contrast). - **Test ids**: `contact-form`, `contact-form-`, `contact-form-submit`, `contact-form-status`, `contact-form-sent`, `contact-gate-notice`, `contact-gate-mail`. ## Loading The form is a lazy chunk, loaded when the section comes within 200 px of the screen or at once when arriving via "Boek …", and it stays once loaded; the heading and the gate's notice render immediately over a placeholder of the form's height (unit 5 code summary, performance). ## Content - `HomeContent.contact = { title: 'Contact', lead: 'Wil je meer informatie ontvangen? Neem gerust contact met mij op.' }` - `siteContent.contactForm = { enabled: false }` ## Accessibility (NFR-HP-01) - Labels visible and linked; errors via `aria-errormessage`/`aria-invalid` (Ark's Field) and announced; focus to the first invalid field on submit; thank-you focused; failure announced (`role="alert"`). - With the gate on, the inert form is skipped by keyboard and screen readers; the notice and its button are reachable. - Contrast: labels and placeholder text meet 4.5:1 (no `ink.muted` on paper); the dimmed form is decorative while inert. - Axe clean in both gate states; Lighthouse accessibility stays 1.0.