feat: replace theme-based text color with WCAG luminance contrast (Closes #7) #69

Merged
shahondin1624 merged 1 commits from feature/issue-7-accessible-color-contrast into main 2026-03-13 14:08:05 +01:00

Summary

  • Add contrastTextColor(backgroundColor) utility in theme package that calculates WCAG 2.1 relative luminance and picks black or white text for >= 4.5:1 contrast ratio
  • Replace if (isInDarkMode) Color.Black else Color.White pattern in both Attribute.kt and Talent.kt with luminance-based calculation
  • Add 9 unit tests verifying luminance calculation, contrast ratio, symmetry, and WCAG compliance for all attribute colors

Test plan

  • All 9 ContrastUtilsTest tests pass (luminance, contrast ratio, WCAG compliance for all attribute colors)
  • Attribute and Talent cards derive text color from background color, not theme mode
  • Mid-luminance colors (e.g., gray) get appropriate contrast text

Closes #7

## Summary - Add `contrastTextColor(backgroundColor)` utility in theme package that calculates WCAG 2.1 relative luminance and picks black or white text for >= 4.5:1 contrast ratio - Replace `if (isInDarkMode) Color.Black else Color.White` pattern in both `Attribute.kt` and `Talent.kt` with luminance-based calculation - Add 9 unit tests verifying luminance calculation, contrast ratio, symmetry, and WCAG compliance for all attribute colors ## Test plan - [x] All 9 ContrastUtilsTest tests pass (luminance, contrast ratio, WCAG compliance for all attribute colors) - [x] Attribute and Talent cards derive text color from background color, not theme mode - [x] Mid-luminance colors (e.g., gray) get appropriate contrast text Closes #7
shahondin1624 added 1 commit 2026-03-13 14:07:59 +01:00
Add contrastTextColor() utility that calculates relative luminance per
WCAG 2.1 and picks black or white text to guarantee >= 4.5:1 contrast.
Attribute and Talent cards now derive text color from the background
color itself instead of checking dark/light theme, fixing mid-luminance
colors that were previously unreadable.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
shahondin1624 merged commit a9cf04de0e into main 2026-03-13 14:08:05 +01:00
shahondin1624 deleted branch feature/issue-7-accessible-color-contrast 2026-03-13 14:08:05 +01:00
Sign in to join this conversation.