Skip to content

Commit 01ff8f5

Browse files
fix: dark mode persistence on Learn page (#183)
* fix(navbar): implement responsive collapse at 955px Signed-off-by: Yashsaraswat2004 <saraswatyash2004@gmail.com> * fix(navbar): implement responsive collapse at 955px - Add mobile-first responsive navbar - Preserve help dropdown functionality - Optimize logo/text hierarchy Closes #172 Signed-off-by: Yashsaraswat2004 <saraswatyash2004@gmail.com> * fix: dark mode persistence on Learn page Signed-off-by: Yashsaraswat2004 <saraswatyash2004@gmail.com> * feat: add additional style changes for Learn page consistency Signed-off-by: Yashsaraswat2004 <saraswatyash2004@gmail.com> * fix: remove console.log and revert unrelated navbar changes Signed-off-by: Yashsaraswat2004 <saraswatyash2004@gmail.com> --------- Signed-off-by: Yashsaraswat2004 <saraswatyash2004@gmail.com>
1 parent 70bd7aa commit 01ff8f5

File tree

8 files changed

+51
-21
lines changed

8 files changed

+51
-21
lines changed

src/components/Navbar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,4 @@ function Navbar({ scrollToFooter }: { scrollToFooter: any }) {
254254
);
255255
}
256256

257-
export default Navbar;
257+
export default Navbar;

src/components/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ const Sidebar: React.FC<{ steps: { title: string; link: string }[] }> = ({
4949
);
5050
};
5151

52-
export default Sidebar;
52+
export default Sidebar;

src/components/ToggleDarkMode.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const ToggleDarkMode: React.FC = () => {
1414
const handleChange = () => {
1515
toggleDarkMode();
1616
setIsDarkMode((prev) => !prev);
17+
const newTheme = !isDarkMode ? "dark" : "light";
18+
document.documentElement.setAttribute("data-theme", newTheme);
1719
};
1820

1921
return (

src/index.css

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,23 @@ body {
77
margin: 0;
88
padding: 0;
99
}
10+
11+
html[data-theme="dark"] {
12+
--bg-color: #121212;
13+
--text-color: #ffffff;
14+
--border-color: #444444;
15+
--active-bg-color: #333333;
16+
--active-text-color: #ffffff;
17+
--hover-bg-color: #444444;
18+
--hover-text-color: #ffffff;
19+
}
20+
21+
html[data-theme="light"] {
22+
--bg-color: #ffffff;
23+
--text-color: #121212;
24+
--border-color: #ddd;
25+
--active-bg-color: #e0e0e0;
26+
--active-text-color: #1b2540;
27+
--hover-bg-color: #e0e0e0;
28+
--hover-text-color: #050c40;
29+
}

src/pages/LearnNow.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import React from "react";
22
import { Outlet } from "react-router-dom";
33
import Sidebar from "../components/Sidebar";
4-
import { LearnNowContainer } from "../styles/pages/LearnNow";
4+
import { LearnNowContainer, SidebarContainer, ContentContainer } from "../styles/pages/LearnNow";
55
import { steps } from "../constants/learningSteps/steps";
66

77
const LearnNow: React.FC = () => {
88
return (
99
<LearnNowContainer>
10-
<Sidebar steps={steps} />
11-
<Outlet />
10+
<SidebarContainer>
11+
<Sidebar steps={steps} />
12+
</SidebarContainer>
13+
<ContentContainer>
14+
<Outlet />
15+
</ContentContainer>
1216
</LearnNowContainer>
1317
);
1418
};

src/styles/components/Content.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const ContentContainer = styled.div`
55
max-width: 900px;
66
width: 100%;
77
margin: 0 auto;
8-
background: #ffffff;
8+
background-color: var(--bg-color) !important;
99
border-radius: 8px;
1010
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
1111
box-sizing: border-box;
@@ -18,12 +18,13 @@ export const ContentContainer = styled.div`
1818
h6 {
1919
margin-top: 1em;
2020
margin-bottom: 0.5em;
21-
color: #333;
21+
color: var(--text-color) !important;
2222
}
2323
2424
p {
2525
line-height: 1.6;
2626
margin-bottom: 1em;
27+
color: var(--text-color) !important;
2728
}
2829
2930
a {
@@ -41,6 +42,7 @@ export const ContentContainer = styled.div`
4142
4243
li {
4344
margin-bottom: 0.5em;
45+
color: var(--text-color) !important;
4446
}
4547
}
4648

src/styles/components/Sidebar.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { NavLink } from "react-router-dom";
33

44
export const SidebarContainer = styled.div`
55
width: 260px;
6-
background-color: #f5f5f5;
6+
background-color: var(--bg-color) !important;
77
padding: 1rem;
88
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
99
border-radius: 4px;
1010
position: relative;
1111
overflow-y: auto;
12-
12+
border-right: 1px solid #ddd;
1313
@media (max-width: 768px) {
1414
width: 100%;
1515
height: auto;
@@ -21,7 +21,7 @@ export const SidebarTitle = styled.h2`
2121
font-size: 1.2rem;
2222
font-weight: 500;
2323
margin-bottom: 1rem;
24-
color: #333;
24+
color: var(--text-color) !important;
2525
`;
2626

2727
export const SidebarList = styled.ul`
@@ -41,19 +41,19 @@ export const SidebarLink = styled(NavLink)`
4141
border-radius: 4px;
4242
font-size: 0.95rem;
4343
font-weight: 600;
44-
color: #717171;
44+
color: var(--text-color) !important;
4545
transition: background-color 0.3s, color 0.3s;
4646
4747
&.active {
48-
background-color: #e0e0e0;
49-
color: #1b2540;
48+
background-color: var(--active-bg-color) !important;
49+
color: var(--active-text-color) !important;
5050
font-weight: 600;
5151
border-left: 2.5px solid #19c6c7;
5252
}
5353
5454
&:hover {
55-
background-color: #e0e0e0;
56-
color: #050c40;
55+
background-color: var(--hover-bg-color) !important;
56+
color: var(--hover-text-color) !important;
5757
text-decoration: underline;
5858
}
5959
`;
@@ -81,7 +81,7 @@ export const HelperText = styled.div`
8181
color: #333;
8282
8383
a {
84-
color: #19c6c7;
84+
color: #19c6c7 !important;
8585
text-decoration: none;
8686
8787
&:hover {
@@ -98,4 +98,4 @@ export const DividerLine = styled.div`
9898
height: 1px;
9999
background-color: #ddd;
100100
margin: 7rem 0 1rem 0;
101-
`;
101+
`;

src/styles/pages/LearnNow.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export const LearnNowContainer = styled.div`
66

77
export const SidebarContainer = styled.div`
88
width: 250px;
9-
background-color: #f4f4f4;
10-
padding: 20px;
11-
border-right: 1px solid #ddd;
9+
background-color: var(--bg-color) !important;
10+
padding: 0;
11+
border-right: 1px solid var(--border-color) !important;
1212
1313
h2 {
1414
margin-top: 0;
@@ -25,11 +25,13 @@ export const SidebarContainer = styled.div`
2525
2626
a {
2727
text-decoration: none;
28-
color: #333;
28+
color: var(--text-color) !important;
2929
}
3030
`;
3131

3232
export const ContentContainer = styled.div`
3333
flex: 1;
3434
padding: 20px;
35+
background-color: var(--bg-color) !important;
36+
color: var(--text-color) !important;
3537
`;

0 commit comments

Comments
 (0)