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.4 KiB
Code Summary — Unit 5: Contact
Plan: contact-code-generation-plan.md. Functional design: ../functional-design/. Branch: feature/homepage-sections.
Files
Created
| File | Purpose |
|---|---|
web/src/contact/types.ts |
Values, errors, payload, shoot option, limits, empty values |
web/src/contact/submitContactForm.ts + test |
The single submission adapter; fails until the API exists (comment shows the future POST /api/contact) |
web/src/lib/shootOptions.ts + test |
Shown packages + Overig |
web/src/lib/validateContact.ts + test |
validateField / validateContact with the agreed messages |
web/src/lib/toContactPayload.ts + test |
Trimmed payload |
web/src/lib/isLikelySpam.ts + test |
Honeypot or under 3000 ms |
web/src/lib/mailLink.ts + test |
mailSubject, mailtoLink |
web/src/lib/contactFormReducer.ts + test |
The form as a pure state machine (editing → sending → sent / failed) |
web/src/recipes/formControl.ts |
The design's square fields for Input, Textarea and NativeSelect |
web/src/components/ContactForm/ContactForm.tsx + test |
The form (lazy chunk) |
web/src/components/ContactForm/ContactFormGate.tsx + test |
Dimmed, inert form under the coming-soon notice |
web/src/components/home/ContactSection/ContactSection.tsx + test |
The section: heading, gate, lazy form, ?pakket= handling, focus |
Modified
| File | Change |
|---|---|
web/src/content/types.ts, homeContent.ts, siteContent.ts |
HomeContent.contact; SiteContent.contactForm = { enabled: false } |
web/src/theme.ts |
error colour (#a4443a: 5.7:1 on paper, 6.1:1 on white), panel shadow, formControl recipe |
web/src/components/SectionHeading/SectionHeading.tsx |
focusable (tabIndex −1 for the programmatic focus) |
web/src/components/home/Pricing/PriceCard.tsx |
Feature list as plain ul/li instead of Chakra List (see performance) |
web/src/components/home/Testimonials/TestimonialSlide.tsx |
Plain figure/blockquote/figcaption instead of Chakra Blockquote (see performance) |
web/src/routes/index.tsx |
Renders ContactSection with pakket from Route.useSearch() |
web/src/test/arbitraries.ts |
contactValues, anyContactValues, contactEvent |
web/src/test/setup.ts |
No-op Element.scrollIntoView (the router's hash scroll; jsdom lacks it) |
web/src/app.test.tsx |
"Contact" in the page order; full "Boek Newborn" path through the real route |
Findings and fixes during generation
-
Labels not linked (found by a test): Chakra's
Field.Rootlinks the label to the control through its own id; overriding the control'sidbroke that. In Ark,Field.Root'sidis the control's id (andids.controlis, confusingly, the root group's id), so the id now goes onField.Root. Ark links the error text witharia-errormessage(notaria-describedbyas written in the functional design);aria-invalidis set. -
Field refs vs the React compiler lint: refs set from a helper called during render were rejected; focus now finds the first invalid field by its id.
-
Form disappearing after a "Boek" arrival: with the form loaded because of
?pakket=, removing the parameter made it unload until the observer fired, losing typed input. Once loaded the form now stays (asserted in the app test). -
Coverage: two reducer branches were only reached randomly by the stateful property test; fixed with deterministic example tests (100% on
src/lib/**). -
Performance (5-run Lighthouse medians, unit 4 rebuilt alongside for the same conditions):
Build Median LCP TBT Unit 4 0.83 3.84 s 177 ms Unit 5, form in the route chunk 0.80 3.99 s 232 ms Unit 5, form lazy 0.81 3.99 s 207 ms Unit 5, form lazy, no slot recipes in the route chunk 0.83 3.84 s 175 ms First the form was moved into its own chunk, loaded when the section comes within 200 px of the screen, or at once when arriving via "Boek …". The remaining gap came from a new shared chunk (Chakra's slot-recipe factory, now used by three chunks) that the route had to fetch on page load: the price cards'
Listand the review slide'sBlockquotewere the only slot-recipe components on the route, so they became plain elements with the same styling, and the route no longer needs that chunk. -
Placeholder while the form loads: measured 604 px on phones, 502 px from
sm.
Verification (pnpm check)
- Lint ✅, Prettier ✅, build ✅ (
ContactFormin its own chunk, ±5.7 KB gzipped) - Tests: 52 files, 237 passed; 100% coverage on
src/lib/** - Lighthouse home: mobile 0.83, desktop 1.0; accessibility, best practices, SEO 1.0
- Visual check: 1440 and 390 with the overlay; 1440 with the form switched on locally (reverted before the build that was checked)
Extension compliance
- Security Baseline: client-side limits and format (SECURITY-05, server side in the API feature); misuse: gate + honeypot + time check (SECURITY-11); generic failure text (SECURITY-15); the e-mail address is assembled in the browser; no new dependencies or external resources; CSP unchanged.
- PBT: PBT-02 (mailto round-trip), PBT-03 (validation invariants), PBT-04 (payload idempotency), PBT-05 (spam and e-mail oracles), PBT-06 (stateful reducer test over random event sequences), PBT-07 (generators), PBT-08/09 (existing seed setup), PBT-10 (example tests).