Fix pink header in chromatic light palettes (mix alpha in oklab, not oklch)#284
Merged
Merged
Conversation
Translucent theme tokens were derived with `color-mix(in oklch, <color>, transparent)`. Mixing with `transparent` in a polar space drops the result hue to `none`, which renders as hue 0 (red): the chroma survives, so any palette whose canvas/ink/primary isn't pure gray got a pink-tinted header (--surface-scrim), hover, and selection. The default palette escaped only because its anchors are chroma-0. Mix translucency in oklab (rectangular — carries the hue through) instead. Opaque color->canvas mixes stay oklch. Covers --surface-scrim, --state-hover/active, --surface-recessed/raised/destructive/selected and their borders in theme.css, plus the scrollbar thumbs in app.css. Add a theme.test.ts guard that fails if `color-mix(in oklch, ..., transparent)` is reintroduced, so future palettes stay correct by construction. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
In Light mode, the Nord and Dracula palettes (and any non-gray palette) rendered the app header (
bg-surface-scrim) with a pink/warm tint that didn't match the cool body. Every new palette hit this, so it was a systematic derivation bug rather than a per-theme mistake.Root cause
Translucent tokens were derived with
color-mix(in oklch, <color>, transparent). Mixing a color withtransparentin a polar space drops the result hue tonone, which renders as hue 0 (red) while the chroma survives. Chromium computes, for Nord's canvas:Composited over the canvas that's
[243,237,240](pink). The default palette escaped only because its anchors areoklch(1 0 0)— chroma exactly 0, so there's no hue to lose.Fix
Mix translucency in
oklab(rectangular — carries the hue through). Verified:color-mix(in oklab, #eceff4 92%, transparent)over canvas →[236,239,245], matching the cool body. Opaque color→canvas mixes correctly stayoklch.Touched (light + dark):
--surface-scrim,--state-hover/active,--surface-recessed/raised/destructive/destructive-border/selected/selected-borderintheme.css, plus the scrollbar thumbs inapp.css.This is the systematic fix: palettes only set opaque anchors and never touch these derived tokens, so every current and future palette is correct by construction.
Tests
theme.test.tsto acceptoklabfor the translucent tokens.color-mix(in oklch, …, transparent)is reintroduced.pnpm exec turbo run test --filter=@bb/app -- theme.test.ts→ 17 passed.Notes
Out of scope:
apps/landing/src/styles.csshas the same pattern (~24 spots), but it's the marketing site — not palette-driven, and mostly dark box-shadows where the hue shift is imperceptible. Worth a follow-up sweep for full consistency.🤖 Generated with Claude Code