Repository navigation
Choose black or white text on accents by WCAG contrast - #16
Open
piotrkowski wants to merge 1 commit into
Open
piotrkowski wants to merge 1 commit into
piotrkowski wants to merge 1 commit into
Conversation
`on_color` chose black or white ink with a cutoff on `luminance`, which weights the channels but leaves them gamma-encoded. That reads mid tones as darker than they are, so they got white where black has twice the contrast: 2.7:1 against 7.7:1 on Everforest's red, which fills the destructive buttons, and 3.2:1 against 6.5:1 on a plain #8f8f8f. It now takes the WCAG relative luminance, with the channels linearised, and picks whichever ink has the higher contrast ratio. `luminance` stays as it is for telling a light palette from a dark one, the only other thing it does. Light accents such as Everforest's, Catppuccin's, Tokyo Night's and Nord's already got black and are unchanged. A saturated mid blue like GNOME's #3584e4 flips to black as well, 5.6:1 against 3.8:1. None of this touches a desktop without an Omarchy palette, where libadwaita's own colours stand.
piotrkowski
force-pushed
the
fix/on-color-contrast
branch
from
October 11, 2026 19:01
6417a95 to
13126d6
Compare
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.
on_colorpicks black or white withluminance(c) > 0.6, on gamma-encoded sRGB values (weighted, but not linearized). For mid tones that often picks the worse ink.#8f8f8f, for example, gets white at 3.2:1 instead of black at 6.5:1. The red from the Everforest test palette (#e67e80) gets white at 2.7:1, which is what destructive buttons use.This picks whichever of black or white has the higher WCAG contrast ratio, using linearized relative luminance.
luminanceitself is unchanged, since mode detection still uses it.#8f8f8f#e67e80(Everforest red)#e06c75(One Dark red)#3584e4(GNOME blue)Light accents like Everforest, Catppuccin, Tokyo Night and Nord are unaffected; they were already black. Note that GNOME blue flips to black too, because white falls short of 4.5:1 there. This only affects Omarchy palettes; without one, libadwaita's own colors are untouched.
Before / after with a
#8f8f8faccent (checked toggle, today badge):Best landed after #14: with more reds getting black ink, destructive buttons need their fill back. The two merge cleanly in either order.
Test first (
on_color_picks_the_ink_with_more_contrast_on_a_mid_tone), then the four CI gates.