Skip to content

Commit f8c53ea

Browse files
committed
fix: Fix missing buttons in navigation bar
1 parent 77d5d7c commit f8c53ea

File tree

1 file changed

+62
-59
lines changed

1 file changed

+62
-59
lines changed

src/components/NavigationBar/NavigationBar.tsx

Lines changed: 62 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
import { useState } from "react";
22
import { Link, useLocation, useNavigate } from "react-router-dom";
33

4-
import CloseIcon from "@mui/icons-material/Close";
54
import LanguageIcon from '@mui/icons-material/Language';
65
import MenuIcon from "@mui/icons-material/Menu";
76
import NightlightIcon from "@mui/icons-material/Nightlight";
87
import WbSunnyIcon from "@mui/icons-material/WbSunny";
98
import {
109
Box,
1110
Button,
12-
Divider,
1311
Drawer,
1412
IconButton,
1513
List,
1614
ListItem,
1715
ListItemText,
1816
Menu,
19-
MenuItem,
17+
MenuItem
2018
} from "@mui/material";
2119
import { useTranslation } from "react-i18next";
2220

@@ -124,42 +122,42 @@ const NavigationBar: React.FC<{
124122

125123
{/* Login/Logout and Toggle Buttons */}
126124
<Box sx={{ display: "flex", alignItems: "center", gap: 2 }}>
125+
{/* Community Dropdown */}
126+
<Box>
127+
<Button
128+
onClick={(event) => {
129+
if (communityMenuAnchor) {
130+
setCommunityMenuAnchor(null);
131+
} else {
132+
setCommunityMenuAnchor(event.currentTarget)
133+
}
134+
}}
135+
sx={{ color: "text.primary", textTransform: "capitalize" }}
136+
>
137+
{t("navigation_bar.community")}
138+
</Button>
139+
<Menu
140+
anchorEl={communityMenuAnchor}
141+
open={Boolean(communityMenuAnchor)}
142+
onClose={() => setCommunityMenuAnchor(null)}
143+
sx={{ mt: 1, zIndex: 9001 }}
144+
>
145+
<MenuItem onClick={() => {
146+
window.open(Endpoints.projectRepoUrl);
147+
setCommunityMenuAnchor(null);
148+
}}>
149+
{t("navigation_bar.community.github")}
150+
</MenuItem>
151+
<MenuItem onClick={() => {
152+
window.open(Endpoints.projectDiscordUrl);
153+
setCommunityMenuAnchor(null);
154+
}}>
155+
{t("navigation_bar.community.discord")}
156+
</MenuItem>
157+
</Menu>
158+
</Box>
127159
{isLoggedIn ? (
128160
<>
129-
{/* Community Dropdown */}
130-
<Box>
131-
<Button
132-
onClick={(event) => {
133-
if (communityMenuAnchor) {
134-
setCommunityMenuAnchor(null);
135-
} else {
136-
setCommunityMenuAnchor(event.currentTarget)
137-
}
138-
}}
139-
sx={{ color: "text.primary", textTransform: "capitalize" }}
140-
>
141-
{t("navigation_bar.community")}
142-
</Button>
143-
<Menu
144-
anchorEl={communityMenuAnchor}
145-
open={Boolean(communityMenuAnchor)}
146-
onClose={() => setCommunityMenuAnchor(null)}
147-
sx={{ mt: 1, zIndex: 9001 }}
148-
>
149-
<MenuItem onClick={() => {
150-
window.open(Endpoints.projectRepoUrl);
151-
setCommunityMenuAnchor(null);
152-
}}>
153-
{t("navigation_bar.community.github")}
154-
</MenuItem>
155-
<MenuItem onClick={() => {
156-
window.open(Endpoints.projectDiscordUrl);
157-
setCommunityMenuAnchor(null);
158-
}}>
159-
{t("navigation_bar.community.discord")}
160-
</MenuItem>
161-
</Menu>
162-
</Box>
163161
<Button
164162
component={Link}
165163
to="/profile"
@@ -221,7 +219,7 @@ const NavigationBar: React.FC<{
221219

222220
{/* Hamburger Menu for Mobile */}
223221
<IconButton
224-
onClick={() => setMobileMenuOpen(true)}
222+
onClick={() => setMobileMenuOpen(prev => !prev)}
225223
sx={{ color: "text.primary", display: { xs: "block", md: "none" } }}
226224
>
227225
<MenuIcon />
@@ -238,16 +236,10 @@ const NavigationBar: React.FC<{
238236
width: "60vw",
239237
maxWidth: "300px",
240238
backgroundColor: "background.default",
239+
marginTop: 9,
241240
},
242241
}}
243242
>
244-
<Box sx={{ p: 2, display: "flex", justifyContent: "space-between", alignItems: "center" }}>
245-
<Box component="img" src={logo} alt="Logo" sx={{ width: 32, height: 32 }} />
246-
<IconButton onClick={() => setMobileMenuOpen(false)}>
247-
<CloseIcon />
248-
</IconButton>
249-
</Box>
250-
<Divider />
251243
<List>
252244
{/* Documentation */}
253245
<ListItem
@@ -311,20 +303,31 @@ const NavigationBar: React.FC<{
311303
<ListItemText primary={t("navigation_bar.community.discord")} />
312304
</ListItem>
313305

314-
<ListItem
315-
component={Link}
316-
to="/profile"
317-
onClick={() => setMobileMenuOpen(false)}
318-
sx={{ cursor: "pointer" }}
319-
>
320-
<ListItemText primary={t("navigation_bar.profile")} />
321-
</ListItem>
322-
<ListItem
323-
onClick={handleLogout}
324-
sx={{ cursor: "pointer" }}
325-
>
326-
<ListItemText primary={t("navigation_bar.logout")} />
327-
</ListItem>
306+
{isLoggedIn ? (
307+
<>
308+
<ListItem
309+
component={Link}
310+
to="/profile"
311+
onClick={() => setMobileMenuOpen(false)}
312+
sx={{ cursor: "pointer" }}
313+
>
314+
<ListItemText primary={t("navigation_bar.profile")} />
315+
</ListItem>
316+
<ListItem
317+
onClick={handleLogout}
318+
sx={{ cursor: "pointer" }}
319+
>
320+
<ListItemText primary={t("navigation_bar.logout")} />
321+
</ListItem>
322+
</>
323+
) : (
324+
<ListItem
325+
onClick={() => handleLogin()}
326+
sx={{ cursor: "pointer" }}
327+
>
328+
<ListItemText primary={t("navigation_bar.login")} />
329+
</ListItem>
330+
)}
328331
</List>
329332
</Drawer>
330333
</Box>

0 commit comments

Comments
 (0)