Skip to content

Commit ff74407

Browse files
committed
fix theme icon not updating synched
1 parent 0d1b055 commit ff74407

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const App: React.FC = () => {
5959
// Define Navbar wrapper
6060
const NavbarWrapper = () => (
6161
<div>
62-
<NavigationBar isDarkMode={isDarkMode} toggleTheme={toggleTheme} />
62+
<NavigationBar toggleTheme={toggleTheme} />
6363
<Outlet />
6464
</div>
6565
);

src/components/NavigationBar/NavigationBar.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {
1414
ListItem,
1515
ListItemText,
1616
Menu,
17-
MenuItem
17+
MenuItem,
18+
useTheme
1819
} from "@mui/material";
1920
import { useTranslation } from "react-i18next";
2021

@@ -31,14 +32,11 @@ import { galleryApiFetch } from "@/utils";
3132
/**
3233
* Contains commonly accessed items pinned at the top.
3334
*
34-
* @param isDarkMode boolean indicating if the website is in dark mode
3535
* @param toggleTheme toggles the theme of the website (light/dark)
3636
*/
3737
const NavigationBar: React.FC<{
38-
isDarkMode: boolean;
3938
toggleTheme: () => void
4039
}> = ({
41-
isDarkMode,
4240
toggleTheme
4341
}) => {
4442
// lazy loads translations
@@ -52,6 +50,7 @@ const NavigationBar: React.FC<{
5250
const [languageMenuAnchor, setLanguageMenuAnchor] = useState<null | HTMLElement>(null);
5351
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
5452
const [communityMenuAnchor, setCommunityMenuAnchor] = useState<null | HTMLElement>(null);
53+
const theme = useTheme()
5554

5655
const handleLogout = async () => {
5756
setIsLoggedIn(false);
@@ -223,7 +222,7 @@ const NavigationBar: React.FC<{
223222

224223
{/* Theme Toggle Button */}
225224
<IconButton onClick={toggleTheme} sx={{ color: "text.primary" }}>
226-
{isDarkMode ? <NightlightIcon /> : <WbSunnyIcon />}
225+
{theme.palette.mode === 'dark' ? <NightlightIcon /> : <WbSunnyIcon />}
227226
</IconButton>
228227

229228
{/* Hamburger Menu for Mobile */}

0 commit comments

Comments
 (0)