|
| 1 | +# Component Catalog |
| 2 | + |
| 3 | +`components.json` is the typed catalog of every section component under |
| 4 | +`src/components/sections/` — one entry per file, written from the actual JSX (not guessed). |
| 5 | + |
| 6 | +## Entry schema |
| 7 | + |
| 8 | +``` |
| 9 | +{ id, component, scenario, requiredFacts[], editingControls[], semanticFallback, |
| 10 | + motion { type: none|css|scroll-driven|webgl, reducedMotion }, browserApis[], |
| 11 | + a11yNotes, budget { maxKbJs, maxKbImg }, tests[] } |
| 12 | +``` |
| 13 | + |
| 14 | +- `scenario` — the visitor job the section serves (what it's FOR, not what it looks like). |
| 15 | +- `requiredFacts` — verified-fact keys the component may NOT render without. `[]` = copy-driven. |
| 16 | +- `semanticFallback` — what renders when facts/media are absent (scrub firewall, self-hide, defaults). |
| 17 | +- `budget` — gzipped JS ceiling (component + exclusive deps) and combined image-transfer ceiling at 1280w. |
| 18 | + |
| 19 | +## The provenance rule (non-negotiable) |
| 20 | + |
| 21 | +Components with non-empty `requiredFacts` render ONLY when those facts are verified in the |
| 22 | +creative brief / research pack — **never fabricate a fact to unlock a section.** No invented |
| 23 | +menu items, prices, products, named people, quotes, stats, live counts, logos, timeline |
| 24 | +events, FAQ pairs, or donate links. Most components self-hide via `src/lib/placeholders.ts` |
| 25 | +(scrubText / isPlaceholder / hasRealImage) as defense-in-depth, but three render props |
| 26 | +verbatim (`MetricRow`, `Quote`, `Spotlight`) — for those, this catalog IS the gate. |
| 27 | + |
| 28 | +## How site-generation consumes it |
| 29 | + |
| 30 | +1. Extract evidence from the creative brief (`_brand.json`, research pack, citations). |
| 31 | +2. For each page, match visitor jobs to `scenario` fields to shortlist components. |
| 32 | +3. Select a shortlisted component only when EVERY `requiredFacts` key is verified; |
| 33 | + missing facts → pick the fact-free sibling (e.g. `TeamGrid` → `TeamRoles`) or omit. |
| 34 | +4. Respect `budget` per section and the route-level ceilings (JS ≤ 200KB gz/route). |
| 35 | +5. Honor `motion.reducedMotion` + `a11yNotes` as shipped invariants — don't regress them. |
| 36 | + |
| 37 | +## Drift gate |
| 38 | + |
| 39 | +`npm run validate:catalog` (`scripts/validate-catalog.mjs`) fails the build when a sections/ |
| 40 | +component lacks an entry, an entry points at a missing file, or `requiredFacts` isn't an array. |
| 41 | +Add the catalog entry in the SAME commit that adds/renames a section component. |
0 commit comments