Repository navigation
Preferences: accent ink and links keep contrast with the picked accent - #997
Open
juanlentino wants to merge 2 commits into
Open
juanlentino wants to merge 2 commits into
juanlentino wants to merge 2 commits into
Conversation
accentWantsDarkInk compared relative luminance against 0.35. The crossover where Void and Starlight have equal contrast is about 0.184, so between the two the picker chose Starlight where Void reads better: Teal, Emerald, Amber and custom colours such as #ff0000 (3.90:1 with Starlight, 4.91:1 with Void). Pulse keeps Starlight as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The accent picker wrote --os-ui-accent, its ink and its dim, and left --os-link and --os-ui-accent-strong at the palette's Nebula, so links and accent-strong labels stayed pink whatever swatch was picked. apply() now writes both inline on <body>: the accent itself when it reads at 4.5:1 on Astro, otherwise the accent mixed toward Starlight until it does. Pulse keeps the palette's Nebula, as it keeps its dim, and nothing is written while a desktop theme is worn, since the theme owns the surfaces the link sits on. Co-Authored-By: Claude Opus 5.5 <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.
Fixes #996
accentWantsDarkInkcompared the accent's relative luminance against0.35. The crossover where Void (#0c0b0f) and Starlight (#fffbff) have equal contrast on a fill is about0.184, so between the two the picker chose the ink with less contrast.What changed
src/settings/index.ts: the threshold is now0.184, with the formula in the docblock. Pulse returns early and keeps Starlight, as the docblock already promised.assets/css/variables.cssanddocs/desktop-themes.md: the comment and the token description now say Void is written when it has more contrast on the accent, and name the swatches that get it.Swatches whose ink changes to Void (dark)
#04a4cc#d97706#059669Custom accents with luminance between 0.184 and 0.35 change too, for example
#ff0000: 3.90:1 before, 4.91:1 after. Pulse, WordPress Blue, Indigo and Rose keep Starlight; Nebula, Sirius, Lagoon and Starlight keep Void.Links
The picker wrote
--os-ui-accent, its ink and its dim, and left--os-linkand--os-ui-accent-strongat the palette's Nebula (#ec9bff). Every link and accent-strong label stayed pink whichever accent was picked.apply()now writes both inline on<body>withaccentLinkColor()insrc/settings/index.ts. If the accent reads at 4.5:1 on Astro (#33303a, the lightest surface the palette puts text on), it is used as is. Otherwise it is mixed toward Starlight in 5% steps until it reads at 4.5:1. Pulse keeps Nebula, as it keeps its dim. Nothing is written while a desktop theme is worn, because the theme owns the surfaces the link sits on.assets/css/variables.cssanddocs/desktop-themes.mddescribe the two tokens.Contrast on Astro:
#ec9bff#ec9bff#9af2ff#9af2ff#9f98ff#9f98ff#fffbff#fffbff#2271b1#6fa1cc#3858e9#8899f2#04a4cc#11a8cf#059669#44af8e#d97706#dd841f#e11d48#ed7691#ff0000#ff7173tests/vitest/os-settings-accent-link-apply.test.ts(new, 14 cases):#ec9bff.With the link change reverted, 9 of the 14 cases fail (Sirius, Lagoon, Starlight, WordPress Blue, Indigo, Teal, Emerald, Amber, Rose). With it, all pass. With both changes,
npm run lint(0 errors),npm run typecheck,npm run buildandnpm run test:js(537 files, 6,722 tests) pass.Testing
tests/vitest/accent-ink.test.ts(new): for every built-in swatch except Pulse, and for custom#ff0000,#00a000and#000080, the chosen ink has more contrast than the other one, computed independently in the test;#ff0000reaches AA 4.5:1; Pulse keeps Starlight; a value that is not a six-digit hex keeps Starlight. On trunk 6 of the 16 cases fail (Teal, Emerald, Amber,#ff0000,#00a000, and the AA check); with this change all pass.npm run lint(0 errors),npm run typecheck, andnpm run test:js(535 files, 6,700 tests) pass.Engineered with Claude as a pair programmer.
🤖 Generated with Claude Code