1
1
import { useState } from "react" ;
2
2
import { Link , useLocation , useNavigate } from "react-router-dom" ;
3
3
4
- import CloseIcon from "@mui/icons-material/Close" ;
5
4
import LanguageIcon from '@mui/icons-material/Language' ;
6
5
import MenuIcon from "@mui/icons-material/Menu" ;
7
6
import NightlightIcon from "@mui/icons-material/Nightlight" ;
8
7
import WbSunnyIcon from "@mui/icons-material/WbSunny" ;
9
8
import {
10
9
Box ,
11
10
Button ,
12
- Divider ,
13
11
Drawer ,
14
12
IconButton ,
15
13
List ,
16
14
ListItem ,
17
15
ListItemText ,
18
16
Menu ,
19
- MenuItem ,
17
+ MenuItem
20
18
} from "@mui/material" ;
21
19
import { useTranslation } from "react-i18next" ;
22
20
@@ -124,42 +122,42 @@ const NavigationBar: React.FC<{
124
122
125
123
{ /* Login/Logout and Toggle Buttons */ }
126
124
< 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 >
127
159
{ isLoggedIn ? (
128
160
< >
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 >
163
161
< Button
164
162
component = { Link }
165
163
to = "/profile"
@@ -221,7 +219,7 @@ const NavigationBar: React.FC<{
221
219
222
220
{ /* Hamburger Menu for Mobile */ }
223
221
< IconButton
224
- onClick = { ( ) => setMobileMenuOpen ( true ) }
222
+ onClick = { ( ) => setMobileMenuOpen ( prev => ! prev ) }
225
223
sx = { { color : "text.primary" , display : { xs : "block" , md : "none" } } }
226
224
>
227
225
< MenuIcon />
@@ -238,16 +236,10 @@ const NavigationBar: React.FC<{
238
236
width : "60vw" ,
239
237
maxWidth : "300px" ,
240
238
backgroundColor : "background.default" ,
239
+ marginTop : 9 ,
241
240
} ,
242
241
} }
243
242
>
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 />
251
243
< List >
252
244
{ /* Documentation */ }
253
245
< ListItem
@@ -311,20 +303,31 @@ const NavigationBar: React.FC<{
311
303
< ListItemText primary = { t ( "navigation_bar.community.discord" ) } />
312
304
</ ListItem >
313
305
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
+ ) }
328
331
</ List >
329
332
</ Drawer >
330
333
</ Box >
0 commit comments