Skip to content

fix: raise muted and destructive ink to 4.5:1 in the light theme - #78

Merged
YaelAnaya merged 1 commit into
mainfrom
fix/60-colour-role-contrast
Dec 5, 2026
Merged

YaelAnaya merged 1 commit into
mainfrom
fix/60-colour-role-contrast

Conversation

@YaelAnaya

Copy link
Copy Markdown
Contributor

Summary

Two colour roles fell below WCAG 1.4.3's 4.5:1 in the light theme: muted text on muted surfaces, and destructive ink on its own tint. Both roles change in styles.css only, with no component class touched. The axe exception for #60 is gone, and 70 contrast assertions now hold the pairs in both themes.

Closes #60

Values (light only; dark already passed and is unchanged)

Role Was Is Contrast, was → is
--muted-foreground neutral-500 #737373 neutral-600 #525252 on #f5f5f5 4.34 → 7.15; on #f3f3f3 4.26 → 7.03; on the destructive tint 4.33 → 7.14
--destructive #e60000 red-700 on its /10 tint 4.03 → 5.33; on white 6.42

In dark, muted-foreground on muted is 5.83, and destructive on its /20 tint is 4.63–5.3.

Decisions (please look at the first one)

  • Muted text is now a full palette step darker: neutral-600, about 7:1.
    • The issue suggested something between 500 and 600. A color-mix of the two reaches 5.47:1, but Tailwind emits an @supports fallback for it in every consumer's :root, which broke the packed-consumer test.

    • The two options:

      • keep neutral-600, a palette step, simple and with headroom;
      • use a literal grey around oklch(0.51 0 0) (≈5.4:1 on the tightest surface), as styles.css already does for --brand and --destructive-foreground.

      This PR takes neutral-600. If you'd rather keep muted text lighter, it's a one-line change plus regenerating the baselines.

  • Destructive is red-700. That is what DESIGN.md already said it was, so the doc is now true. Its dark column is corrected to red-400 (it said red-300), and its surface column to "none".
  • DESIGN.md gains a Text contrast section with the rule, the values and the reasons.

Changes

  • src/theme/styles.css: the two roles.
  • tests/theme/contrast.ts (new): resolves oklch, var() and alpha, and computes the WCAG ratio.
  • tests/theme/tokens.test.ts: 70 assertions in both themes.
    • Pairs: each foreground on its surface, status ink on its -surface, muted-foreground on seven surfaces and tints, and destructive on its tint.
    • 10 of them fail against the old stylesheet.
  • tests/browser/a11y.spec.ts: the [a11y] Colour roles: muted text on muted surfaces and destructive ink on its tint fall below 4.5:1 (light) #60 exception and the list of low-contrast pairs are removed. The [22] CMP-01 · CodeBlock: audit the language switcher and choose its foundation #35 entries for CodeBlock's line numbers at muted-foreground/70 stay.
  • tests/package/consumer.test.ts: expects neutral-600.
  • Visual: 32 baselines changed, all light theme, none dark. The agent viewed badge, button, table-phone, sidebar-desktop, dialog and field-errors; I checked field-errors. Only muted and destructive ink moved.
    • A plain test:visual:update rewrote nothing, because each change is under the 0.2% pixel tolerance. The baselines were forced with --update-snapshots=all.

Testing evidence

Limitations

  • Destructive's hover (/20) on the white page is 4.38:1 in light. It is transient, and axe doesn't measure it. Clearing it needs red-800 or a different hover recipe; DESIGN.md notes it.
  • The visual tolerance is loose enough that colour-only changes of this size pass without a baseline update. That's worth knowing for future token changes.

…ight

--muted-foreground moves from neutral-500 to neutral-600 and --destructive from #e60000 to red-700 in the light theme. Dark is unchanged. tokens.test.ts now asserts 4.5:1 for the ink/surface pairs components paint, in both themes. The #60 exception is removed from the axe audit, DESIGN.md records the decision, and 32 light-theme baselines are updated.

Closes #60
@YaelAnaya YaelAnaya added bug Something isn't working area: design-tokens Visual contracts and styling area: accessibility Accessibility and interaction semantics labels Dec 5, 2026
@YaelAnaya YaelAnaya self-assigned this Dec 5, 2026
@YaelAnaya
YaelAnaya merged commit 3d4b09a into main Dec 5, 2026
7 checks passed
@YaelAnaya
YaelAnaya deleted the fix/60-colour-role-contrast branch December 5, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: accessibility Accessibility and interaction semantics area: design-tokens Visual contracts and styling bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[a11y] Colour roles: muted text on muted surfaces and destructive ink on its tint fall below 4.5:1 (light)

1 participant