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): add aria-labelledby and aria-describedby to SVG badges for screen reader support (JhaSourav07#1687)
## Description
FixesJhaSourav07#1683
Although the generated SVGs included `<title>` and `<desc>` elements,
screen readers completely ignored them because the outer `<svg>` element
was missing `aria-labelledby` and `aria-describedby` attributes. This
fix adds proper screen reader support across all generated SVG badge
types.
**Changes made:**
- Added unique `id` attributes to `<title>` and `<desc>` elements based
on sanitized usernames (e.g. `id="cp-title-username"`,
`id="cp-desc-username"`)
- Added `aria-labelledby` and `aria-describedby` on the outer `<svg>`
tag referencing the unique IDs
- Fix applied across all SVG rendering functions: standard, auto-theme,
monthly, versus, wrapped, and error-state badges
- Updated existing test assertions in `generator.test.ts` and
`generator.additional.test.ts` to verify the presence of these
attributes
- All 146 tests pass
## Pillar
- [ ] 🎨 Pillar 1 — New Theme Design
- [x] 📐 Pillar 2 — Geometric SVG Improvement
- [ ] 🕐 Pillar 3 — Timezone Logic Optimization
- [ ] 🛠️ Other (Bug fix, refactoring, docs)
## Visual Preview
No visual change — this is an accessibility fix. Screen readers will now
correctly announce badge content to visually impaired users.
## 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`).
- [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 qualit
<desc id="cp-desc-${safeId}">GitHub Wrapped stats for ${safeUser} in ${year}: ${stats.totalContributions} total contributions, top language is ${stats.topLanguage||'Unknown'}, busiest month is ${stats.busiestMonth||'Unknown'}.</desc>
936
956
<defs>
937
957
${filterGlow}
938
958
</defs>
@@ -1084,6 +1104,8 @@ function generateAutoThemeMonthlySVG(stats: MonthlyStats, params: BadgeParams):
0 commit comments