Commit bed8625
authored
fix(svg): add aria attributes and desc to pulse badge SVG functions (JhaSourav07#3250)
## Description
Fixes JhaSourav07#3230
Added missing accessibility attributes to `generatePulseSVG` and
`generateAutoThemePulseSVG` in `lib/svg/generator.ts`, making pulse
badges consistent with all other badge types which are already fully
accessible.
**Changes made:**
`lib/svg/generator.ts`:
- Added `aria-labelledby="cp-title-${safeId}"` to root `<svg>`
- Added `aria-describedby="cp-desc-${safeId}"` to root `<svg>`
- Added `id="cp-title-${safeId}"` to existing `<title>` element
- Added `<desc id="cp-desc-${safeId}">` summarizing commit activity
- Added `safeId` derived from `safeUser` for valid HTML id format
`lib/svg/generator.test.ts`:
- Added `generatePulseSVG` to imports
- Added `describe('generatePulseSVG accessibility')` with 12 new tests
- Tests cover: aria attributes, title/desc ids, safeId sanitization,
pulseTotal in desc text, valid SVG structure, auto-theme variant
- All 143 tests passing ✅
## 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 — accessibility attributes are invisible in rendered
output but allow screen readers to correctly describe pulse badges.
Before: Screen readers saw an unlabelled SVG image
After: Screen readers announce "Heartbeat sparkline for {user} showing
commit activity over the last 30 days (total commits: {N})"
## Checklist before requesting a review:
- [x] I have read the `CONTRIBUTING.md` file.
- [x] I have tested these changes locally.
- [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors.
- [x] My commits follow the Conventional Commits format (`fix(svg):
...`).
- [ ] I have updated `README.md` if I added a new theme or URL
parameter. (Not needed)
- [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.
- [x] (Recommended) I joined the CommitPulse Discord community.2 files changed
Lines changed: 121 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
1778 | 1779 | | |
1779 | 1780 | | |
1780 | 1781 | | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
| 1799 | + | |
| 1800 | + | |
| 1801 | + | |
| 1802 | + | |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
| 1806 | + | |
| 1807 | + | |
| 1808 | + | |
| 1809 | + | |
| 1810 | + | |
| 1811 | + | |
| 1812 | + | |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2331 | 2331 | | |
2332 | 2332 | | |
2333 | 2333 | | |
| 2334 | + | |
| 2335 | + | |
2334 | 2336 | | |
2335 | 2337 | | |
2336 | 2338 | | |
| |||
2339 | 2341 | | |
2340 | 2342 | | |
2341 | 2343 | | |
| 2344 | + | |
| 2345 | + | |
2342 | 2346 | | |
2343 | | - | |
| 2347 | + | |
| 2348 | + | |
2344 | 2349 | | |
2345 | 2350 | | |
2346 | 2351 | | |
| |||
2510 | 2515 | | |
2511 | 2516 | | |
2512 | 2517 | | |
| 2518 | + | |
| 2519 | + | |
2513 | 2520 | | |
2514 | 2521 | | |
2515 | 2522 | | |
| |||
2518 | 2525 | | |
2519 | 2526 | | |
2520 | 2527 | | |
| 2528 | + | |
| 2529 | + | |
2521 | 2530 | | |
2522 | | - | |
| 2531 | + | |
| 2532 | + | |
2523 | 2533 | | |
2524 | 2534 | | |
2525 | 2535 | | |
| |||
0 commit comments