You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(a11y): improve label contrast on light theme to meet WCAG AA requirements (JhaSourav07#1693)
## Description
FixesJhaSourav07#1685
In the default `light` theme (`bg: ffffff`, `accent: 0969da`), the
`.label` class was rendered using the accent color at 70% opacity,
producing a pale blue-gray (`#5396e5`) on a pure white background with a
contrast ratio of only ~2.8:1 — severely violating the WCAG AA minimum
of 4.5:1.
**Changes made:**
- Updated `renderStyle` in `lib/svg/generator.ts` to accept the `bg`
color and use `getLuminance` to detect background brightness
- On light backgrounds (`luminance > 0.5`), `.label` now uses the
primary `text` color (`#24292f`) at 80% opacity, achieving a contrast
ratio of ~5.5:1
- On dark backgrounds, `.label` retains the existing accent color fill
at 70% opacity
- Updated `generateAutoThemeSVG` and `generateAutoThemeVersusSVG` to
compute `--cp-label-fill` and `--cp-label-opacity` CSS custom properties
dynamically for light/dark theme pairs
- Added `getLuminance` utility to `lib/svg/sanitizer.ts` for background
brightness detection
- Added test case in `generator.test.ts` asserting correct label styling
on both light and dark backgrounds
- All 150 tests pass
## Pillar
- [ ] 🎨 Pillar 1 — New Theme Design
- [x] 📐 Pillar 2 — Geometric SVG Improvement
- [ ] 🕐 Pillar 3 — Timezone Logic Optimization
- [ ] 🛠️ Other (Bug fix, refactoring, docs)
## Checklist before requesting a review:
- [x] I have read the `CONTRIBUTING.md` file.
- [x] I have tested these changes locally
(`localhost:3000/api/streak?user=Pranav-IIITM&theme=light`).
- [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors (CI will fail otherwise).
- [x] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
- [ ] I have updated `README.md` if I added a new theme or URL
parameter.
- [x] I have started the repo.
- [x] I have made sure that i have only one commit to merge in this PR.
- [x] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
- [x] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.
0 commit comments