feat: follow the reader's light or dark setting - #31
Merged
Merged
Conversation
The product and the evidence dashboard were dark whatever the reader had chosen. Both surfaces share this stylesheet, so redefining the tokens under `prefers-color-scheme: light` gives both a light theme and leaves every rule below written once. Two things had to change before the tokens alone were enough. The issue assumed every colour was already a token; nineteen were not. Raised surfaces were painted with literal white overlays, `rgba(255, 255, 255, a)`, which are invisible on a light page, and the sticky topbar carried the dark page colour so it would have floated a dark band over a light one. Both now come from tokens: a single `--tint` the overlays multiply against, which inverts with the theme and preserves every existing alpha, and a `--scrim` for the topbar. The verdict colours are not the dark ones lightened. A judge reads a verdict as a word and a glyph first, but the colour still has to carry, so pass, fail and review are darkened to hold contrast against a white page rather than staying shades chosen for near-black. The claim/reality contrast is still the one dramatic moment on the page. No new rule and no inline style, so the Content-Security-Policy is untouched, and the dashboard layer still defines no token of its own. Verified in both schemes in a browser; `apps/product` and `apps/dashboard` tests pass, 79 of them. Closes #14.
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.
Closes #14.
Both surfaces share this stylesheet, so the light theme is a
prefers-color-scheme: lightblock that redefines the tokens and nothing else. Every rule below stays written once and both themes get it, and the dashboard layer still defines no token of its own.One correction to the issue
The issue says all colours are already tokens. Nineteen were not, and they were exactly the ones that break:
rgba(255, 255, 255, a), in eighteen places: nav hover, table stripes, chips, the button's lit top edge. White on a white page is invisible, so the whole depth model would have flattened.rgba(8, 9, 12, 0.82), so it would have floated a dark band over a light page while scrolling.Rather than tokenise eighteen values separately, the overlays now multiply against a single
--tintthat inverts with the theme, preserving every existing alpha unchanged. The topbar gets a--scrim. That is two new tokens instead of eighteen, and it keeps the file's rule that depth is expressed one way.The verdict colours are not the dark ones lightened
--pass,--failand--revieware chosen for near-black and do not hold contrast on white. They are darkened for the light theme instead of reused. The file's stated principle is that a verdict is read as a word and a glyph first, so colour is never the only signal, but it still has to carry, and the claim/reality contrast is still the one dramatic moment on the page.Constraints respected
ships the product stylesheet verbatim as its baseanddefines no token or base component of its ownboth still hold.Verification
apps/productandapps/dashboardtests: 79 passing, including the two that guard the shared-stylesheet arrangement and the one that fails the build on an inline style.pnpm typecheckpasses.Note
Low Risk
Overview
This pull request implements automatic light/dark theme switching based on the user's system preference via
prefers-color-scheme: lightmedia query inapps/product/src/client/styles.css. The change corrects a prior assumption that all colors were already tokenized by introducing tokens for nineteen previously-hardcoded values, including raised-surface overlays that used literalrgba(255, 255, 255, a)values. The structure keeps every non-tokenized rule written once and shared between themes, with the light theme only redefining token values while the dashboard layer continues to avoid defining tokens of its own. Overall, this enables both light and dark surfaces to share the same stylesheet while honoring the reader's OS-level theme setting.Written by Gitzilla for commit de3b6bd. This will update automatically on new runs. Configure in the Gitzilla dashboard.