feat(frontend): Dark Mode Theme Engine — state refactor, animations, unit tests & screen reader support#1008
Conversation
Replace multiple useState calls with useReducer for atomic, predictable state transitions. Fix stale closure bug in system media query listener by using a ref for current theme. Separate mount-time initialization into a single one-time effect, eliminating redundant listener re-registration on every theme change. Extract DOM side-effects into reusable helpers for clarity and testability.
|
@libby-coder is attempting to deploy a commit to the Emmanuel's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
@libby-coder Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 34269854 | Triggered | Stripe Webhook Secret | 6405d1a | backend/src/lib/payment-signature-verification.test.js | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Summary
This PR addresses all four Dark Mode Theme Engine UX enhancement issues:
useStatecalls touseReducerfor atomic, predictable transitions. Fixed stale closure bug in the system media query listener using athemeRef. Initialization now runs in a single one-timeuseEffect, eliminating redundant listener re-registration on every theme change. ExtractedresolveThemeandapplyThemeToDomhelpers for clarity.framer-motionanimations on theThemeTogglewith spring physics, hover/tap scale effects, and smoother icon crossfade transitions between light, dark, and system states.ThemeTogglecovering loading skeleton, all icon states (sun/moon/system/error), ARIA attribute correctness, keyboard interaction, and screen reader announcement text.aria-labeldescriptions,aria-pressedto reflect dark-mode active state,aria-livepolite region for theme-change announcements, and focus-visible ring styles for keyboard users.Test plan
prefers-color-schememedia querylocalStoragepersists preference under the configuredstorageKeyCloses #947
Closes #948
Closes #949
Closes #950