Repository navigation
fix(theme): ensure text on accent background keeps 4.5:1 contrast (#65) - #70
Merged
your-moon merged 1 commit intoOct 14, 2026
Merged
Conversation
your-moon
approved these changes
Oct 14, 2026
your-moon
left a comment
Owner
There was a problem hiding this comment.
nice one, checked it in the running app: dark mode buttons are now dark text on the violet (measured the pixels, both the sidebar and center buttons), light mode stays white. the built-in wallpapers test is the important part, covers the yellow case i hit. going with black text on dark mode since white on #8b7cf6 is only ~3.5:1. thanks!
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 #65.
Summary
When an accent color is light (e.g., bright yellow wallpapers like Van Gogh's Wheat Field with Cypresses or wallpaper accents pushed toward white on dark surfaces), primary buttons painted with
t.accentand hardcoded white text fell below the WCAG 4.5:1 contrast ratio.Changes
on_accent: HslatoTheme:pub on_accent: HslatoTheme.pub fn on_accent_for(accent: Hsla) -> Hslachoosing between white (0xffffff) and near-black dark ink (0x0d0d0d, matching tern's shell) based oncontrast_ratioagainstaccent(preferring white when it meets 4.5:1, otherwise falling back to near-black).self.on_accentinTheme::tintedand initialized in stockzeron_light()andzeron_dark().t.on_accentacross primary buttons:crates/tern/src/shell_connections.rs:720(button form submit / save).crates/tern/src/sidebar.rs:209(empty state "New connection" button).text_on_accent_keeps_contrast_in_light_and_dark_modesassertingcontrast_ratio(on_accent, accent) >= 4.49across test wallpaper swatches.built_in_wallpapers_keep_on_accent_contrastpinning that for every built-in wallpaper (BUILTINS) in both light and dark appearances,contrast_ratio(on_accent, accent) >= 4.49.zeron_darkandzeron_lightcontrast assertions incrates/tern/src/theme.rs.Verification
cargo test -p ternpassed (281 tests passed, 0 failed)../scripts/check-craft.shpassed cleanly.cargo fmt --checkpassed cleanly.cargo clippy --all-targets -- -D warningspassed with 0 warnings.