Skip to content

Commit e5cf7c3

Browse files
authored
Merge pull request #26 from SudharsanSaravanan/fix/theme-toggle-mobile
Add mobile theme toggle to Navbar, closes #25
2 parents a69b869 + 127bfc3 commit e5cf7c3

1 file changed

Lines changed: 14 additions & 31 deletions

File tree

frontend/src/components/Layout/Navbar.jsx

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,8 @@ const Navbar = ({ theme, onThemeChange }) => {
8484
<nav className={`
8585
fixed top-0 left-0 right-0 z-50 transition-all duration-200
8686
${isScrolled
87-
? `backdrop-blur-xl border-b ${
88-
isDark
89-
? 'bg-gray-900/80 border-gray-800'
90-
: 'bg-white/80 border-gray-200'
91-
}`
92-
: `backdrop-blur-sm ${
93-
isDark
94-
? 'bg-gray-900/40 border-gray-800/40'
95-
: 'bg-white/40 border-gray-200/40'
96-
} border-b`
87+
? `backdrop-blur-xl border-b ${isDark ? 'bg-gray-900/80 border-gray-800' : 'bg-white/80 border-gray-200'}`
88+
: `backdrop-blur-sm ${isDark ? 'bg-gray-900/40 border-gray-800/40' : 'bg-white/40 border-gray-200/40'} border-b`
9789
}
9890
`}>
9991
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
@@ -108,10 +100,7 @@ const Navbar = ({ theme, onThemeChange }) => {
108100
transition-colors duration-200 focus-visible:outline-none
109101
focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2
110102
rounded-lg px-2 py-1
111-
${isDark
112-
? 'text-white hover:text-blue-400 focus-visible:ring-offset-gray-900'
113-
: 'text-gray-900 hover:text-blue-600 focus-visible:ring-offset-white'
114-
}
103+
${isDark ? 'text-white hover:text-blue-400 focus-visible:ring-offset-gray-900' : 'text-gray-900 hover:text-blue-600 focus-visible:ring-offset-white'}
115104
`}
116105
>
117106
<div className={`
@@ -137,10 +126,7 @@ const Navbar = ({ theme, onThemeChange }) => {
137126
focus-visible:ring-blue-500 focus-visible:ring-offset-2
138127
${isActive(path)
139128
? 'bg-blue-600 text-white'
140-
: (isDark
141-
? 'text-gray-300 hover:text-white hover:bg-gray-700'
142-
: 'text-gray-700 hover:text-gray-900 hover:bg-gray-100'
143-
)
129+
: (isDark ? 'text-gray-300 hover:text-white hover:bg-gray-700' : 'text-gray-700 hover:text-gray-900 hover:bg-gray-100')
144130
}
145131
`}
146132
>
@@ -165,10 +151,7 @@ const Navbar = ({ theme, onThemeChange }) => {
165151
p-2 rounded-lg transition-colors duration-200
166152
focus-visible:outline-none focus-visible:ring-2
167153
focus-visible:ring-blue-500 focus-visible:ring-offset-2
168-
${isDark
169-
? 'hover:bg-gray-800 text-gray-300 hover:text-white focus-visible:ring-offset-gray-900'
170-
: 'hover:bg-gray-100 text-gray-600 hover:text-gray-900 focus-visible:ring-offset-white'
171-
}
154+
${isDark ? 'hover:bg-gray-800 text-gray-300 hover:text-white focus-visible:ring-offset-gray-900' : 'hover:bg-gray-100 text-gray-600 hover:text-gray-900 focus-visible:ring-offset-white'}
172155
`}
173156
>
174157
{isMenuOpen ? <X className="h-6 w-6" /> : <Menu className="h-6 w-6" />}
@@ -179,10 +162,7 @@ const Navbar = ({ theme, onThemeChange }) => {
179162

180163
{/* Mobile menu */}
181164
{isMenuOpen && (
182-
<div className={`
183-
md:hidden border-t backdrop-blur-xl
184-
${isDark ? 'bg-gray-900/95 border-gray-800' : 'bg-white/95 border-gray-200'}
185-
`}>
165+
<div className={`md:hidden border-t backdrop-blur-xl ${isDark ? 'bg-gray-900/95 border-gray-800' : 'bg-white/95 border-gray-200'}`}>
186166
<div className="px-4 py-3 space-y-1">
187167
{navItems.map(({ path, label, icon: Icon }) => (
188168
<Link
@@ -194,18 +174,21 @@ const Navbar = ({ theme, onThemeChange }) => {
194174
focus-visible:outline-none focus-visible:ring-2
195175
focus-visible:ring-blue-500 focus-visible:ring-offset-2
196176
${isDark
197-
? `hover:bg-gray-800 focus-visible:ring-offset-gray-900
198-
${isActive(path) ? 'bg-gray-800 text-white' : 'text-gray-300'}`
199-
: `hover:bg-gray-100 focus-visible:ring-offset-white
200-
${isActive(path) ? 'bg-gray-100 text-gray-900' : 'text-gray-600'}`
177+
? `hover:bg-gray-800 focus-visible:ring-offset-gray-900 ${isActive(path) ? 'bg-gray-800 text-white' : 'text-gray-300'}`
178+
: `hover:bg-gray-100 focus-visible:ring-offset-white ${isActive(path) ? 'bg-gray-100 text-gray-900' : 'text-gray-600'}`
201179
}
202180
`}
203181
>
204182
<Icon className="h-4 w-4" />
205183
<span className="text-sm font-medium">{label}</span>
206184
</Link>
207185
))}
208-
186+
187+
{/* Theme toggle for mobile */}
188+
<div className="px-3 py-2">
189+
<ThemeToggle theme={theme} onToggle={onThemeChange} />
190+
</div>
191+
209192
{/* Mobile CTA */}
210193
<div className="pt-3 mt-3 border-t border-gray-700">
211194
<Link

0 commit comments

Comments
 (0)