|
3 | 3 | * See the LICENSE file in the repository root folder for details. |
4 | 4 | */ |
5 | 5 |
|
6 | | -import AppBar from '@mui/material/AppBar'; |
7 | 6 | import Box from '@mui/material/Box'; |
8 | 7 | import Toolbar from '@mui/material/Toolbar'; |
9 | 8 | import Typography from '@mui/material/Typography'; |
10 | 9 | import { Link } from 'react-router-dom'; |
11 | 10 | import { routes } from '../../utils/routes'; |
12 | | -import { useAuth } from '../../hooks/auth.hooks'; |
13 | 11 | import { fullNamePipe } from '../../utils/pipes'; |
14 | 12 | import NavUserMenu from './NavUserMenu'; |
| 13 | +import NERAppBar from '../../components/NERAppBar'; |
| 14 | +import { LayoutProps } from '../LayoutProps'; |
| 15 | +import { IconButton } from '@mui/material'; |
| 16 | +import { GridMenuIcon } from '@mui/x-data-grid'; |
| 17 | +import { useCurrentUser } from '../../hooks/users.hooks'; |
15 | 18 |
|
16 | 19 | const textColor = 'white'; |
17 | 20 | const background = '#ef4345'; |
18 | 21 |
|
19 | | -const NavTopBar: React.FC = () => { |
20 | | - const auth = useAuth(); |
| 22 | +interface NavTopBarProps extends LayoutProps { |
| 23 | + handleDrawerOpen: () => void; |
| 24 | +} |
| 25 | + |
| 26 | +const NavTopBar: React.FC<NavTopBarProps> = ({ open, handleDrawerOpen }) => { |
| 27 | + const user = useCurrentUser(); |
21 | 28 | return ( |
22 | | - <Box sx={{ flexGrow: 1 }}> |
23 | | - <AppBar position="fixed"> |
24 | | - <Toolbar disableGutters sx={{ height: 68, px: 1, background, color: textColor }}> |
25 | | - <Box sx={{ flexGrow: 1 }}> |
26 | | - <Link to={routes.HOME} style={{ textDecoration: 'none' }}> |
27 | | - <Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}> |
28 | | - <Box |
29 | | - component="img" |
30 | | - sx={{ height: 60 }} |
31 | | - alt="Northeastern Electric Racing Logo" |
32 | | - src="/NER-Logo-App-Icon.png" |
33 | | - /> |
34 | | - <Typography |
35 | | - variant="h4" |
36 | | - fontSize={30} |
37 | | - component="div" |
38 | | - sx={{ flexGrow: 1, paddingLeft: 2, color: textColor }} |
39 | | - > |
40 | | - FinishLine by NER |
41 | | - </Typography> |
42 | | - </Box> |
43 | | - </Link> |
44 | | - </Box> |
45 | | - <Typography variant="body1" component="div" sx={{ color: textColor }}> |
46 | | - {fullNamePipe(auth.user)} |
47 | | - </Typography> |
48 | | - <NavUserMenu /> |
49 | | - </Toolbar> |
50 | | - </AppBar> |
51 | | - </Box> |
| 29 | + <NERAppBar position="fixed" open={open}> |
| 30 | + <Toolbar disableGutters sx={{ height: 68, px: 1, background, color: textColor }}> |
| 31 | + <IconButton |
| 32 | + color="inherit" |
| 33 | + aria-label="open drawer" |
| 34 | + onClick={handleDrawerOpen} |
| 35 | + sx={{ |
| 36 | + marginRight: 4, |
| 37 | + ml: '3px', |
| 38 | + ...(open && { display: 'none' }) |
| 39 | + }} |
| 40 | + > |
| 41 | + <GridMenuIcon /> |
| 42 | + </IconButton> |
| 43 | + <Box sx={{ flexGrow: 1 }}> |
| 44 | + <Link to={routes.HOME} style={{ textDecoration: 'none' }}> |
| 45 | + <Box sx={{ display: 'flex', flexDirection: 'row', alignItems: 'center' }}> |
| 46 | + <Box |
| 47 | + component="img" |
| 48 | + sx={{ height: 60 }} |
| 49 | + alt="Northeastern Electric Racing Logo" |
| 50 | + src="/NER-Logo-App-Icon.png" |
| 51 | + /> |
| 52 | + <Typography variant="h4" fontSize={30} component="div" sx={{ flexGrow: 1, paddingLeft: 2, color: textColor }}> |
| 53 | + FinishLine by NER |
| 54 | + </Typography> |
| 55 | + </Box> |
| 56 | + </Link> |
| 57 | + </Box> |
| 58 | + <Typography |
| 59 | + variant="body1" |
| 60 | + sx={{ |
| 61 | + color: textColor, |
| 62 | + '@media (max-width: 600px)': { |
| 63 | + display: 'none' // Hide the text on screens with width less than 600 pixels |
| 64 | + } |
| 65 | + }} |
| 66 | + > |
| 67 | + {fullNamePipe(user)} |
| 68 | + </Typography> |
| 69 | + <NavUserMenu /> |
| 70 | + </Toolbar> |
| 71 | + </NERAppBar> |
52 | 72 | ); |
53 | 73 | }; |
54 | 74 |
|
|
0 commit comments