Skip to content

feat(storybook): foundation governance stories (#406 PR7) - #426

Merged
Astro-Han merged 7 commits into
mainfrom
opencode/storybook-foundation
Jul 2, 2026
Merged

Astro-Han merged 7 commits into
mainfrom
opencode/storybook-foundation

Conversation

@Astro-Han

Copy link
Copy Markdown
Contributor

Summary

Make Storybook the visible, reviewable, lockable surface for the CSS/token foundation. This is PR7 of #406 — the acceptance pass that exposes foundation rules so PR2-PR6 can be reviewed in Storybook without driving the desktop app into product states.

Why

The design-system refactor (#406) needs a governance surface. Storybook had only 2 Design System stories (Tokens, Animation Catalog) and the palette toolbar exposed 4 of 11 palettes. The contract only checked subset, not completeness. PR2-PR6 (color, motion, radius, accent split, borders) have no visible review surface yet.

Scope

Changed:

  • Palette toolbar: 4 → 11 palettes (full THEME_PALETTES); contract upgraded from subset to bidirectional equality
  • design-tokens.stories.tsx: added SemanticColors export (action/control/link/focus-ring/status-running/nav-active/toast-accent)
  • animation-catalog.stories.tsx: added DurationScale and EasingScale exports
  • storybook-baseline-contract.test.ts: 3 new contract blocks (icon tracking, foundation story exports, undefined-token-reference guard)
  • tests/smoke.md §S10: synced 5 → 11 palettes

New:

  • icons.stories.tsx — auto-tracks all makeIcon products via displayName filter + bot brand icons via MAKA_BOT_ICON_BODIES keys
  • palette-matrix.stories.tsx — 11 palettes × light/dark grid (per-block data-maka-theme + .dark)
  • typography.stories.tsx — font-sans/mono, Markdown, code block
  • spacing.stories.tsx — --spacing step scale + layout geometry tokens
  • elevation.stories.tsx — 4 shadow recipes + border tokens
  • layering.stories.tsx — 10 z-index tokens sorted by value
  • interaction-states.stories.tsx — default/disabled/loading/icon buttons

Not included:

  • No token value changes, no primitive behavior changes
  • No Storybook addon/docs-site/Chromatic work
  • No token JSON/style-dictionary export
  • No Product surface expansion (existing Product stories stay as regression fixtures)
  • Primitive token consumers (deferred to PR2-PR6 when their tokens are ready)

Verification

  • npm run -w @maka/desktop test — 1648 pass (3 new contract it blocks)
  • npm run typecheck — all workspaces pass
  • npm run -w @maka/desktop build-storybook — builds successfully

Reviewer notes

4 atomic commits:

  1. fc88c306 palette toolbar + bidirectional contract + smoke.md sync
  2. 6c2cdd0b icon story (auto-tracked via displayName, zero-maintenance)
  3. f19551ea SemanticColors + DurationScale/EasingScale stories
  4. 33d82d32 6 foundation stories + foundation-exports contract + token-reference guard

The token-reference contract scans all 9 Design System story files for var(--*) and string-literal token references, asserting each resolves to a token defined in maka-tokens.css. This catches future undefined-token drift structurally, without pixel assertions.

Astro-Han added 7 commits July 2, 2026 18:35
The Storybook palette toolbar only exposed 4 of the 11 THEME_PALETTES,
so 7 palettes with full CSS definitions were invisible in review. The
contract only checked the subset direction, which let the gap survive.

Add all 11 palettes to the preview.tsx toolbar, tighten the contract
to assert bidirectional equality (offered == allowed), and sync the
stale smoke.md S10 section (5 → 11).
Auto-enumerate Phosphor icons (makeIcon products filtered by
displayName) and bot brand icons (MAKA_BOT_ICON_BODIES keys) so the
registry stays complete without manual maintenance. Contract locks the
enumeration seam.
…e contract

Add 6 Design System stories (Palette Matrix, Typography, Spacing,
Elevation, Layering, Interaction States) covering the full CSS/token
foundation surface. Extend the contract to lock required Design System
story exports and catch undefined token references in foundation stories.
…z-index sort

- Make default palette addressable via :root, [data-maka-theme="default"]
  selector so the Palette Matrix default tile renders real :root values
  even when the toolbar selects a non-default palette (Codex P2).
- Update readCssToken regex to handle combined selectors.
- Sort zScale array by numeric value to match the 'sorted by value' claim
  (Codex P3).
…oggle

- Deduplicate Phosphor icon entries by displayName so alias exports
  (ChevronLeftIcon = ChevronLeft etc.) no longer render duplicate tiles
  in the Icons grid (subagent review P3).
- Replace useState + MutationObserver with useSyncExternalStore in
  palette-matrix so dark-mode toggle re-renders synchronously without
  a one-frame stale flash (subagent review P3).
…n token guard, single-source palettes

- Merge InteractionStates into PrimaryActions (loading slot added);
  remove the standalone story to eliminate default/disabled/icon
  duplication flagged in review.
- Upgrade undefined-token guard: support var(--x, fallback),
  var( --x ), and double/backtick quotes; scan styles.css too;
  auto-discover story files via readdirSync instead of a hand-
  maintained list.
- Generate palette toolbar items from THEME_PALETTES with a label
  map, removing the double-maintenance surface; contract now asserts
  the toolbar is single-sourced from @maka/core.
@Astro-Han
Astro-Han merged commit 7d8b1c3 into main Jul 2, 2026
@Astro-Han
Astro-Han deleted the opencode/storybook-foundation branch July 2, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant