Skip to content

fix(theme): take status colours out of the palette and put them in the theme - #714

Merged
EVWorth merged 1 commit into
mainfrom
fix/colour-token-leak
Sep 17, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/colour-token-leak

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Wave 3 of the UI review.
Closes #706.

317 hardcoded palette classes across 46 files → 44. Every one was the same
colour in every theme by definition, which is how #218 happened: the Compare
screen rendered labels legible in dark and invisible in light. That was fixed
at the instance; the cause stayed in 46 files.

It's also what blocks custom themes (#350) — a theme can only restyle what goes
through tokens.

Three kinds, three answers

146 status text colours → --color-error / --color-success /
--color-warning / --color-accent. Every rung of a hue collapses onto one
token, because the distinction between red-300 and red-400 was never a
decision anyone made.

111 tinted surfaces and edges → surface-* / edge-* utilities that
color-mix from the token. A theme that changes its error colour now brings a
matching wash with it. Verified live:

dark   surface-error → #ef4444 @ 12%    edge-warning → #eab308 @ 35%
light  surface-error → #ca2323 @ 12%    edge-warning → #8b5f03 @ 35%

Two strengths, not the four opacities that were in use — the difference between
a 10% and a 15% tint was never chosen either.

20 solid borders and opacity-modified text the first two passes missed.

What stays, deliberately

  • Solid bg-<hue>-<rung> button fills. White text needs a colour far
    darker than any --color-* token — those are foregrounds — and
    button-contrast.test.ts already guards what matters about them.
  • Purple, pink, orange, grey. No semantic meaning here. Forcing them
    through tokens would mean inventing a token for "the colour of a subquery
    badge", which isn't a concept a theme should carry.

Tests that changed

Several asserted toContain("amber") — checking a hue where they meant a
meaning. Now toContain("--color-warning"), which is more accurate and
doesn't break when a shade moves.

The guard

colour-tokens.test.ts bans the hues that have tokens, in the positions with a
right answer, and keeps an allowlist that must be justified in writing —
currently empty. A third test fails if an allowlist entry stops being needed;
it caught the one speculative exception I'd written within a minute of my
writing it.

One chase worth recording

Mid-verification a token-styled element computed #ef4444 (dark's error) while
its own --color-error resolved to #ca2323 (light's). I walked the ancestor
chain, enumerated every matching CSS rule, and created a fresh element with the
same class — the fresh one was correct. A hard reload made the existing ones
correct too. It was stale HMR state after a long editing session, not a bug,
but it looked exactly like one and was worth ruling out rather than assuming.

Verification

  • 2,934 unit tests, 340 browser tests, lint, dprint, tsc pass
  • Measured in the running app: light theme now has 0 of 29 visible text
    elements below AA, against 25 of 30 when the review started

🤖 Generated with Claude Code

…e theme

317 hardcoded palette classes across 46 component files, down to 44. Every one
of them was the same colour in every theme by definition, which is how #218
happened: the Compare screen rendered labels that were legible in dark and
invisible in light. That was fixed at the instance, and the cause stayed in 46
files.

Three kinds, three answers:

- 146 status text colours — `text-red-400` and friends — now read from
  `--color-error`, `--color-success`, `--color-warning` and `--color-accent`.
  Every rung of a hue collapses onto the one token, because the distinction
  between red-300 and red-400 was never a decision anyone made.
- 111 tinted surfaces and edges — `bg-red-500/10`, `border-amber-500/30` — are
  now `surface-*` and `edge-*` utilities that `color-mix` from the token, so a
  theme that changes its error colour brings a matching wash with it. Two
  strengths rather than the four opacities that were in use; the difference
  between a 10% and a 15% tint was never chosen either.
- 20 solid borders and opacity-modified text that the first two passes missed.

What stays, deliberately: solid `bg-<hue>-<rung>` button fills, because white
text needs a colour far darker than any `--color-*` token — those are
foregrounds — and `button-contrast.test.ts` already guards the thing that
matters about them. And the hues with no semantic meaning here: purple, pink,
orange, grey. Forcing those through tokens would mean inventing a token for
"the colour of a subquery badge", which is not a concept a theme should carry.

Tests that asserted on colour class names now assert on the token. Those were
checking a hue where they meant a meaning: `toContain("amber")` became
`toContain("--color-warning")`, which is both more accurate and no longer
breaks when a shade changes.

The guard bans the hues that have tokens, in the positions that have a right
answer, and keeps an allowlist that must be justified in writing — currently
empty, and a third test fails if an entry stops being necessary. That test
earned itself immediately by catching the one exception I had written
speculatively.

Measured in the running app: light theme now has 0 of 29 visible text elements
below AA, against 25 of 30 when the review started.

Closes #706.
@EVWorth
EVWorth merged commit de12fcb into main Sep 17, 2026
12 checks passed
@EVWorth
EVWorth deleted the fix/colour-token-leak branch September 17, 2026 22:22
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.

[P2][convention] 340 hardcoded palette colours in 46 files bypass the theme tokens

1 participant