-
Notifications
You must be signed in to change notification settings - Fork 53
fix: background not changing in dark/light mode toggle #220 #225
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,4 +175,23 @@ | |
| border-color: #1e90ff; | ||
| box-shadow: 0 0 5px #1e90ff; | ||
| } | ||
| /* =============================== | ||
| Global Light/Dark Background | ||
| =============================== */ | ||
|
|
||
| /* Light mode (default) */ | ||
| .light body, | ||
| .light .Home { | ||
| background-color: #ffffff !important; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid excessive !important usage to prevent future styling conflicts and allow component-level text color overrides |
||
| color: #000000 !important; | ||
| transition: background-color 0.4s ease, color 0.4s ease; | ||
| } | ||
|
|
||
| /* Dark mode */ | ||
| .dark body, | ||
| .dark .Home { | ||
| background-color: #0d0d0d !important; /* or #121212 for a softer dark */ | ||
| color: #f0f0f0 !important; | ||
| transition: background-color 0.4s ease, color 0.4s ease; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,20 +19,21 @@ export const Home = () => { | |
| const token = localStorage.getItem("token"); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensures API request is made only when a valid token exists, preventing unnecessary or unauthorized backend calls |
||
| if (token) { | ||
| axios.get(`${import.meta.env.VITE_API_URL}/users/me`, { | ||
| headers: { Authorization: `Bearer ${token}` }, | ||
| }) | ||
| .then(res => { | ||
| setUser(res.data.user); | ||
| localStorage.setItem("user", JSON.stringify(res.data.user)); // ✅ Keep in sync | ||
| }) | ||
| .catch(err => console.error("Error fetching user:", err)); | ||
| axios | ||
| .get(`${import.meta.env.VITE_API_URL}/users/me`, { | ||
| headers: { Authorization: `Bearer ${token}` }, | ||
| }) | ||
| .then((res) => { | ||
| setUser(res.data.user); | ||
| localStorage.setItem("user", JSON.stringify(res.data.user)); // ✅ Keep in sync | ||
| }) | ||
| .catch((err) => console.error("Error fetching user:", err)); | ||
| } | ||
| }, []); | ||
|
|
||
| return ( | ||
| <div> | ||
| <div id="top"></div> {/* Add this line */} | ||
| <div className="Home"> | ||
| <div id="top"></div> | ||
| <Header /> | ||
|
|
||
| {/* ✅ Show user info if logged in */} | ||
|
|
||
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.
Centralizes background and text color transitions to avoid duplication and keep theme switching smooth and consistent