-
Notifications
You must be signed in to change notification settings - Fork 0
🎨 Palette: Add aria-pressed to toggle buttons #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ export function applyTheme(theme) { | |
| const nextThemeLabel = theme === 'light' ? '深色' : '淺色'; | ||
| toggleBtn.setAttribute('aria-label', `切換至${nextThemeLabel}模式`); | ||
| toggleBtn.setAttribute('title', `切換至${nextThemeLabel}模式`); | ||
| toggleBtn.setAttribute('aria-pressed', theme === 'dark' ? 'true' : 'false'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the WAI-ARIA Authoring Practices Guide (APG), a button that changes its label to reflect its state (e.g., "切換至深色模式" vs "切換至淺色模式") is not considered a toggle button and must not use the References
|
||
| } | ||
|
|
||
| document.dispatchEvent(new CustomEvent('themechange', { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,7 @@ | |
| </noscript> | ||
| <script src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit" async defer></script> | ||
| <script src="/theme-init.js"></script> | ||
| <link rel="stylesheet" href="/dist/main-bt8E1vXG.css" id="vite-css"> | ||
| <link rel="stylesheet" href="/dist/main-D2sAJccc.css" id="vite-css"> | ||
|
||
| <link rel="icon" type="image/x-icon" href="/favicon.ico?v=20260402"> | ||
| <link rel="icon" type="image/png" href="/favicon-96x96.png?v=20260402" sizes="96x96" /> | ||
| <link rel="icon" type="image/svg+xml" href="/favicon.svg?v=20260402" /> | ||
|
|
@@ -91,7 +91,7 @@ <h1>成績分析平台</h1> | |
| </div> | ||
| <div class="flex-center-gap-8 header-actions"> | ||
| <button class="icon-btn theme-toggle-btn" id="themeToggleBtn" type="button" aria-label="切換至淺色模式" | ||
| title="切換主題"> | ||
| title="切換主題" aria-pressed="false"> | ||
|
Comment on lines
93
to
+94
|
||
| <span class="dropdown-icon theme-icon theme-icon-moon"> | ||
| <svg class="inline-svg-icon icon-18" fill="currentColor" xmlns="http://www.w3.org/2000/svg" | ||
| height="1em" viewBox="0 -960 960 960" width="1em"> | ||
|
|
@@ -185,7 +185,7 @@ <h3 class="flex-center-gap-8"> | |
| autocomplete="current-password" placeholder=" " data-tour="login-password"> | ||
| <label for="passwordInput">密碼</label> | ||
| <button type="button" id="togglePasswordBtn" class="toggle-password-btn" | ||
| aria-label="顯示密碼" title="顯示密碼"> | ||
| aria-label="顯示密碼" title="顯示密碼" aria-pressed="false"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| <svg class="inline-svg-icon eye-icon" fill="currentColor" | ||
| xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 -960 960 960" | ||
| width="1em"> | ||
|
|
@@ -534,7 +534,7 @@ <h3 class="section-title"> | |
| </footer> | ||
| </div> | ||
|
|
||
| <script type="module" src="/dist/main-D-w4GNFQ.js"></script> | ||
| <script type="module" src="/dist/main-b8YgiUL2.js"></script> | ||
| </body> | ||
|
|
||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,7 @@ | |
| <link | ||
| href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Noto+Sans+TC:wght@400;500;700&display=swap" | ||
| rel="stylesheet"> | ||
| <link rel="stylesheet" href="/dist/main-bt8E1vXG.css" id="vite-css"> | ||
| <link rel="stylesheet" href="/dist/main-D2sAJccc.css" id="vite-css"> | ||
|
||
| <link rel="icon" type="image/x-icon" href="/favicon.ico"> | ||
| <style> | ||
| .privacy-container { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the theme toggle, the password visibility button uses a dynamic label ("隱藏密碼" / "顯示密碼"). Per ARIA standards,
aria-pressedshould not be used on buttons whose labels change to reflect their state. It is recommended to remove thearia-pressedattribute to avoid redundant or confusing information for screen reader users.References