Skip to content

[minor] Rebalance semantic palette for text/glyph contrast#47

Open
matt-edmondson wants to merge 1 commit into
feat/theme-analysis-toolfrom
fix/palette-rebalance
Open

[minor] Rebalance semantic palette for text/glyph contrast#47
matt-edmondson wants to merge 1 commit into
feat/theme-analysis-toolfrom
fix/palette-rebalance

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Summary

The palette audit tool (#44) showed a systemic imbalance: Text failed WCAG AA over every Primary-colored surface on all 38 themes, and light-theme checkmarks fell under 3:1. Root cause was structural, not per-theme: accent fills sat at mid-high lightness while body text uses the brightest neutral, so light text landed on a light-ish fill.

Stacked on #44 (the analysis tool). Base retargets to main once that merges. Only the two mapper/derivation files change here.

Changes

  • ImGuiPaletteMapper — move text-bearing surfaces (Button, Header, Tab, TitleBgActive, TableHeaderBg, FrameBg) toward the low (background) lightness end. Because Text always sits at the maximum-visibility end, this widens the text/surface lightness gap in both light and dark themes. Base backgrounds (ChildBg/PopupBg/MenuBarBg) share the window surface; the CheckMark glyph takes the most-visible accent so it contrasts its frame.
  • SemanticColorMapper — widen the non-neutral band from 50–90% to 20–82% of the global lightness range. The lower floor gives accent surfaces contrast room and lets glyphs reach a dark enough value; capping the top below the global maximum keeps saturated hues in gamut instead of washing out near white (this also fixed the pre-existing chroma warnings on Dracula/One Dark/Nightfly).

Result (measured by ThemeProvider.Analysis)

Text/glyph gates Chroma warns
Before 0 / 38 pass 3
After 33 / 38 pass 1

Hue is preserved exactly (0° drift) on every theme. The 4 remaining fails (Tokyo Night Day, Everforest Light/Hard/Soft) are intentionally low-contrast light themes whose source palettes span too little lightness to reach AA on mid-surfaces without losing their character, so they stay flagged rather than distorted. Existing tests pass.

🤖 Generated with Claude Code

The ImGui mapper placed accent fills (Button/Header/Tab/TitleBg) at mid-high
lightness while body text uses the brightest neutral, so text-on-accent
contrast failed WCAG AA on every theme, and light-theme checkmarks fell
under 3:1.

- Mapper: move text-bearing surfaces toward the low (background) lightness
  end so they sit far from the text color in both light and dark themes;
  base backgrounds (Child/Popup/MenuBar) share the window surface; the
  checkmark glyph takes the most-visible accent to contrast its frame.
- SemanticColorMapper: widen the non-neutral band to 20-82% of the global
  range. The lower floor gives accent surfaces contrast room and lets glyphs
  reach a dark enough value; capping the top below the global maximum keeps
  saturated hues in gamut instead of washing out near white.

Measured across the 38 registered themes with ThemeProvider.Analysis:
text/glyph contrast passes on 33 (was 0); hue is preserved exactly. The
4 remaining are intentionally low-contrast light themes whose source
palettes cannot reach AA without losing their character.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant