Repository navigation
fix(theme): take status colours out of the palette and put them in the theme - #714
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 onetoken, because the distinction between
red-300andred-400was never adecision anyone made.
111 tinted surfaces and edges →
surface-*/edge-*utilities thatcolor-mixfrom the token. A theme that changes its error colour now brings amatching wash with it. Verified live:
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
bg-<hue>-<rung>button fills. White text needs a colour fardarker than any
--color-*token — those are foregrounds — andbutton-contrast.test.tsalready guards what matters about 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 ameaning. Now
toContain("--color-warning"), which is more accurate anddoesn't break when a shade moves.
The guard
colour-tokens.test.tsbans the hues that have tokens, in the positions with aright 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) whileits own
--color-errorresolved to#ca2323(light's). I walked the ancestorchain, 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
elements below AA, against 25 of 30 when the review started
🤖 Generated with Claude Code