1
1
import * as React from 'react' ;
2
+ import { Link } from "react-router-dom"
2
3
import AppBar from '@mui/material/AppBar' ;
3
4
import Box from '@mui/material/Box' ;
4
5
import Toolbar from '@mui/material/Toolbar' ;
5
6
import IconButton from '@mui/material/IconButton' ;
6
7
import Typography from '@mui/material/Typography' ;
7
8
import Menu from '@mui/material/Menu' ;
8
9
import MenuIcon from '@mui/icons-material/Menu' ;
9
- import Container from '@mui/material/Container' ;
10
10
import Avatar from '@mui/material/Avatar' ;
11
- import Button from '@mui/material/Button' ;
12
11
import Tooltip from '@mui/material/Tooltip' ;
13
12
import MenuItem from '@mui/material/MenuItem' ;
14
- import AdbIcon from '@mui/icons-material/Adb' ;
15
13
import AppLogo from '../images/app-icon.svg?react'
16
- import { APP_LOGO_TEXT , APP_URL_Home , DEFAULT_SIZE_1_REM , DEFAULT_SIZE_0_5_REM } from '../constants/general' ;
14
+ import { APP_LOGO_TEXT , DEFAULT_SIZE_1_REM , DEFAULT_SIZE_0_5_REM , APP_URL_Home } from '../constants/general' ;
17
15
import { useAppDispatch , useAppSelector } from '../redux/hooks/hooks' ;
18
16
import { GlobalState } from '../redux/states/GlobalState' ;
19
17
import { firstLetter , LinkButton } from '../utils/utils' ;
20
18
import ThemeChooser from './ThemeChooser' ;
21
- import { Link , useNavigate } from 'react-router-dom' ;
19
+ import { useNavigate } from 'react-router-dom' ;
22
20
import { useTheme } from '@mui/material' ;
23
21
24
22
export interface AppBarItem {
25
23
hidden ?: boolean ,
26
24
label : string ,
25
+ selected ?: boolean ,
27
26
icon ?: JSX . Element ,
28
27
url ?: string ,
29
- selected ?: boolean ,
30
28
onClick ?: ( ) => void ,
31
29
}
32
30
33
31
function ResponsiveAppBar ( props : {
34
32
pages : AppBarItem [ ] ,
35
- settings : AppBarItem [ ]
33
+ settings : AppBarItem [ ]
36
34
} ) {
37
35
const global = useAppSelector < GlobalState > ( ( state ) => state . global )
38
36
const dispatch = useAppDispatch ( )
@@ -69,27 +67,29 @@ function ResponsiveAppBar(props: {
69
67
DESKTOP LOGO
70
68
-----------------------------------------------------------------------
71
69
*/ }
72
- < Box
73
- sx = { {
74
- display : 'flex' ,
70
+ { global . isMobile === false && < div
71
+ onClick = { ( ) => navigate ( APP_URL_Home ) }
72
+ style = { {
73
+ display : 'flex' ,
74
+ cursor : 'pointer'
75
75
} } >
76
76
77
- < LinkButton
78
- LinkComponent = { Link }
79
- to = { APP_URL_Home }
80
- sx = { {
81
- display : { xs : 'none' , md : 'flex' } ,
82
- mr : 2
83
- } } >
77
+ < Link
78
+ style = { {
79
+ // display: { xs: 'none', md: 'flex' },
80
+ marginRight : DEFAULT_SIZE_0_5_REM
81
+ } }
82
+ to = { APP_URL_Home } >
84
83
< AppLogo width = '100%' height = '50px' />
85
- </ LinkButton >
84
+ </ Link >
86
85
87
86
{ APP_LOGO_TEXT && < Typography
88
87
variant = "h6"
89
88
noWrap
90
89
sx = { {
91
90
mr : 2 ,
92
- display : { xs : 'none' , md : 'flex' } ,
91
+ display : 'flex' ,
92
+ // display: { xs: 'none', md: 'flex' },
93
93
alignSelf : 'center' ,
94
94
fontFamily : 'monospace' ,
95
95
fontWeight : 700 ,
@@ -100,18 +100,19 @@ function ResponsiveAppBar(props: {
100
100
>
101
101
{ APP_LOGO_TEXT }
102
102
</ Typography > }
103
- </ Box >
103
+ </ div > }
104
104
105
105
{ /*
106
106
-----------------------------------------------------------------------
107
107
DESKTOP MENU
108
108
-----------------------------------------------------------------------
109
109
*/ }
110
- < Box sx = { {
110
+ { global . isMobile === false && < Box sx = { {
111
111
flexGrow : 1 ,
112
- display : { xs : 'none' , md : ' flex' }
112
+ display : ' flex'
113
113
} } >
114
114
{ pages . filter ( w => w . hidden !== true ) . map ( ( page , pageIdx ) => (
115
+
115
116
< LinkButton
116
117
LinkComponent = { Link }
117
118
to = { page . url ?? '' }
@@ -129,14 +130,14 @@ function ResponsiveAppBar(props: {
129
130
</ Typography >
130
131
</ LinkButton >
131
132
) ) }
132
- </ Box >
133
+ </ Box > }
133
134
134
135
{ /*
135
136
-----------------------------------------------------------------------
136
137
MOBILE MENU
137
138
-----------------------------------------------------------------------
138
139
*/ }
139
- < Box sx = { { flexGrow : 0 , display : { xs : 'flex' , md : 'none' } } } >
140
+ { global . isMobile && < Box sx = { { flexGrow : 0 , display : 'flex' , gap : DEFAULT_SIZE_0_5_REM , alignItems : 'center' } } >
140
141
< IconButton
141
142
size = "large"
142
143
aria-label = "account of current user"
@@ -147,6 +148,22 @@ function ResponsiveAppBar(props: {
147
148
>
148
149
< MenuIcon />
149
150
</ IconButton >
151
+
152
+ < IconButton
153
+ size = "large"
154
+ aria-label = "account of current user"
155
+ aria-controls = "menu-appbar"
156
+ aria-haspopup = "true"
157
+ onClick = { ( ) => navigate ( APP_URL_Home ) }
158
+ color = "inherit"
159
+ >
160
+ < Box sx = { {
161
+ display : 'flex' , gap : DEFAULT_SIZE_0_5_REM
162
+ } } >
163
+ < AppLogo width = '100%' height = '50px' />
164
+ </ Box >
165
+ </ IconButton >
166
+
150
167
< Menu
151
168
id = "menu-appbar"
152
169
anchorEl = { anchorElNav }
@@ -162,28 +179,34 @@ function ResponsiveAppBar(props: {
162
179
open = { Boolean ( anchorElNav ) }
163
180
onClose = { handleCloseNavMenu }
164
181
sx = { {
165
- display : { xs : 'block' , md : 'none' } ,
182
+ display : 'block'
183
+ // display: { xs: 'block', md: 'none' },
166
184
} }
167
185
>
168
186
{ pages . filter ( w => w . hidden !== true ) . map ( ( page , pageIdx ) => (
169
187
< MenuItem
170
188
key = { `mob-page-${ pageIdx } ` }
171
189
onClick = { ( ) => {
190
+ if ( page . url )
191
+ navigate ( page . url ?? '' )
172
192
page . onClick ?.( )
173
193
handleCloseNavMenu ( )
174
194
} } >
175
- < Typography textAlign = "center" > { page . label } </ Typography >
195
+ < Box sx = { { display : 'flex' , gap : DEFAULT_SIZE_0_5_REM } } >
196
+ { page . icon }
197
+ < Typography textAlign = "center" > { page . label } </ Typography >
198
+ </ Box >
176
199
</ MenuItem >
177
200
) ) }
178
201
</ Menu >
179
- </ Box >
202
+ </ Box > }
180
203
181
204
{ /*
182
205
-----------------------------------------------------------------------
183
206
MOBILE LOGO
184
207
-----------------------------------------------------------------------
185
208
*/ }
186
- < div
209
+ { global . isMobile && < div
187
210
onClick = { ( ) => navigate ( APP_URL_Home ) }
188
211
style = { {
189
212
display : 'flex' ,
@@ -194,36 +217,16 @@ function ResponsiveAppBar(props: {
194
217
< Box sx = { {
195
218
display : 'flex' ,
196
219
width : '100%' ,
197
- justifyContent : 'center '
220
+ justifyContent : 'flex-start '
198
221
} } >
199
222
200
223
< Box sx = { { display : 'flex' } } >
201
224
202
- < Box mr = { 1 } sx = { { display : { xs : 'flex' , md : 'none' } , mr : 1 } } >
203
- < AppLogo width = '100%' height = '50px' />
204
- </ Box >
205
-
206
- { APP_LOGO_TEXT && < Typography
207
- variant = "h5"
208
- noWrap
209
- sx = { {
210
- mr : 2 ,
211
- display : { xs : 'flex' , md : 'none' } ,
212
- alignSelf : 'center' ,
213
- fontFamily : 'monospace' ,
214
- fontWeight : 700 ,
215
- letterSpacing : '.3rem' ,
216
- color : 'inherit' ,
217
- textDecoration : 'none' ,
218
- } }
219
- >
220
- { APP_LOGO_TEXT }
221
- </ Typography > }
222
225
223
226
</ Box >
224
227
225
228
</ Box >
226
- </ div >
229
+ </ div > }
227
230
228
231
{ /*
229
232
-----------------------------------------------------------------------
@@ -232,6 +235,7 @@ function ResponsiveAppBar(props: {
232
235
*/ }
233
236
< Box sx = { { flexGrow : 0 } } >
234
237
< ThemeChooser />
238
+
235
239
< Tooltip title = "Open settings" >
236
240
< IconButton onClick = { handleOpenUserMenu } sx = { { p : 0 } } >
237
241
< Avatar >
@@ -272,7 +276,7 @@ function ResponsiveAppBar(props: {
272
276
</ Box >
273
277
</ Toolbar >
274
278
</ Box >
275
- </ AppBar >
279
+ </ AppBar >
276
280
) ;
277
281
}
278
282
export default ResponsiveAppBar ;
0 commit comments