Files
SluijsensandClaude Opus 5.5 ad85e3fe5b Records unit 2 of the Contact page as generated
Functional design, code generation plan and summary of the shared
contact blocks, plus the coordination with the parallel features.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 18:26:48 +01:00

3.8 KiB

Business Logic Model — Unit 2: Shared contact blocks

Pure logic

New, in lib/contactChannels.ts (100% coverage threshold applies to lib/). Implements BR-CD-01..04 and the external flag of BR-CD-05, using the existing emailAddress, mailtoLink, mailSubject, visibleSocials and the platform names. ContactDetails only renders what it returns (and renders nothing for an empty list, BR-CD-06).

Reused unchanged

shootOptions, packageFromSearch, visiblePackages, mailSubject, contactFormReducer (the form's state machine).

Flows

Card

graph TD
    Content["siteContent: email, socials"] --> Fn["contactChannels()"]
    Fn --> Empty{"Empty list?"}
    Empty -->|"yes"| Nothing(["null"])
    Empty -->|"no"| Render["ContactDetails renders heading, list, one row per channel"]
    classDef data fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
    classDef logic fill:#FFA726,stroke:#E65100,stroke-width:1px,color:#000;
    classDef decision fill:#FFF59D,stroke:#F57F17,stroke-width:1px,color:#000;
    class Content data;
    class Fn,Render,Nothing logic;
    class Empty decision;

Text alternative: the site content goes through contactChannels; an empty result renders nothing, otherwise the card renders a heading and one row per channel.

Panel

graph TD
    In["packages, enabled, email, replyTime, pakket, load"] --> Opts["shootOptions(packages)"]
    In --> Pk{"New pakket value?"}
    Pk -->|"valid id"| Pre["preselect key + 1, subject with package name"]
    Pk -->|"invalid or none"| Keep["no change"]
    Opts --> Gate{"enabled?"}
    Pre --> Gate
    Keep --> Gate
    Gate -->|"no"| Notice["Gate: dimmed inert form, notice, mail button, privacy line"]
    Gate -->|"yes"| FormOnly["Form only"]
    Notice --> Load{"load"}
    FormOnly --> Load
    Load -->|"eager"| Now["Form rendered now"]
    Load -->|"lazy"| Near{"Near screen or pakket?"}
    Near -->|"no"| Placeholder["Placeholder of form height"]
    Near -->|"yes"| Lazy["Load form chunk, keep it loaded"]
    classDef data fill:#9ae6b4,stroke:#2f855a,stroke-width:1px,color:#000;
    classDef logic fill:#FFA726,stroke:#E65100,stroke-width:1px,color:#000;
    classDef decision fill:#FFF59D,stroke:#F57F17,stroke-width:1px,color:#000;
    class In data;
    class Opts,Pre,Keep,Notice,FormOnly,Now,Placeholder,Lazy logic;
    class Pk,Gate,Load,Near decision;

Text alternative: the panel derives the shoot options, applies a valid new package value as preselect with a matching mail subject, wraps the form in the gate when the form is off, and renders the form now (eager) or when it comes near the screen or a package value arrives (lazy), keeping a placeholder until then.

Properties for property-based testing (PBT-01)

Function Property Category
contactChannels The e-mail channel is present and first ⇔ emailAddress(email) is not null Invariant
contactChannels The social channels are exactly visibleSocials(socials) in the same order (same platforms and hrefs) Invariant / oracle
contactChannels Every social channel's label is its trimmed label when non-empty, otherwise the platform name; never empty Invariant
contactChannels Every href is mailto: or https:; never javascript: or another scheme Invariant (security)
contactChannels external is true exactly for social channels Invariant
contactChannels Length ≤ 1 + socials.length Invariant

Generators: extend src/test/arbitraries.ts — socialLink gets an optional label (absent, empty, whitespace, text), reuse anyEmail and anyHref. ContactPanel behaviour is covered by example-based component tests (it is UI wiring over already property-tested helpers).