-
Notifications
You must be signed in to change notification settings - Fork 649
Expand file tree
/
Copy pathindex.jsx
More file actions
76 lines (58 loc) · 1.88 KB
/
index.jsx
File metadata and controls
76 lines (58 loc) · 1.88 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import { useMemo } from 'react';
import useMediaQuery from '@mui/material/useMediaQuery';
import AppBar from '@mui/material/AppBar';
import Toolbar from '@mui/material/Toolbar';
import AppBarStyled from './AppBarStyled';
import HeaderContent from './HeaderContent';
import IconButton from 'components/@extended/IconButton';
import { handlerDrawerOpen, useGetMenuMaster } from 'api/menu';
import { DRAWER_WIDTH, MINI_DRAWER_WIDTH } from 'config';
import MenuFoldOutlined from '@ant-design/icons/MenuFoldOutlined';
import MenuUnfoldOutlined from '@ant-design/icons/MenuUnfoldOutlined';
export default function Header() {
const downLG = useMediaQuery((theme) => theme.breakpoints.down('lg'));
const { menuMaster } = useGetMenuMaster();
const drawerOpen = menuMaster.isDashboardDrawerOpened;
const headerContent = useMemo(() => <HeaderContent />, []);
const mainHeader = (
<Toolbar>
<IconButton
aria-label="open drawer"
onClick={() => handlerDrawerOpen(!drawerOpen)}
edge="start"
color="secondary"
variant="light"
sx={(theme) => ({
color: 'text.primary',
bgcolor: drawerOpen ? 'transparent' : 'grey.100',
ml: { xs: 0, lg: -2 }
})}
>
{!drawerOpen ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
</IconButton>
{headerContent}
</Toolbar>
);
const appBar = {
position: 'fixed',
color: 'inherit',
elevation: 0,
sx: {
borderBottom: '1px solid',
borderBottomColor: 'divider',
zIndex: 1200,
width: { xs: '100%', lg: drawerOpen ? `calc(100% - ${DRAWER_WIDTH}px)` : `calc(100% - ${MINI_DRAWER_WIDTH}px)` }
}
};
return (
<>
{!downLG ? (
<AppBarStyled open={drawerOpen} {...appBar}>
{mainHeader}
</AppBarStyled>
) : (
<AppBar {...appBar}>{mainHeader}</AppBar>
)}
</>
);
}