Skip to content

diagram: finish design-token consolidation + dark-mode token parity - #802

Merged
bpowers merged 2 commits into
mainfrom
design-token-consolidation
Jun 20, 2026
Merged

bpowers merged 2 commits into
mainfrom
design-token-consolidation

Conversation

@bpowers

@bpowers bpowers commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

Finishes the design-token consolidation begun by the frontend UX audit (#799) and folds in the component-library dark-mode parity it overlapped (#709), so both are resolved together. src/diagram/theme.css becomes a complete light and dark token system, and ~30 stylesheets consume it instead of hardcoding literals.

What changed

  1. Hardcoded colors → tokens (diagram: component-library CSS modules hardcode light colors with no dark-mode overrides #709 fold-in). Every #fff surface, the named greys/dividers, and the pervasive rgba(0,0,0,x) MUI-opacity values now resolve through tokens. Near-duplicate greys/dividers are normalized onto a tight scale (text-primary/muted/light/disabled, divider/border/border-input); a few sub-perceptible shifts result (e.g. #999/#aaa→light, breadcrumb hover 0.08→0.04), each documented in theme.css. Surfaces and always-light contrast ink are kept distinct (--color-surface flips in dark; --color-contrast-text does not) so button/AppBar text stays white. Every new token has a [data-theme="dark"] value.
  2. Shadow tokens. Unified MUI-elevation scheme: --shadow-sm/md/lg → --shadow-1/2/3, plus the distinct --shadow-4/8/16/24 (AppBar/Menu/Drawer/Dialog). Inline elevation strings adopt the tokens.
  3. px → rem typography. Editor-chrome and detail-panel text moves to rem (honors browser zoom) via a new caption (0.75rem) token and app typography variant.
  4. Toolbar coupling. --toolbar-dense-height drives both Toolbar .dense min-height and Home .toolbarSpacer so they cannot drift.

Notes on scope

Dark-mode chrome tokens are infrastructure: nothing in the shipping app sets data-theme="dark" on the editor chrome yet (only StaticDiagram's canvas does), so light rendering is unchanged. Deliberate literal exceptions, left with rationale: Login's branded Google sign-in button, the ErrorToast severity palette (intentionally brighter than the status tokens), and canvas tool-icon greys.

Tests

New guard tests (src/diagram/tests/theme-tokens.test.ts, src/app/tests/design-tokens.test.ts) assert the component library stays literal-free, every var(--token) resolves to a definition, the chrome tokens carry dark values, no retired shadow names remain, Editor/ModuleDetails are rem-only, and the toolbar/caption couplings hold. Full diagram (1189) and app (98) jest suites, eslint, and tsc all pass.

Fixes #799
Fixes #709

🤖 Generated with Claude Code

Completes the design-token sweep begun by the frontend UX audit (#799) and
folds in the component-library dark-mode parity it overlapped (#709). theme.css
gains a full neutral text/border/action/surface palette plus brand variants,
each with [data-theme="dark"] values, so the component library and editor
chrome theme from one source instead of ~30 files of scattered literals.

- Shadows: renamed --shadow-sm/md/lg to a single MUI-elevation scheme
  (--shadow-1/2/3) and added the distinct --shadow-4/8/16/24 used by the
  AppBar, menus, drawer, and dialogs; inline elevation strings adopt them.
- Colors: migrated every hardcoded #fff/grey/divider and the rgba(0,0,0,x)
  MUI-opacity values onto tokens. Near-duplicate greys/dividers normalize onto
  a tight scale (documented in theme.css), trading a few sub-perceptible shifts
  for one coherent palette; surfaces vs. always-light contrast ink are kept
  separate so dark mode flips the former without inverting button text.
- Typography: editor-chrome and detail-panel text moves from raw px to rem
  (honoring browser zoom) via a new caption (0.75rem) variant and token.
- Toolbar: the app's fixed-AppBar spacer and Toolbar's dense min-height both
  derive from --toolbar-dense-height so they cannot drift apart.

Guard tests assert the component library stays literal-free, every var(--token)
resolves to a definition, the chrome tokens carry dark values, and the
toolbar/caption couplings hold. Login's branded Google button, the ErrorToast
severity palette, and canvas tool-icon greys are left as deliberate,
self-contained exceptions.
@bpowers

bpowers commented Jun 20, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1834fe2f27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

z-index: 1300;
background: #fff;
border: 1px solid rgba(0, 0, 0, 0.23);
background: var(--color-surface);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Set a foreground on tokenized autocomplete popups

When [data-theme="dark"] is applied high enough to affect this portaled listbox, --color-surface becomes dark here but the popup/options never set color, so option labels inherit the page/default black text instead of --color-text-primary and become hard to read on the dark surface. Add a foreground token on the listbox or option rows when switching the popup surface to the theme token.

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Jun 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.83%. Comparing base (d40c274) to head (1208649).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #802   +/-   ##
=======================================
  Coverage   90.83%   90.83%           
=======================================
  Files         224      224           
  Lines      142627   142627           
=======================================
+ Hits       129560   129562    +2     
+ Misses      13067    13065    -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@claude

claude Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review

No findings.

Verified the consolidation preserves semantics across the board:

  • Shadows: Each --shadow-{1,2,3,4,8,16,24} token's value byte-matches the inline string it replaces (so AppBar/Menu/Drawer/Dialog/etc. render identically). --shadow-md → --shadow-2, --shadow-sm → --shadow-1, --shadow-lg → --shadow-3 are pure renames at the same values.
  • Token closure: Every var(--...) reference across src/diagram/** and src/app/** resolves to a definition in theme.css; no retired --shadow-sm/md/lg usages remain anywhere.
  • Components are token-pure: src/diagram/components/*.module.css contains zero hex/rgba( literals after the change, matching what the guard test asserts.
  • rem migration scope: Editor.module.css and ModuleDetails.module.css have no remaining raw-px font sizes; out-of-scope files (e.g. LineChart.module.css:13's font-size: 12px) are consistent with the stated scope ("editor-chrome and detail-panel text").
  • Coupling tokens: .toolbarSpacer (Home) and .dense (Toolbar) both read --toolbar-dense-height; .caption reads --font-size-caption. Both couplings are covered by the new tests.
  • Documented sub-perceptible shifts: --color-text-light #888 → rgba(0,0,0,0.4) (≈#999, the centroid of the #888/#999/#aaa set it absorbs); --color-divider #ddd → rgba(0,0,0,0.12) (≈#dedede); breadcrumb hover 0.08 → 0.04. All called out in theme.css comments and the PR description.
  • Dark-mode parity: chrome tokens listed in the test (--color-surface, text scale, borders, action-hover) all have [data-theme="dark"] overrides; permanently-dark chips (--color-contrast-text, --color-snackbar-bg, --color-tooltip-bg) deliberately do not flip.

Overall correctness

Correct. The patch is a pure refactor with token-level identity for the shadows, documented intentional shifts for the consolidated greys/hover weights, and new guard tests that lock the consolidation in place.

Addresses a codex review finding on the Autocomplete popup and its siblings:
surfaces switched to var(--color-surface) but kept relying on inherited
(default-black) text, so under [data-theme="dark"] the surface flips dark while
option/content text stays black and becomes unreadable. Portaled popups
(Autocomplete, Drawer) can't inherit a foreground from the editor root at all.

Each affected surface now owns var(--color-text-primary) alongside its
background: the Autocomplete listbox, Drawer panel, Accordion, the variable /
module / error detail cards (covering the recessed field-bg wells and KaTeX,
which render with currentColor), the Snapshotter card, the search bar (native
input), and the hosted-editor error box. In light mode this softens those
surfaces' inherited text from pure black to the 0.87 MUI primary already used
by their tokenized siblings (sub-perceptible); in dark mode the text flips with
the surface.
@bpowers

bpowers commented Jun 20, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@claude

claude Bot commented Jun 20, 2026

Copy link
Copy Markdown

Reviewed the diff end-to-end. The token consolidation is consistent: every component-CSS literal removed maps to a defined token, the dark block carries values for all the chrome tokens introduced, the rgb-equivalents of the old hex literals match the new alpha-over-surface tokens (#999 ≡ rgba(0,0,0,0.4) on white, #666 ≡ rgba(0,0,0,0.6) on white, etc.), the few documented shifts (breadcrumb hover 0.08→0.04, checkbox border 0.54→0.6, standard input underline 0.42→0.23) are intentional normalizations, and the four guard tests (component literal-free, all var(--*) references defined, no retired shadow names, Editor/ModuleDetails rem-only, dense-toolbar/caption coupling) plausibly cover the contract. No findings.

Overall correctness: correct.

@bpowers

bpowers commented Jun 20, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 1208649b64

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@bpowers
bpowers merged commit 7eedcd5 into main Jun 20, 2026
15 checks passed
@bpowers
bpowers deleted the design-token-consolidation branch June 20, 2026 13:37
@bpowers

bpowers commented Jun 20, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 7eedcd5961

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant