Skip to content

fix(client): WCAG AA colour contrast for ThemeToggle design tokens#1

Open
DevRushd wants to merge 1 commit into
masterfrom
colour-contrast-check
Open

fix(client): WCAG AA colour contrast for ThemeToggle design tokens#1
DevRushd wants to merge 1 commit into
masterfrom
colour-contrast-check

Conversation

@DevRushd

@DevRushd DevRushd commented Jun 29, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a proper design token system to the ThemeToggle component and ensures all colour pairs pass WCAG AA contrast ratios (4.5:1 normal text, 3:1 UI components). A CI check prevents future regressions.

Changes

client/src/index.css

  • Defined colour design tokens via Tailwind v4 @theme with .dark overrides
  • Consolidated duplicate :root blocks into one
  • Body colour and background now reference --color-text-body / --color-bg CSS vars

client/src/components/ThemeToggle.tsx

  • Replaced raw Tailwind colour classes with semantic token classes (bg-surface, border-border, text-icon, etc.)
  • Fixed border contrast: light border was 1.35:1 (needs 3:1), now 4.39:1; dark border was 1.40:1, now 3.48:1
  • Removed duplicate dark:bg-white/10 that was overriding dark:bg-white/5
  • Removed redundant dark:text-white (was overridden by dark:text-white/80 anyway)

client/scripts/check-contrast.js (new)

Zero-dependency Node.js script that:

  • Parses CSS variables from @theme, :root, and .dark blocks
  • Computes effective colours with proper alpha blending
  • Validates 8 foreground–background pairs against WCAG AA thresholds
  • Exits with code 1 on any failure

client/design.md

Added a Colour Tokens section documenting all 7 tokens for both light and dark modes, with effective values and contrast ratios.

.github/workflows/ci.yml

Added a Check colour contrast (WCAG AA) step to the client CI job that runs node scripts/check-contrast.js. The pipeline fails if any token pair drops below threshold.

Contrast verification

Pair Light Dark Threshold
Body text on background 17.40:1 12.10:1 4.5:1
Icon on button surface 13.34:1 9.12:1 4.5:1
Icon hover on hover surface 16.96:1 12.04:1 4.5:1
Border on button surface 4.39:1 3.48:1 3.0:1

Closes crackedstudio#827

…tokens

- Define colour design tokens via Tailwind v4 @theme with .dark overrides
- Fix border contrast (was 1.35:1 light / 1.40:1 dark, now 4.39:1 / 3.48:1)
- Consolidate duplicate :root blocks in index.css
- Add contrast verification script (scripts/check-contrast.js)
- Add CI step to fail on contrast regressions
- Document colour system in design.md under 'Colour Tokens' section

Closes crackedstudio#827
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.

[client] Add colour contrast check to ThemeToggle design tokens

1 participant