Skip to content

Commit b6ba35f

Browse files
feat(a11y): add aria-pressed attribute to toggle buttons
Co-authored-by: alvin000009238 <107313913+alvin000009238@users.noreply.github.com>
1 parent f93682b commit b6ba35f

4 files changed

Lines changed: 8 additions & 5 deletions

File tree

frontend/sync.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,13 @@ export function setupSyncFeature() {
375375
eyeOffIcon.style.display = 'block';
376376
togglePasswordBtn.setAttribute('aria-label', '隱藏密碼');
377377
togglePasswordBtn.setAttribute('title', '隱藏密碼');
378+
togglePasswordBtn.setAttribute('aria-pressed', 'true');
378379
} else {
379380
eyeIcon.style.display = 'block';
380381
eyeOffIcon.style.display = 'none';
381382
togglePasswordBtn.setAttribute('aria-label', '顯示密碼');
382383
togglePasswordBtn.setAttribute('title', '顯示密碼');
384+
togglePasswordBtn.setAttribute('aria-pressed', 'false');
383385
}
384386
});
385387
}

frontend/theme.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export function applyTheme(theme) {
2828
const nextThemeLabel = theme === 'light' ? '深色' : '淺色';
2929
toggleBtn.setAttribute('aria-label', `切換至${nextThemeLabel}模式`);
3030
toggleBtn.setAttribute('title', `切換至${nextThemeLabel}模式`);
31+
toggleBtn.setAttribute('aria-pressed', theme === 'dark' ? 'true' : 'false');
3132
}
3233

3334
document.dispatchEvent(new CustomEvent('themechange', {

public/index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</noscript>
4141
<script src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit" async defer></script>
4242
<script src="/theme-init.js"></script>
43-
<link rel="stylesheet" href="/dist/main-bt8E1vXG.css" id="vite-css">
43+
<link rel="stylesheet" href="/dist/main-D2sAJccc.css" id="vite-css">
4444
<link rel="icon" type="image/x-icon" href="/favicon.ico?v=20260402">
4545
<link rel="icon" type="image/png" href="/favicon-96x96.png?v=20260402" sizes="96x96" />
4646
<link rel="icon" type="image/svg+xml" href="/favicon.svg?v=20260402" />
@@ -91,7 +91,7 @@ <h1>成績分析平台</h1>
9191
</div>
9292
<div class="flex-center-gap-8 header-actions">
9393
<button class="icon-btn theme-toggle-btn" id="themeToggleBtn" type="button" aria-label="切換至淺色模式"
94-
title="切換主題">
94+
title="切換主題" aria-pressed="false">
9595
<span class="dropdown-icon theme-icon theme-icon-moon">
9696
<svg class="inline-svg-icon icon-18" fill="currentColor" xmlns="http://www.w3.org/2000/svg"
9797
height="1em" viewBox="0 -960 960 960" width="1em">
@@ -185,7 +185,7 @@ <h3 class="flex-center-gap-8">
185185
autocomplete="current-password" placeholder=" " data-tour="login-password">
186186
<label for="passwordInput">密碼</label>
187187
<button type="button" id="togglePasswordBtn" class="toggle-password-btn"
188-
aria-label="顯示密碼" title="顯示密碼">
188+
aria-label="顯示密碼" title="顯示密碼" aria-pressed="false">
189189
<svg class="inline-svg-icon eye-icon" fill="currentColor"
190190
xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 -960 960 960"
191191
width="1em">
@@ -534,7 +534,7 @@ <h3 class="section-title">
534534
</footer>
535535
</div>
536536

537-
<script type="module" src="/dist/main-D-w4GNFQ.js"></script>
537+
<script type="module" src="/dist/main-b8YgiUL2.js"></script>
538538
</body>
539539

540540
</html>

public/privacy.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<link
1515
href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Noto+Sans+TC:wght@400;500;700&display=swap"
1616
rel="stylesheet">
17-
<link rel="stylesheet" href="/dist/main-bt8E1vXG.css" id="vite-css">
17+
<link rel="stylesheet" href="/dist/main-D2sAJccc.css" id="vite-css">
1818
<link rel="icon" type="image/x-icon" href="/favicon.ico">
1919
<style>
2020
.privacy-container {

0 commit comments

Comments
 (0)