Fix WCAG AA contrast failures on colored badge, state, and tooltip backgrounds#130
Open
michikrug wants to merge 2 commits into
Open
Fix WCAG AA contrast failures on colored badge, state, and tooltip backgrounds#130michikrug wants to merge 2 commits into
michikrug wants to merge 2 commits into
Conversation
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.
Problem
Several color tokens in the Graphite dark theme used bright/pastel colors as opaque backgrounds while the text rendered on top was near-white (
rgb(228, 228, 231)). This produced contrast ratios well below the WCAG AA minimum of 4.5:1, making the affected components effectively unreadable.rgb(255, 219, 117)rgb(39, 209, 246)rgb(234, 114, 135)rgb(78, 183, 128)rgb(141, 253, 166)rgb(255, 255, 255)Badge colors:
token-color-background-label-badge-{color}aliased directly to the corresponding feedback token (e.g.var(--token-color-feedback-warning)). Those feedback tokens are intentionally bright because their primary role is as icon and indicator colors on dark backgrounds — a context where high lightness is desirable. Using them as opaque badge fills with light text on top is a separate concern that required dedicated, darker values.Tooltip:
--wa-tooltip-background-colorfalls back through--ha-tooltip-background-colorto--ha-color-surface-default, a HA core token that the theme did not override. HA's built-in default for that token is a light/white surface, so the tooltip rendered near-white text (rgb(228, 228, 231)) on a white background regardless of theme mode.Changes
src/tokens_dark.yamltoken-rgb-green/token-rgb-light-green— darkened from pastel mint to a mid-range green that passes WCAG AA against white texttoken-color-feedback-success/rgb-success-color— aligned to the updated greentoken-color-background-label-badge-{red,blue,yellow}— decoupled from the feedback tokens and replaced with dedicated dark values; the feedback tokens themselves are unchanged so icon/indicator uses are unaffectedtoken-color-background-label-badge-green— updated to match the new green tokentoken-rgb-greenrgb(141, 253, 166)rgb(32, 126, 71)token-rgb-light-greenrgb(156, 255, 166)rgb(42, 126, 77)token-color-feedback-successrgb(118, 214, 152)rgb(32, 126, 71)token-color-background-label-badge-redvar(--feedback-error)rgb(174, 19, 50)token-color-background-label-badge-bluevar(--feedback-info)rgb(10, 104, 127)token-color-background-label-badge-yellowvar(--feedback-warning)rgb(121, 98, 6)token-color-background-label-badge-greenrgb(78, 183, 128)rgb(32, 126, 71)src/template.yamlha-tooltip-background-color— explicitly set totoken-color-background-input-base(rgb(46, 48, 56)) to prevent fallback to HA's built-in light surfaceha-tooltip-text-color— explicitly set totoken-color-text-primaryto make the intent clear and guard against future changes to the fallback chainha-tooltip-background-colorrgb(255, 255, 255)rgb(46, 48, 56)Out of scope
token-color-feedback-{error,info,warning}— left unchanged; they are used primarily as icon/text indicators on dark backgrounds where their high luminance gives excellent contrast (5–12:1).rgb(224, 138, 0)yields ~2.69:1 against white, which fails AA for normal text. This is a known characteristic of saturated orange as a primary hue and requires a broader design decision beyond a token patch.