blob: d8510c7cd5abaec4827ccd419b9f8aa2514f6e3a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
import React from 'react';
import { useContext, useState } from 'react';
import { Link } from 'react-router-dom';
import { Button, IconButton, Menu, MenuItem } from '@mui/material';
import DarkModeIcon from '@mui/icons-material/DarkMode';
import LightModeIcon from '@mui/icons-material/LightMode';
import { useTheme } from '@mui/material/styles';
import { ThemeContext } from '../AppThemeProvider';
import MenuIcon from '@mui/icons-material/Menu';
import pages from '../pages';
function Mobile() {
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
const theme = useTheme();
const { toggleColorMode } = useContext(ThemeContext);
const handleOpenNavMenu = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};
const handleCloseNavMenu = () => {
setAnchorEl(null);
};
return (
<div style={{ marginLeft: 'auto' }}>
<IconButton color="inherit" onClick={toggleColorMode}>
{theme.palette.mode === 'dark' ? <DarkModeIcon /> : <LightModeIcon />}
</IconButton>
<IconButton color="inherit" onClick={handleOpenNavMenu}>
<MenuIcon />
</IconButton>
<Menu anchorEl={anchorEl} open={!!anchorEl} onClose={handleCloseNavMenu}>
{pages.map((page) => (
<MenuItem key={page.name} onClick={handleCloseNavMenu}>
<Button
color="inherit"
component={Link}
to={page?.to}
key={page?.name}
>
{page?.name}
</Button>
</MenuItem>
))}
</Menu>
</div>
);
}
export default Mobile;
|