-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathVirtoAppHeader.tsx
174 lines (167 loc) · 4.55 KB
/
VirtoAppHeader.tsx
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import {
AppBar,
Box,
Drawer,
IconButton,
Link,
Toolbar,
Typography
} from "@mui/material";
import React, { Fragment, useState } from "react";
import AppLauncher from "../AppLauncher";
import AppsIcon from "@mui/icons-material/Apps";
import Menu from "@mui/icons-material/Menu";
import { Theme } from "@mui/material/styles";
import ToggleColorMode from "../ToggleColorMode";
import UserMenu from "../UserMenu";
import { VirtoAppHeaderProps } from "./VirtoAppHeader.types";
import VirtoLogo from "../SvgIcons/VirtoLogo";
// appbar component
function Header({
appName,
mode,
onAppClick,
onColourModeChange,
onChangePassword,
onLogout,
onMenuClick,
username,
virtoLogoLinkUrl
}: VirtoAppHeaderProps) {
return (
<AppBar
sx={theme => ({
backgroundColor: theme.palette.primary.main
})}
>
<Toolbar style={{ justifyContent: "space-between" }}>
<Box display="flex" alignItems="center">
<IconButton sx={{ pl: 0 }} onClick={onAppClick} disableRipple>
<AppsIcon
sx={theme => ({
color: theme.palette.background.paper,
fontSize: "30px"
})}
/>
</IconButton>
<IconButton
disableRipple
color="inherit"
data-testid="launcher-button"
edge="start"
onClick={onMenuClick}
sx={theme => ({
pl: 2.5,
[theme.breakpoints.up("md")]: {
display: "none"
}
})}
size="large"
>
<Menu
sx={theme => ({
color: theme.palette.background.paper,
fontSize: "30px"
})}
/>
</IconButton>
<Box ml={1} display="flex" alignItems="center">
<Link href={virtoLogoLinkUrl} underline="none" display="flex">
<VirtoLogo
data-testid="virto-logo"
sx={{
color: (theme: Theme) =>
theme.palette.mode === "dark" ? "#003063" : "white",
height: 22,
mr: 0.4,
width: 110
}}
/>
</Link>
<Typography
variant="h6"
fontSize="28px"
lineHeight="34px"
letterSpacing="0.05em"
textTransform="uppercase"
fontWeight="700"
color={theme =>
theme.palette.mode === "dark" ? "#003063" : "white"
}
>
{`.`}
<span style={{ marginLeft: "7px" }}>{appName}</span>
</Typography>
</Box>
</Box>
<Box display="flex" alignItems="center">
<ToggleColorMode mode={mode} onChange={onColourModeChange} />
<UserMenu
username={username}
onChangePassword={onChangePassword}
onLogout={onLogout}
/>
</Box>
</Toolbar>
</AppBar>
);
}
// app header component
function VirtoAppHeader({
appName,
baseUrl,
mode,
onChangePassword,
onLogout,
onMenuClick,
onColourModeChange,
username,
virtoLogoLinkUrl = ""
}: VirtoAppHeaderProps) {
// sidebar styling
const applancherWidth = 300;
// define state for managing app launcher
const [appOpen, setAppOpen] = useState(false);
// handle click event
const handleMenuClick =
(cb: (event: React.MouseEvent<HTMLElement>) => void) =>
(event: React.MouseEvent<HTMLElement>) => {
cb(event);
};
return (
<Fragment>
<Header
appName={appName}
mode={mode}
onAppClick={() => setAppOpen(!appOpen)}
onColourModeChange={onColourModeChange}
onChangePassword={onChangePassword}
onLogout={onLogout}
onMenuClick={handleMenuClick(onMenuClick)}
username={username}
virtoLogoLinkUrl={virtoLogoLinkUrl}
/>
<Drawer
variant="temporary"
anchor="left"
data-testid="app-launcher"
open={appOpen}
onClose={() => setAppOpen(false)}
sx={{
"& .MuiDrawer-paper": {
height: theme => `calc(100% - ${theme.mixins.toolbar.minHeight}px)`,
top: theme => theme.mixins.toolbar.minHeight,
width: applancherWidth
}
}}
>
<AppLauncher
baseUrl={baseUrl}
logoLinkUrl={virtoLogoLinkUrl}
onAppButtonClick={() => setAppOpen(false)}
/>
</Drawer>
</Fragment>
);
}
export default VirtoAppHeader;