-
Notifications
You must be signed in to change notification settings - Fork 97
feat: add High-Contrast Accessibility Mode Toggle #1177
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 |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import { describe, it, expect } from "vitest"; | ||
|
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. P1: The test file provides essentially no coverage for the actual ThemeContext component or the high-contrast feature it claims to test. It only exercises basic localStorage setItem/getItem β no imports of ThemeProvider, useTheme, toggleHighContrast, or any of the actual module exports. The Prompt for AI agents |
||
|
|
||
| describe("ThemeContext theme & high-contrast state module", () => { | ||
| it("manages high contrast localStorage persistence safely", () => { | ||
| if (typeof localStorage !== "undefined") { | ||
| localStorage.setItem("voiceforge:highContrast", "true"); | ||
| expect(localStorage.getItem("voiceforge:highContrast")).toBe("true"); | ||
|
|
||
| localStorage.setItem("voiceforge:highContrast", "false"); | ||
| expect(localStorage.getItem("voiceforge:highContrast")).toBe("false"); | ||
| } else { | ||
| expect(true).toBe(true); | ||
| } | ||
| }); | ||
| }); | ||
|
Comment on lines
+1
to
+15
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. π Maintainability & Code Quality | π‘ Minor | β‘ Quick win Test the This test does not exercise π€ Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,9 +19,10 @@ import { | |||||
| LANGUAGE_STORAGE_KEY, | ||||||
| } from "../utils/languages.js"; | ||||||
|
|
||||||
| import { Trash2, CircleAlert, Download, Upload, Globe, Webcam } from "lucide-react"; | ||||||
| import { Trash2, CircleAlert, Download, Upload, Globe, Eye } from "lucide-react"; | ||||||
| import { useToast, ToastContainer } from "../components/useToast.jsx"; | ||||||
| import { LanguageSelector } from "../components/LanguageSelector.jsx"; | ||||||
| import { useTheme } from "../components/ThemeContext.jsx"; | ||||||
| import { | ||||||
| deleteVoiceProfile, | ||||||
| getSavedProfiles, | ||||||
|
|
@@ -77,6 +78,7 @@ export default function Settings() { | |||||
|
|
||||||
|
|
||||||
| const defaultSettings = DEFAULT_VOICE_SETTINGS; | ||||||
| const { theme, toggleTheme, isHighContrast, toggleHighContrast } = useTheme(); | ||||||
|
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. P3: Prompt for AI agents
Suggested change
|
||||||
| const [voiceSettings, setVoiceSettings] = React.useState(loadVoiceSettings); | ||||||
| const [language, setLanguage] = React.useState(loadLanguage); | ||||||
| const selectedLangObj = getLanguageByCode(language); | ||||||
|
|
@@ -628,6 +630,40 @@ export default function Settings() { | |||||
| <AudioOutputSelector /> | ||||||
| </section> | ||||||
|
|
||||||
| <section className="rounded-lg border border-ink/10 bg-white p-5 shadow-soft dark:border-border dark:bg-surface dark:text-neutral-100 dark:shadow-soft-dk"> | ||||||
| <h2 className="text-xl font-bold mb-1">Appearance & Accessibility</h2> | ||||||
| <p className="text-sm text-ink/65 mb-5 dark:text-muted"> | ||||||
| Customize high-contrast accessibility options, contrast ratios, and visual boundaries. | ||||||
| </p> | ||||||
|
|
||||||
| <div className="flex flex-col gap-4 sm:flex-row sm:items-center justify-between rounded-md border border-ink/10 bg-amber-50/40 p-4 dark:border-border dark:bg-black"> | ||||||
| <div className="flex items-start gap-3"> | ||||||
| <Eye size={20} className="mt-0.5 text-moss dark:text-glow" aria-hidden="true" /> | ||||||
| <div> | ||||||
| <h3 className="font-semibold text-sm text-ink dark:text-neutral-100"> | ||||||
| High-Contrast Accessibility Mode | ||||||
| </h3> | ||||||
| <p className="text-xs text-ink/65 dark:text-muted mt-0.5"> | ||||||
| Enforces maximum WCAG AAA contrast ratios, thick element borders, and bright yellow focus rings. | ||||||
| </p> | ||||||
| </div> | ||||||
| </div> | ||||||
|
|
||||||
| <button | ||||||
| type="button" | ||||||
| onClick={toggleHighContrast} | ||||||
| aria-pressed={isHighContrast} | ||||||
| className={`inline-flex items-center gap-2 rounded-full px-4 py-2 text-xs font-bold transition-all ${ | ||||||
| isHighContrast | ||||||
| ? "bg-amber-500 text-black shadow-sm ring-2 ring-amber-400" | ||||||
| : "bg-ink/10 text-ink hover:bg-ink/20 dark:bg-neutral-800 dark:text-neutral-200" | ||||||
| }`} | ||||||
| > | ||||||
| {isHighContrast ? "High-Contrast ON" : "High-Contrast OFF"} | ||||||
| </button> | ||||||
| </div> | ||||||
| </section> | ||||||
|
|
||||||
| <section className="rounded-lg border border-ink/10 bg-white p-5 shadow-soft dark:border-border dark:bg-surface dark:text-neutral-100 dark:shadow-soft-dk"> | ||||||
| <h2 className="text-xl font-bold">Backup & Restore</h2> | ||||||
| <p className="mt-1 text-sm text-ink/65 mb-5 dark:text-muted"> | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -243,3 +243,34 @@ textarea { | |||||||
| transition: stroke-dashoffset 0.1s linear, opacity 0.1s ease; | ||||||||
| opacity: 0; | ||||||||
| } | ||||||||
|
|
||||||||
| /* High-Contrast Accessibility Mode */ | ||||||||
| .high-contrast { | ||||||||
| --bg-page: #000000 !important; | ||||||||
| --bg-card: #000000 !important; | ||||||||
| --bg-input: #000000 !important; | ||||||||
| --text-base: #ffffff !important; | ||||||||
| --text-muted: #ffff00 !important; | ||||||||
| --border: #ffffff !important; | ||||||||
| --ring: #ffff00 !important; | ||||||||
| color: #ffffff !important; | ||||||||
|
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. P1: The high-contrast mode overrides CSS custom properties on the root and sets Prompt for AI agents |
||||||||
| background-color: #000000 !important; | ||||||||
|
itsdakshjain marked this conversation as resolved.
|
||||||||
| } | ||||||||
|
Comment on lines
+248
to
+258
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. π― Functional Correctness | π Major | ποΈ Heavy lift Override descendant palette utilities, not only root variables. Existing classes such as π§° Toolsπͺ Stylelint (17.14.0)[error] 147-147: Expected empty line before declaration (declaration-empty-line-before) (declaration-empty-line-before) π€ Prompt for AI Agents |
||||||||
|
|
||||||||
| .high-contrast * { | ||||||||
| border-color: #ffffff !important; | ||||||||
|
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. P2: The Prompt for AI agents
Suggested change
|
||||||||
| box-shadow: none !important; | ||||||||
| } | ||||||||
|
|
||||||||
| .high-contrast button, | ||||||||
| .high-contrast input, | ||||||||
| .high-contrast select, | ||||||||
| .high-contrast textarea, | ||||||||
| .high-contrast a { | ||||||||
| border: 2px solid #ffffff !important; | ||||||||
| } | ||||||||
|
Comment on lines
+260
to
+271
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. π― Functional Correctness | π Major | β‘ Quick win Increase card border widths as well as border colors. The universal rule changes only π€ Prompt for AI Agents |
||||||||
|
|
||||||||
| .high-contrast :focus-visible { | ||||||||
| outline: 3px solid #ffff00 !important; | ||||||||
| outline-offset: 3px !important; | ||||||||
| } | ||||||||
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.
P2: The
.high-contrastclass is applied in auseEffect, which runs after the browser paints. On initial load, users who have high-contrast mode persisted will see a brief flash of unstyled content before the class takes effect. Since this is an accessibility feature, consider usinguseLayoutEffectinstead so the class is applied synchronously before the first paint, eliminating the flash entirely. The same improvement could also benefit the existing theme effect.Prompt for AI agents