feat(web): Add high-contrast mode setting#1284
feat(web): Add high-contrast mode setting#1284alacritythief wants to merge 2 commits intopingdotgg:mainfrom
Conversation
- Persist and apply a high-contrast class at startup and in the root route - Add a settings toggle and restore control - Boost muted text contrast in the UI
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can generate a title for your PR based on the changes with custom instructions.Set the |
|
Updated the PR description with related issues that are addressed and fixed with this PR and added comparison screenshots for tool calls. |
|
I prefer to change the backgrounds while keeping fonts as is. Vibe-coded: 98267d8 |
@lukstafi Thanks for the suggestion. I experimented with that and avoided it because I wanted to make a more comprehensive accessibility pass that follows WCAG 2.2 AA standards and proper contrast ratios in both modes. Pure black and white backgrounds can cause halation/readability issues. Your commit however did make me realize I should correct the non-text elements like borders too, so I updated my PR and screenshots to with that change. |
Addresses & Fixes Related Issues
Addresses #254, #1279
Fixes #233, Fixes #400
What Changed
Added an opt-in
High contrast modesetting to improve readability in both light and dark themes without changing the default appearance when the setting is off.This includes:
highContrastModeto the existing app settings schema and persistence flowSettings > Appearancehigh-contrastclass when the setting is enabledWhy
getLocalStorageItemis usedgetLocalStorageItemis used so high contrast mode can be applied immediately at startup, before React renders.That startup read is needed to avoid a flash where the app initially renders in normal contrast and only switches to high contrast after the app mounts. This mirrors the existing theme behavior, where theme classes are also applied early to avoid visual flicker.
The setting is still stored the same way as the rest of the app settings:
AppSettingsSchemat3code:app-settings:v1local storage entryuseAppSettings().updateSettings(...)The only special handling is the early synchronous read so the root class can be applied before first paint.
Why
The app had multiple contrast issues in both dark and light mode, mainly from:
text-muted-foreground/*utilitiesThe high contrast colors were chosen to bring these muted/read-secondary states closer to WCAG AA expectations for normal text contrast, instead of relying on visually subtle opacity reductions that were falling below accessible contrast thresholds. The goal here was not to redesign the palette, but to keep the existing visual language and raise the contrast of the specific text treatments that were failing.
Rather than changing the default theme for everyone, this PR adds a focused accessibility improvement that users can opt into when they want stronger readability.
Screenshots
High Contrast setting location

High Contrast togged ON

Dark mode with high contrast OFF

Dark mode with high contrast ON

Light mode with high contrast OFF

Light mode with with high contrast ON

Checklist
highContrastModeapp settingSettings > Appearancebun fmtbun lintbun typecheckNote
Add high-contrast mode setting to the web app
highContrastModeboolean toAppSettingsSchema(defaultfalse) and persists it in localStorage.applyHighContrastMode()in appSettings.ts which toggles ahigh-contrastclass on<html>, controlling CSS variables for muted text, borders, and inputs in both light and dark themes.Macroscope summarized 7255b26.