Files
AndreaSlopFotografie/aidlc-docs/features/homepage-sections/construction/contact/code/code-summary.md
T
SluijsensandClaude Opus 5.5 0b00b781b9 Fixes the scroll to Contact from the price cards
Removing ?pakket= from the URL replaced the click's navigation before the
router scrolled to #contact, and told it not to scroll, so nothing
happened. The clean-up now asks the router to scroll there, below the
fixed header. The review carousel's placeholder is now the longest review
itself, so it matches the carousel's height at every width and no longer
shifts the target while the page scrolls past it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 00:59:20 +02:00

7.1 KiB
Raw Blame History

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.Root links the label to the control through its own id; overriding the control's id broke that. In Ark, Field.Root's id is the control's id (and ids.control is, confusingly, the root group's id), so the id now goes on Field.Root. Ark links the error text with aria-errormessage (not aria-describedby as written in the functional design); aria-invalid is 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' List and the review slide's Blockquote were 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.

Bugs found by the owner on LAN, fixed (2026-10-21)

  1. "Boek …" did not scroll. The click navigates to /?pakket=<id>#contact and the router scrolls to the hash in its onRendered step. Our clean-up navigation (removing ?pakket=) ran first and passed hashScrollIntoView: false, so the router's last instruction was "don't scroll". Traced in real Chrome: pushState, replaceState, no scrollIntoView. The clean-up now asks the router to scroll to #contact (smooth, or auto under reduced motion). Anchored sections get scroll-margin-top equal to the header, so the section lands below the fixed header. A new app test clicks "Boek Newborn" on the price card and asserts the scroll to #contact; it fails with the old code and passes with the fix. jsdom tests missed it because scrollIntoView is a stub there.
  2. "Boek Zwangerschap" scrolled less far than the others. Smooth scrolling fixes its target when it starts. From the top card the review carousel was not loaded yet and loaded during the scroll; its fixed-height placeholder only matched the carousel at the measured widths, so #contact moved by +29 px (360 px wide) or −44 px (600 px) mid-scroll. The placeholder is now the longest review rendered like a slide plus the control bar's height, which is as tall as the carousel at every width. Measured at 360, 390, 412, 600, 768, 1024 and 1440 px: no movement during the scroll; every button ends at the same place.
  3. CI run 555: the Lighthouse job on the Pi runner stopped with exit code −1 right after pnpm install, before any measurement (runner/infra, not a check failure); rerun with the next deploy.

Verification (pnpm check)

  • Lint ✅, Prettier ✅, build ✅ (ContactForm in its own chunk, ±5.7 KB gzipped)
  • Tests: 52 files, 238 passed (after the fixes); 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).