feat(frontend): add dark mode with theme toggle and localStorage pers…#453
Open
oncleweynom wants to merge 1 commit into
Open
feat(frontend): add dark mode with theme toggle and localStorage pers…#453oncleweynom wants to merge 1 commit into
oncleweynom wants to merge 1 commit into
Conversation
|
@oncleweynom 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds manual dark mode support to the app — a toggle button in the navbar lets users switch between light and dark themes, with their preference saved across sessions.
Why
The codebase already had dark: Tailwind classes in place but no mechanism to activate them. Dark mode was purely driven by the OS setting with no user control. This completes the implementation.
Changes
globals.css
— migrated dark mode from prefers-color-scheme media query to .dark class strategy using Tailwind v4's @variant
layout.tsx
— added a synchronous inline script that reads localStorage and applies .dark before React hydrates, eliminating flash of wrong theme. Added suppressHydrationWarning on
ThemeToggle.tsx
— icon button (sun/moon) that reads from and writes to the theme store
Navbar.tsx
— mounts ThemeToggle between the Pools link and ConnectWallet
themeStore.ts
— Zustand store managing theme, setTheme, and toggleTheme. Writes to localStorage on every change
index.ts
— exports useThemeStore and Theme type
index.ts
— exports ThemeToggle
Behaviour
First visit: checks localStorage first, falls back to prefers-color-scheme
Toggle: switches theme instantly, persists choice to localStorage
No flash: inline script runs before paint, before hydration
All existing dark: classes across the app activate automatically — no page-level changes needed
Build
next build --webpack passes clean ✓
ESLint + Prettier pre-commit hooks pass ✓
close #430