Skip to content

Phone app: warning colour is a real hex again - #2122

Merged
davidmckayv merged 1 commit into
mainfrom
fix/mobile-warning-colour
Nov 24, 2026
Merged

davidmckayv merged 1 commit into
mainfrom
fix/mobile-warning-colour

Conversation

@davidmckayv

Copy link
Copy Markdown
Contributor

The phone app's warning colour was #bb4dNaN in light mode and #ffb9NaN in dark, which React Native can't draw.

Cause. mobile/src/scheme.ts is generated by bun run tokens:generate from tokens/src/scheme.ts, converting each OKLCH colour to sRGB hex. Warning is outside sRGB in both modes, so its blue linear channel is below zero. The transfer function raised that negative number to a fractional power (NaN) before the clip ran, and the clip let NaN through.

Fix. tokens/src/color.ts clips the linear channel to 0..1 before encoding. Warning is now #bb4d00 (light) and #ffb900 (dark), matching culori 4.0.2's clamped conversion of the web app's tokens. Regenerated: only the two warning lines change; the web, desktop and first-paint copies are unchanged.

Tests (tokens/tests/generated.test.ts):

  • every colour in the phone's copy is a #rrggbb or #rrggbbaa hex
  • the phone's warning equals the web app's --warning from app/src/theme.css, light and dark
  • out-of-gamut colours convert to the culori reference values

Red before the fix (3 failing, Received: "#bb4dNaN"), green after (12 pass).

The tokens generator converts each OKLCH colour to sRGB hex for the phone
app. A colour outside sRGB has a linear channel below zero, and the transfer
function raised that negative number to a fractional power, giving NaN before
the clip ran. Warning is outside sRGB in both modes, so the phone drew
#bb4dNaN (light) and #ffb9NaN (dark).

The converter now clips the linear channel before encoding, so warning comes
out #bb4d00 and #ffb900, the same as culori's clamped conversion of the web
app's tokens. No other colour changes.

The tokens tests now check that every colour in the phone's copy is a hex
React Native can draw, and that its warning matches the web app's warning
token in app/src/theme.css.
@davidmckayv
davidmckayv merged commit bdb6280 into main Nov 24, 2026
23 checks passed
@davidmckayv
davidmckayv deleted the fix/mobile-warning-colour branch November 24, 2026 07:48
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