Adds the contact form with the live fields, validation and browser-side anti-spam, behind a coming-soon notice with a mail button until the API exists. A "Boek" link on a price card selects its package, tidies the URL and moves focus to the form. The form loads only when it comes near the screen, so the hero does not wait for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5.3 KiB
5.3 KiB
Frontend Components — Unit 5: Contact
Hierarchy
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
pakketwithpackageFromSearch; passes the selected id to the form (preselect) and the package name to the mail subject; removespakketfrom the URL (routernavigate({ search: {}, hash: 'contact', replace: true, resetScroll: false })); moves focus to the heading whenpakketwas present (BR-PARAM-02, BR-FOCUS-01). - Layout:
HomeSectionid="contact",width="narrow", plain background, centredSectionHeading"Contact" with lead; the heading hastabIndex={-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 accentLinkButton-style anchor "Stuur een e-mail" (mailtoLink). White panel, hairline border,shadowfrom 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<void> }(keychanges per "Boek" click so the same package can be applied again) - State:
useReducer(contactFormReducer);shownAtrecorded when the form becomes usable. - Fields: Chakra
Field.Root+Field.Label+ control +Field.ErrorText(invalidfrom state); square inputs in the design style (theme),autocompletename/email,maxLengthper 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
divwithdata-robot-check(FR-HP-09). - Submit button: accent
linkButtonstyle on abutton, "(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.softfor contrast). - Test ids:
contact-form,contact-form-<field>,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.mutedon paper); the dimmed form is decorative while inert. - Axe clean in both gate states; Lighthouse accessibility stays 1.0.