-
-
Notifications
You must be signed in to change notification settings - Fork 100
Persist dark/light mode across page reloads #337
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: shiva <[email protected]>
@DianaLease could you review this PR ? |
✅ Deploy Preview for ap-template-playground ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Signed-off-by: shiva <[email protected]>
src/components/ToggleDarkMode.tsx
Outdated
@@ -8,8 +8,9 @@ const ToggleDarkMode: React.FC = () => { | |||
const [isDarkMode, setIsDarkMode] = useState(backgroundColor === "#121212"); | |||
|
|||
useEffect(() => { | |||
setIsDarkMode(backgroundColor === "#121212"); | |||
}, [backgroundColor]); | |||
const savedTheme = localStorage.getItem('theme'); |
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.
Can't we just get this before initialising the state variable above? We can get rid of this useState?
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.
resolved @sanketshevkar
src/store/store.ts
Outdated
const savedTheme = localStorage.getItem('theme'); | ||
if (savedTheme === 'dark') { | ||
set(() => ({ | ||
backgroundColor: '#121212', |
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.
Can we please move all these string values to a constants
file? We can reuse as variables across the app.
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.
resolved @sanketshevkar
Signed-off-by: shiva <[email protected]>
Sry @sanketshevkar for the late response..caught up with semester exams |
Signed-off-by: shiva <[email protected]>
@sanketshevkar @DianaLease @dselman ..could you review the PR when you find time ? |
Closes #336
Persist Dark/Light Mode Across Page Reloads
Changes
Flags
Screenshots or Video
Author Checklist
--signoff
option of git commit.main
fromfork:branchname