Skip to content

Commit 2974dfd

Browse files
committed
Add ARIA attributes to card appearance toggle buttons
Adds role="group" + aria-label to the .card-theme-row and aria-pressed state to each button, kept in sync by applyCardTheme(). This addresses the accessibility issue raised in #53. https://claude.ai/code/session_019mFhzJHWmUB8cTbLksb6ev
1 parent 8a35156 commit 2974dfd

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

assets/js/app.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ function applyCardTheme(themeName) {
9090
}
9191

9292
elements.cardThemeButtons.forEach((btn) => {
93-
btn.classList.toggle('active', btn.dataset.cardTheme === themeName);
93+
const isActive = btn.dataset.cardTheme === themeName;
94+
btn.classList.toggle('active', isActive);
95+
btn.setAttribute('aria-pressed', String(isActive));
9496
});
9597
}
9698

index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ <h1>GitHub Social <span>Preview</span></h1>
7171
<button class="template-btn" data-platform="desktop">Desktop</button>
7272
</div>
7373

74-
<div class="card-theme-row">
74+
<div class="card-theme-row" role="group" aria-label="Card appearance">
7575
<span class="card-theme-label">Appearance</span>
76-
<button class="template-btn active" data-card-theme="dark">Dark</button>
77-
<button class="template-btn" data-card-theme="light">Light</button>
76+
<button class="template-btn active" data-card-theme="dark" aria-pressed="true">Dark</button>
77+
<button class="template-btn" data-card-theme="light" aria-pressed="false">Light</button>
7878
</div>
7979

8080
<div class="dl-row">

0 commit comments

Comments
 (0)