fix(theme): generated waybar/rofi CSS invisible on on-surface palettes (item 27)
All checks were successful
Check / eval (push) Successful in 2m53s

Follow-on to the swaync fix (a643391): the generated Waybar CSS colored
the module row and #window @subtext and dim states @muted, and the
generated rofi theme put @fg text on @surface chips — invisible where
palettes use those roles as "on-surface" (flexoki-light: subtext==base,
surface==text; gruvbox: muted/base = 1.27). flexoki-light has no
whole-swap, so it ran this CSS. Generated surfaces only — the summer
whole-swaps are hand-authored and untouched.

- waybar: secondary text → alpha(@text, 0.85); dim states (inactive
  workspaces, DND bell, muted volume) → alpha(@text, 0.5).
- rofi: @dim → text+"80", @surface → text+"1a" (#RRGGBBAA fg tints).
- check-theme-contrast.py pairings/docs now cover all three generated
  surfaces; status glyphs (good/warn/bad on base, worst 2.05) are
  deliberately not held to a text ratio — raising them is palette
  design, a human decision.

Verified: V0; V1 (checks.theme-contrast green over 21 themes;
downstream-template-home builds; rendered waybar style has zero
@subtext/@muted/@surface; rendered custom.rasi shows fg-derived
tints). Honesty: NOT visually verified — V3 queued (flexoki-light
eyeball + dark-theme regression spot-check).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Bernardo Magri
2026-07-04 19:08:18 +01:00
parent a643391d3d
commit fd6e5f60e9
7 changed files with 54 additions and 37 deletions

View File

@@ -1,12 +1,12 @@
#!/usr/bin/env python3
"""Guard against invisible-text palettes (BACKLOG item 25).
"""Guard against invisible-text palettes (BACKLOG items 25 + 27).
Asserts, for every themes/*.json, the WCAG contrast ratio of each
hex-on-hex fg/bg pairing the generated swaync CSS uses. Pairings built
from alpha(@text) tints over @base are contrast-by-construction and
need no assert. Extend PAIRINGS as more generated surfaces are fixed to
palette-safe roles (item 27 tracks waybar/rofi, which still use
subtext/surface and would fail here today).
hex-on-hex fg/bg pairing the generated swaync/waybar/rofi CSS uses.
Pairings built from alpha(@text) / #RRGGBBAA text tints are
contrast-by-construction and need no assert. Status glyph accents
(good/warn/bad on base) are deliberately NOT held to a text ratio —
several palettes sit at 2.02.7 there by design.
Wired as `checks.theme-contrast` in flake.nix; also runnable directly:
python3 tools/check-theme-contrast.py themes/
@@ -19,8 +19,9 @@ from pathlib import Path
# borders (@accent/@bad on @base in swaync) are decorative and not held
# to a text ratio (miasma's bad-on-base is 2.3, fine for a border).
PAIRINGS = [
("text", "base", 4.5, "swaync body/summary/titles on the toast"),
("base", "accent", 3.0, "swaync widget-title button:hover"),
("text", "base", 4.5, "swaync body / waybar modules / rofi rows"),
# symmetric ratio also covers accent-on-base (waybar updates, rofi prompt)
("base", "accent", 3.0, "swaync button:hover / waybar active ws / rofi selected row"),
]