Repository navigation
feat(index): follow the reader's system colour scheme - #18
Merged
Merged
Conversation
The directory listings were hard-coded light: every colour was a literal in a rule block, so a reader whose system prefers a dark scheme got a white page, and nothing told the browser to restyle its own canvas or scrollbars. Late-night browsing of the apt repository meant staring at a #fff sheet, and the values were not merely unadapted to a dark background but unusable on one: #555 dates and #ddd rules would have vanished, and the #0645ad links would have sat at a contrast ratio near 1.7:1. Move the palette into custom properties on :root and restate it inside @media (prefers-color-scheme: dark). The rules now reference var(--name) only, so the dark scheme can never inherit a colour that was picked for white. Add color-scheme: light dark so the browser styles form controls, scrollbars and the default canvas for the active scheme, and a pair of theme-color meta tags so the mobile address bar matches the page. The light palette is unchanged value for value, so nobody sees a different page today. The dark palette is #0d1117 on #e6edf3 with #4493f8 links; every colour pair measured to WCAG AA or better on its background (the weakest is 6.11:1). The new script-checks step asserts the shape rather than a list of known-bad values: the scheme is declared, the dark block restates the palette, and no colour literal appears outside a custom-property declaration. Each assertion was verified by mutation, restoring the old hard-coded body colours, deleting the dark block, emptying it, and dropping color-scheme, and each mutation fails the step on all three page depths. Signed-off-by: Oliver Lin <oliver@liuxiaozhen.dev>
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.
The directory listings were hard-coded light: every colour was a literal in a rule block, so a reader whose system prefers a dark scheme got a white page, and nothing told the browser to restyle its own canvas or scrollbars. Late-night browsing of the apt repository meant staring at a #fff sheet, and the values were not merely unadapted to a dark background but unusable on one: #555 dates and #ddd rules would have vanished, and the #0645ad links would have sat at a contrast ratio near 1.7:1.
Move the palette into custom properties on :root and restate it inside @media (prefers-color-scheme: dark). The rules now reference var(--name) only, so the dark scheme can never inherit a colour that was picked for white. Add color-scheme: light dark so the browser styles form controls, scrollbars and the default canvas for the active scheme, and a pair of theme-color meta tags so the mobile address bar matches the page. The light palette is unchanged value for value, so nobody sees a different page today. The dark palette is #0d1117 on #e6edf3 with #4493f8 links; every colour pair measured to WCAG AA or better on its background (the weakest is 6.11:1).
The new script-checks step asserts the shape rather than a list of known-bad values: the scheme is declared, the dark block restates the palette, and no colour literal appears outside a custom-property declaration. Each assertion was verified by mutation, restoring the old hard-coded body colours, deleting the dark block, emptying it, and dropping color-scheme, and each mutation fails the step on all three page depths.