Skip to content
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

Darkmode toggler #260

Merged
merged 7 commits into from
Oct 13, 2024
Merged

Darkmode toggler #260

merged 7 commits into from
Oct 13, 2024

Conversation

Sristi2004-developer
Copy link
Contributor

Created a ThemeContext.jsx file which provides a DarkMode state to track whether the Dark mode is enabled and a toggleTheme function to switch between light and dark modes and used this context into the navbar component using useContext hook.

Copy link

vercel bot commented Aug 24, 2024

@Sristi2004-developer is attempting to deploy a commit to the team ecell Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Aug 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
e-cell-website-22 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 13, 2024 2:43pm

@Ruler45
Copy link
Collaborator

Ruler45 commented Aug 29, 2024

Dark mode doesn't persist after reload. FIX that

@Ecell23
Copy link
Contributor

Ecell23 commented Sep 2, 2024

still the same issue. Take help from your friends in E-cell

Copy link
Contributor

@dheeraj1922d dheeraj1922d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving DOM manipulation and localStorage updates inside useEffect to prevent side effects during rendering.

} else {
if (currentMode == "false") {
document.body.classList.remove("dark-theme");
localStorage.setItem("isDarkMode", "false");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant Local Storage Update : updating local Storage multiple times within the render phase, which is unnecessary

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use UseEffect to update the document.body class and localStorage whenever isDarkMode changes.

@dheeraj1922d dheeraj1922d self-requested a review September 4, 2024 09:48
@Ecell23 Ecell23 merged commit b929b40 into Ecell-NITS:vite_newdev Oct 13, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants