@sikka/hawa 0.0.34 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/es/index.es.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +12 -9
- package/src/elements/AdaptiveButton.js +1 -1
- package/src/elements/DragDropImages.js +135 -143
- package/src/elements/DraggableCard.js +36 -0
- package/src/elements/HawaSelectInput.js +30 -0
- package/src/elements/HawaSnackbar.js +32 -3
- package/src/elements/index.js +2 -0
- package/src/index.js +1 -0
- package/src/layout/HawaAppLayout.js +197 -173
- package/src/layout/HawaAppLayout2.js +260 -0
- package/src/theme/HawaTheme.js +882 -0
- package/src/theme/index.js +2 -0
- package/storybook-static/0.a2c13f8ca8477800b11f.manager.bundle.js +2 -0
- package/storybook-static/{0.0d994c92.iframe.bundle.js.LICENSE.txt → 0.a2c13f8ca8477800b11f.manager.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/0.d94b248f.iframe.bundle.js +3 -0
- package/storybook-static/{4.0fcda1281dc1961dbe94.manager.bundle.js.LICENSE.txt → 0.d94b248f.iframe.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/0.d94b248f.iframe.bundle.js.map +1 -0
- package/storybook-static/1.37f89487.iframe.bundle.js +1 -0
- package/storybook-static/1.d522251f2377f7751924.manager.bundle.js +1 -0
- package/storybook-static/{2.430bf1e3.iframe.bundle.js → 2.89943a03.iframe.bundle.js} +1 -1
- package/storybook-static/5.a331b0a36ded1c541923.manager.bundle.js +2 -0
- package/storybook-static/5.a331b0a36ded1c541923.manager.bundle.js.LICENSE.txt +31 -0
- package/storybook-static/6.3a1fb0c3.iframe.bundle.js +3 -0
- package/storybook-static/6.3a1fb0c3.iframe.bundle.js.LICENSE.txt +31 -0
- package/storybook-static/6.3a1fb0c3.iframe.bundle.js.map +1 -0
- package/storybook-static/6.aee6c4935c69d480fc0d.manager.bundle.js +1 -0
- package/storybook-static/7.5b8a4de4b5fa42d8de02.manager.bundle.js +1 -0
- package/storybook-static/7.f33530b1.iframe.bundle.js +1 -0
- package/storybook-static/8.a3dec9c37e8951a17939.manager.bundle.js +2 -0
- package/storybook-static/{6.a6d45262f7e98f3f18d3.manager.bundle.js.LICENSE.txt → 8.a3dec9c37e8951a17939.manager.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/8.b569e86b.iframe.bundle.js +1 -0
- package/storybook-static/{8.76c3cbf398692028e834.manager.bundle.js → 9.d04fdaada645cd23cb4b.manager.bundle.js} +1 -1
- package/storybook-static/9.f9db5c90.iframe.bundle.js +3 -0
- package/storybook-static/{7.9ce807e3.iframe.bundle.js.LICENSE.txt → 9.f9db5c90.iframe.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/9.f9db5c90.iframe.bundle.js.map +1 -0
- package/storybook-static/iframe.html +19 -3
- package/storybook-static/index.html +2 -2
- package/storybook-static/main.1a0e1257.iframe.bundle.js +1 -0
- package/storybook-static/main.750dea0e0e515fd26844.manager.bundle.js +1 -0
- package/storybook-static/project.json +1 -0
- package/storybook-static/runtime~main.1bd817501fb34a0cb56b.manager.bundle.js +1 -0
- package/storybook-static/runtime~main.9be73be4.iframe.bundle.js +1 -0
- package/storybook-static/vendors~main.826e89a1.iframe.bundle.js +76 -0
- package/storybook-static/{vendors~main.a7262b49.iframe.bundle.js.LICENSE.txt → vendors~main.826e89a1.iframe.bundle.js.LICENSE.txt} +15 -0
- package/storybook-static/vendors~main.826e89a1.iframe.bundle.js.map +1 -0
- package/storybook-static/vendors~main.ed8bc18573e141ab3b26.manager.bundle.js +2 -0
- package/storybook-static/{vendors~main.a697e07137d366f95f76.manager.bundle.js.LICENSE.txt → vendors~main.ed8bc18573e141ab3b26.manager.bundle.js.LICENSE.txt} +18 -18
- package/storybook-static/0.0d994c92.iframe.bundle.js +0 -3
- package/storybook-static/0.0d994c92.iframe.bundle.js.map +0 -1
- package/storybook-static/0.f47eb24a4893a96ec307.manager.bundle.js +0 -1
- package/storybook-static/1.aabc3f3a.iframe.bundle.js +0 -1
- package/storybook-static/4.0fcda1281dc1961dbe94.manager.bundle.js +0 -2
- package/storybook-static/5.63ab4f94d50a3acf080d.manager.bundle.js +0 -1
- package/storybook-static/6.13a534cb.iframe.bundle.js +0 -1
- package/storybook-static/6.a6d45262f7e98f3f18d3.manager.bundle.js +0 -2
- package/storybook-static/7.097710753af9a1c41b80.manager.bundle.js +0 -1
- package/storybook-static/7.9ce807e3.iframe.bundle.js +0 -3
- package/storybook-static/7.9ce807e3.iframe.bundle.js.map +0 -1
- package/storybook-static/8.1bf48ea7.iframe.bundle.js +0 -1
- package/storybook-static/main.9d5968bcf15d21f5487c.manager.bundle.js +0 -1
- package/storybook-static/main.e9b7f5c4.iframe.bundle.js +0 -1
- package/storybook-static/runtime~main.708d7ac1.iframe.bundle.js +0 -1
- package/storybook-static/runtime~main.c8dac23bc753439736f0.manager.bundle.js +0 -1
- package/storybook-static/vendors~main.a697e07137d366f95f76.manager.bundle.js +0 -2
- package/storybook-static/vendors~main.a7262b49.iframe.bundle.js +0 -76
- package/storybook-static/vendors~main.a7262b49.iframe.bundle.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { styled, useTheme } from "@mui/material/styles";
|
|
3
3
|
import Box from "@mui/material/Box";
|
|
4
|
-
import
|
|
4
|
+
import Drawer from "@mui/material/Drawer";
|
|
5
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
5
6
|
import MuiAppBar from "@mui/material/AppBar";
|
|
6
7
|
import Toolbar from "@mui/material/Toolbar";
|
|
7
8
|
import List from "@mui/material/List";
|
|
@@ -11,211 +12,234 @@ import IconButton from "@mui/material/IconButton";
|
|
|
11
12
|
import MenuIcon from "@mui/icons-material/Menu";
|
|
12
13
|
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
|
|
13
14
|
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
|
14
|
-
import
|
|
15
|
+
import ListItem from "@mui/material/ListItem";
|
|
16
|
+
import ListItemIcon from "@mui/material/ListItemIcon";
|
|
15
17
|
import ListItemText from "@mui/material/ListItemText";
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { HawaPopMenu } from "../elements/HawaPopMenu";
|
|
18
|
+
import InboxIcon from "@mui/icons-material/MoveToInbox";
|
|
19
|
+
import MailIcon from "@mui/icons-material/Mail";
|
|
19
20
|
|
|
20
21
|
const drawerWidth = 240;
|
|
21
22
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const DrawerHeader = styled("div")(({ theme, direction }) => ({
|
|
44
|
-
display: "flex",
|
|
45
|
-
alignItems: "center",
|
|
46
|
-
justifyContent: direction === "rtl" ? "flex-start" : "flex-end",
|
|
47
|
-
padding: theme.spacing(0, 1),
|
|
48
|
-
// necessary for content to be below app bar
|
|
49
|
-
...theme.mixins.toolbar
|
|
50
|
-
}));
|
|
23
|
+
const Main = styled("main", { shouldForwardProp: (prop) => prop !== "open" })(
|
|
24
|
+
({ theme, open, direction }) => ({
|
|
25
|
+
flexGrow: 1,
|
|
26
|
+
padding: theme.spacing(3),
|
|
27
|
+
transition: theme.transitions.create("margin", {
|
|
28
|
+
easing: theme.transitions.easing.sharp,
|
|
29
|
+
duration: theme.transitions.duration.leavingScreen
|
|
30
|
+
}),
|
|
31
|
+
marginLeft: direction === "rtl" ? 0 : `-${drawerWidth}px`,
|
|
32
|
+
marginRight: direction === "rtl" ? `-${drawerWidth}px` : 0,
|
|
33
|
+
...(open && {
|
|
34
|
+
transition: theme.transitions.create("margin", {
|
|
35
|
+
easing: theme.transitions.easing.easeOut,
|
|
36
|
+
duration: theme.transitions.duration.enteringScreen
|
|
37
|
+
}),
|
|
38
|
+
marginLeft: direction === "ltr" && 0,
|
|
39
|
+
marginRight: direction === "rtl" && 0
|
|
40
|
+
})
|
|
41
|
+
})
|
|
42
|
+
);
|
|
51
43
|
|
|
52
44
|
const AppBar = styled(MuiAppBar, {
|
|
53
45
|
shouldForwardProp: (prop) => prop !== "open"
|
|
54
46
|
})(({ theme, open, direction }) => ({
|
|
55
|
-
|
|
56
|
-
transition: theme.transitions.create(["width", "margin"], {
|
|
47
|
+
transition: theme.transitions.create(["margin", "width"], {
|
|
57
48
|
easing: theme.transitions.easing.sharp,
|
|
58
49
|
duration: theme.transitions.duration.leavingScreen
|
|
59
50
|
}),
|
|
60
|
-
|
|
61
51
|
...(open && {
|
|
62
|
-
marginLeft: direction === "rtl" ? 0 : drawerWidth,
|
|
63
|
-
marginRight: direction === "rtl" ? drawerWidth : 0,
|
|
64
52
|
width: `calc(100% - ${drawerWidth}px)`,
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
marginLeft: direction === "rtl" ? 0 : `${drawerWidth}px`,
|
|
54
|
+
marginRight: direction === "rtl" ? `${drawerWidth}px` : 0,
|
|
55
|
+
// marginLeft: `${drawerWidth}px`,
|
|
56
|
+
transition: theme.transitions.create(["margin", "width"], {
|
|
57
|
+
easing: theme.transitions.easing.easeOut,
|
|
67
58
|
duration: theme.transitions.duration.enteringScreen
|
|
68
59
|
})
|
|
69
60
|
})
|
|
70
61
|
}));
|
|
71
62
|
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
...(open && {
|
|
80
|
-
...openedMixin(theme),
|
|
81
|
-
"& .MuiDrawer-paper": openedMixin(theme)
|
|
82
|
-
}),
|
|
83
|
-
...(!open && {
|
|
84
|
-
...closedMixin(theme),
|
|
85
|
-
"& .MuiDrawer-paper": closedMixin(theme)
|
|
86
|
-
})
|
|
63
|
+
const DrawerHeader = styled("div")(({ theme }) => ({
|
|
64
|
+
display: "flex",
|
|
65
|
+
alignItems: "center",
|
|
66
|
+
padding: theme.spacing(0, 1),
|
|
67
|
+
// necessary for content to be below app bar
|
|
68
|
+
...theme.mixins.toolbar,
|
|
69
|
+
justifyContent: "flex-end"
|
|
87
70
|
}));
|
|
88
71
|
|
|
89
|
-
export
|
|
72
|
+
export const HawaAppLayout = (props) => {
|
|
90
73
|
const theme = useTheme();
|
|
91
|
-
const [open, setOpen] = React.useState(
|
|
74
|
+
const [open, setOpen] = React.useState(false);
|
|
92
75
|
const isArabic = props.lang === "ar";
|
|
93
|
-
const
|
|
94
|
-
|
|
76
|
+
const handleDrawerOpen = () => {
|
|
77
|
+
setOpen(true);
|
|
78
|
+
};
|
|
95
79
|
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const handleCloseUserMenu = () => setAnchorElUser(null);
|
|
100
|
-
const handleDrawerOpen = () => setOpen(true);
|
|
101
|
-
const handleDrawerClose = () => setOpen(false);
|
|
80
|
+
const handleDrawerClose = () => {
|
|
81
|
+
setOpen(false);
|
|
82
|
+
};
|
|
102
83
|
|
|
103
84
|
return (
|
|
104
|
-
<Box sx={{ display: "flex"
|
|
85
|
+
<Box sx={{ display: "flex" }}>
|
|
86
|
+
<CssBaseline />
|
|
105
87
|
<AppBar
|
|
106
|
-
variant="appbar"
|
|
107
88
|
position="fixed"
|
|
108
89
|
open={open}
|
|
109
90
|
direction={isArabic ? "rtl" : "ltr"}
|
|
91
|
+
style={{
|
|
92
|
+
alignItems: isArabic ? "flex-end" : "flex-start",
|
|
93
|
+
justifyContent: "center"
|
|
94
|
+
}}
|
|
110
95
|
>
|
|
111
|
-
<Toolbar
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
96
|
+
<Toolbar>
|
|
97
|
+
{isArabic ? (
|
|
98
|
+
<>
|
|
99
|
+
<Typography variant="h6" noWrap component="div">
|
|
100
|
+
Persistent drawer
|
|
101
|
+
</Typography>
|
|
102
|
+
<IconButton
|
|
103
|
+
color="inherit"
|
|
104
|
+
aria-label="open drawer"
|
|
105
|
+
onClick={handleDrawerOpen}
|
|
106
|
+
edge={isArabic ? "end" : "start"}
|
|
107
|
+
sx={{ mr: 2, ...(open && { display: "none" }) }}
|
|
108
|
+
>
|
|
109
|
+
<MenuIcon />
|
|
110
|
+
</IconButton>
|
|
111
|
+
</>
|
|
112
|
+
) : (
|
|
113
|
+
<>
|
|
114
|
+
<IconButton
|
|
115
|
+
color="inherit"
|
|
116
|
+
aria-label="open drawer"
|
|
117
|
+
onClick={handleDrawerOpen}
|
|
118
|
+
edge={isArabic ? "end" : "start"}
|
|
119
|
+
sx={{
|
|
120
|
+
marginRight: isArabic ? 0 : 2,
|
|
121
|
+
marginLeft: isArabic ? 2 : 0,
|
|
122
|
+
...(open && { display: "none" })
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
<MenuIcon />
|
|
126
|
+
</IconButton>
|
|
127
|
+
<Typography variant="h6" noWrap component="div">
|
|
128
|
+
Persistent drawer
|
|
129
|
+
</Typography>
|
|
130
|
+
</>
|
|
131
|
+
)}
|
|
132
|
+
</Toolbar>
|
|
133
|
+
</AppBar>
|
|
134
|
+
{!isArabic ? (
|
|
135
|
+
<>
|
|
136
|
+
<Drawer
|
|
121
137
|
sx={{
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
width: drawerWidth,
|
|
139
|
+
flexShrink: 0,
|
|
140
|
+
"& .MuiDrawer-paper": {
|
|
141
|
+
width: drawerWidth,
|
|
142
|
+
boxSizing: "border-box"
|
|
143
|
+
}
|
|
124
144
|
}}
|
|
145
|
+
variant="persistent"
|
|
146
|
+
anchor={isArabic ? "right" : "left"}
|
|
147
|
+
open={open}
|
|
125
148
|
>
|
|
126
|
-
<
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
149
|
+
<DrawerHeader>
|
|
150
|
+
<IconButton onClick={handleDrawerClose}>
|
|
151
|
+
{theme.direction === "ltr" ? (
|
|
152
|
+
<ChevronLeftIcon />
|
|
153
|
+
) : (
|
|
154
|
+
<ChevronRightIcon />
|
|
155
|
+
)}
|
|
156
|
+
</IconButton>
|
|
157
|
+
</DrawerHeader>
|
|
158
|
+
<Divider />
|
|
159
|
+
<List>
|
|
160
|
+
{["Inbox", "Starred", "Send email", "Drafts"].map(
|
|
161
|
+
(text, index) => (
|
|
162
|
+
<ListItem button key={text}>
|
|
163
|
+
<ListItemIcon>
|
|
164
|
+
{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
|
|
165
|
+
</ListItemIcon>
|
|
166
|
+
<ListItemText primary={text} />
|
|
167
|
+
</ListItem>
|
|
168
|
+
)
|
|
169
|
+
)}
|
|
170
|
+
</List>
|
|
171
|
+
<Divider />
|
|
172
|
+
<List>
|
|
173
|
+
{["All mail", "Trash", "Spam"].map((text, index) => (
|
|
174
|
+
<ListItem button key={text}>
|
|
175
|
+
<ListItemIcon>
|
|
176
|
+
{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
|
|
177
|
+
</ListItemIcon>
|
|
178
|
+
<ListItemText primary={text} />
|
|
179
|
+
</ListItem>
|
|
180
|
+
))}
|
|
181
|
+
</List>
|
|
182
|
+
</Drawer>
|
|
183
|
+
<Main open={open} direction={isArabic ? "rtl" : "ltr"}>
|
|
184
|
+
<DrawerHeader />
|
|
185
|
+
{props.children}
|
|
186
|
+
</Main>
|
|
187
|
+
</>
|
|
188
|
+
) : (
|
|
189
|
+
<>
|
|
190
|
+
<Main open={open} direction={isArabic ? "rtl" : "ltr"}>
|
|
191
|
+
<DrawerHeader />
|
|
192
|
+
{props.children}
|
|
193
|
+
</Main>
|
|
194
|
+
<Drawer
|
|
195
|
+
sx={{
|
|
196
|
+
width: drawerWidth,
|
|
197
|
+
flexShrink: 0,
|
|
198
|
+
"& .MuiDrawer-paper": {
|
|
199
|
+
width: drawerWidth,
|
|
200
|
+
boxSizing: "border-box"
|
|
201
|
+
}
|
|
138
202
|
}}
|
|
203
|
+
variant="persistent"
|
|
204
|
+
anchor={isArabic ? "right" : "left"}
|
|
205
|
+
open={open}
|
|
139
206
|
>
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
)}
|
|
177
|
-
</IconButton>
|
|
178
|
-
</DrawerHeader>
|
|
179
|
-
<Divider />
|
|
180
|
-
<List>
|
|
181
|
-
{props.pages.map((p, jk) => {
|
|
182
|
-
return (
|
|
183
|
-
<Tooltip
|
|
184
|
-
title={p.text}
|
|
185
|
-
key={jk}
|
|
186
|
-
placement={"right"}
|
|
187
|
-
arrow={true}
|
|
188
|
-
PopperProps={{ style: { opacity: open ? 0 : 1 } }}
|
|
189
|
-
>
|
|
190
|
-
<ListItemButton
|
|
191
|
-
variant={
|
|
192
|
-
props.pageName?.toLowerCase() === p.slug?.toLowerCase() &&
|
|
193
|
-
"clicked"
|
|
194
|
-
}
|
|
195
|
-
onClick={p.action}
|
|
196
|
-
key={p.text}
|
|
197
|
-
sx={{
|
|
198
|
-
minHeight: 48,
|
|
199
|
-
justifyContent: open ? "initial" : "center",
|
|
200
|
-
px: 2.5
|
|
201
|
-
}}
|
|
202
|
-
>
|
|
203
|
-
<p.icon />
|
|
204
|
-
<div style={{ width: 20 }} />
|
|
205
|
-
<ListItemText
|
|
206
|
-
primary={p.text}
|
|
207
|
-
sx={{ opacity: open ? 1 : 0 }}
|
|
208
|
-
/>
|
|
209
|
-
</ListItemButton>
|
|
210
|
-
</Tooltip>
|
|
211
|
-
);
|
|
212
|
-
})}
|
|
213
|
-
</List>
|
|
214
|
-
</Drawer>
|
|
215
|
-
<Box sx={{ flexGrow: 1, p: 3 }}>
|
|
216
|
-
<DrawerHeader />
|
|
217
|
-
{props.children}
|
|
218
|
-
</Box>
|
|
207
|
+
<DrawerHeader>
|
|
208
|
+
<IconButton onClick={handleDrawerClose}>
|
|
209
|
+
{theme.direction === "ltr" ? (
|
|
210
|
+
<ChevronLeftIcon />
|
|
211
|
+
) : (
|
|
212
|
+
<ChevronRightIcon />
|
|
213
|
+
)}
|
|
214
|
+
</IconButton>
|
|
215
|
+
</DrawerHeader>
|
|
216
|
+
<Divider />
|
|
217
|
+
<List>
|
|
218
|
+
{["Inbox", "Starred", "Send email", "Drafts"].map(
|
|
219
|
+
(text, index) => (
|
|
220
|
+
<ListItem button key={text}>
|
|
221
|
+
<ListItemIcon>
|
|
222
|
+
{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
|
|
223
|
+
</ListItemIcon>
|
|
224
|
+
<ListItemText primary={text} />
|
|
225
|
+
</ListItem>
|
|
226
|
+
)
|
|
227
|
+
)}
|
|
228
|
+
</List>
|
|
229
|
+
<Divider />
|
|
230
|
+
<List>
|
|
231
|
+
{["All mail", "Trash", "Spam"].map((text, index) => (
|
|
232
|
+
<ListItem button key={text}>
|
|
233
|
+
<ListItemIcon>
|
|
234
|
+
{index % 2 === 0 ? <InboxIcon /> : <MailIcon />}
|
|
235
|
+
</ListItemIcon>
|
|
236
|
+
<ListItemText primary={text} />
|
|
237
|
+
</ListItem>
|
|
238
|
+
))}
|
|
239
|
+
</List>
|
|
240
|
+
</Drawer>
|
|
241
|
+
</>
|
|
242
|
+
)}
|
|
219
243
|
</Box>
|
|
220
244
|
);
|
|
221
|
-
}
|
|
245
|
+
};
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import React, { useEffect } from "react";
|
|
2
|
+
import { styled, useTheme } from "@mui/material/styles";
|
|
3
|
+
import Box from "@mui/material/Box";
|
|
4
|
+
import MuiDrawer from "@mui/material/Drawer";
|
|
5
|
+
import MuiAppBar from "@mui/material/AppBar";
|
|
6
|
+
import Toolbar from "@mui/material/Toolbar";
|
|
7
|
+
import List from "@mui/material/List";
|
|
8
|
+
import Typography from "@mui/material/Typography";
|
|
9
|
+
// import Divider from "@mui/material/Divider";
|
|
10
|
+
import IconButton from "@mui/material/IconButton";
|
|
11
|
+
import MenuIcon from "@mui/icons-material/Menu";
|
|
12
|
+
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
|
|
13
|
+
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
|
14
|
+
import ListItemButton from "@mui/material/ListItemButton";
|
|
15
|
+
import ListItemText from "@mui/material/ListItemText";
|
|
16
|
+
import Avatar from "@mui/material/Avatar";
|
|
17
|
+
import Tooltip from "@mui/material/Tooltip";
|
|
18
|
+
import { HawaPopMenu } from "../elements/HawaPopMenu";
|
|
19
|
+
|
|
20
|
+
const drawerWidth = 200;
|
|
21
|
+
|
|
22
|
+
const openedMixin = (theme) => ({
|
|
23
|
+
width: drawerWidth,
|
|
24
|
+
transition: theme.transitions.create("width", {
|
|
25
|
+
easing: theme.transitions.easing.sharp,
|
|
26
|
+
duration: theme.transitions.duration.enteringScreen
|
|
27
|
+
}),
|
|
28
|
+
overflowX: "hidden"
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const closedMixin = (theme) => ({
|
|
32
|
+
transition: theme.transitions.create("width", {
|
|
33
|
+
easing: theme.transitions.easing.sharp,
|
|
34
|
+
duration: theme.transitions.duration.leavingScreen
|
|
35
|
+
}),
|
|
36
|
+
overflowX: "hidden",
|
|
37
|
+
width: `calc(${theme.spacing(0)} + 1px)`,
|
|
38
|
+
[theme.breakpoints.up("sm")]: {
|
|
39
|
+
width: `calc(${theme.spacing(8)} + 1px)`
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const DrawerHeader = styled("div")(({ theme, direction }) => ({
|
|
44
|
+
display: "flex",
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
justifyContent: direction === "rtl" ? "flex-start" : "flex-end",
|
|
47
|
+
padding: theme.spacing(0, 1),
|
|
48
|
+
// necessary for content to be below app bar
|
|
49
|
+
...theme.mixins.toolbar
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
const AppBar = styled(MuiAppBar, {
|
|
53
|
+
shouldForwardProp: (prop) => prop !== "open"
|
|
54
|
+
})(({ theme, open, direction }) => ({
|
|
55
|
+
zIndex: theme.zIndex.drawer + 1,
|
|
56
|
+
transition: theme.transitions.create(["width", "margin"], {
|
|
57
|
+
easing: theme.transitions.easing.sharp,
|
|
58
|
+
duration: theme.transitions.duration.leavingScreen
|
|
59
|
+
}),
|
|
60
|
+
|
|
61
|
+
...(open && {
|
|
62
|
+
marginLeft: direction === "rtl" ? 0 : drawerWidth,
|
|
63
|
+
marginRight: direction === "rtl" ? drawerWidth : 0,
|
|
64
|
+
width: `calc(100% - ${drawerWidth}px)`,
|
|
65
|
+
transition: theme.transitions.create(["width", "margin"], {
|
|
66
|
+
easing: theme.transitions.easing.sharp,
|
|
67
|
+
duration: theme.transitions.duration.enteringScreen
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
const Drawer = styled(MuiDrawer, {
|
|
73
|
+
shouldForwardProp: (prop) => prop !== "open"
|
|
74
|
+
})(({ theme, open }) => ({
|
|
75
|
+
width: drawerWidth,
|
|
76
|
+
flexShrink: 0,
|
|
77
|
+
whiteSpace: "nowrap",
|
|
78
|
+
boxSizing: "border-box",
|
|
79
|
+
...(open && {
|
|
80
|
+
...openedMixin(theme),
|
|
81
|
+
"& .MuiDrawer-paper": openedMixin(theme)
|
|
82
|
+
}),
|
|
83
|
+
...(!open && {
|
|
84
|
+
...closedMixin(theme),
|
|
85
|
+
"& .MuiDrawer-paper": closedMixin(theme)
|
|
86
|
+
})
|
|
87
|
+
}));
|
|
88
|
+
|
|
89
|
+
export function HawaAppLayout(props) {
|
|
90
|
+
const theme = useTheme();
|
|
91
|
+
const [open, setOpen] = React.useState(true);
|
|
92
|
+
const isArabic = props.lang === "ar";
|
|
93
|
+
const [anchorElNav, setAnchorElNav] = React.useState(null);
|
|
94
|
+
const [anchorElUser, setAnchorElUser] = React.useState(null);
|
|
95
|
+
|
|
96
|
+
const handleOpenNavMenu = (event) => setAnchorElNav(event.currentTarget);
|
|
97
|
+
const handleOpenUserMenu = (event) => setAnchorElUser(event.currentTarget);
|
|
98
|
+
const handleCloseNavMenu = () => setAnchorElNav(null);
|
|
99
|
+
const handleCloseUserMenu = () => setAnchorElUser(null);
|
|
100
|
+
const handleDrawerOpen = () => setOpen(true);
|
|
101
|
+
const handleDrawerClose = () => setOpen(false);
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
setOpen(!open);
|
|
105
|
+
}, []);
|
|
106
|
+
return (
|
|
107
|
+
<Box sx={{ display: "flex", direction: isArabic ? "rtl" : "ltr" }}>
|
|
108
|
+
<AppBar
|
|
109
|
+
variant="appbar"
|
|
110
|
+
position="fixed"
|
|
111
|
+
open={open}
|
|
112
|
+
direction={isArabic ? "rtl" : "ltr"}
|
|
113
|
+
>
|
|
114
|
+
<Toolbar
|
|
115
|
+
variant="appbar"
|
|
116
|
+
sx={{ paddingLeft: { xs: 3 }, paddingRight: { xs: 3 } }}
|
|
117
|
+
>
|
|
118
|
+
<IconButton
|
|
119
|
+
color="inherit"
|
|
120
|
+
aria-label="open drawer"
|
|
121
|
+
onClick={handleDrawerOpen}
|
|
122
|
+
edge="start"
|
|
123
|
+
s
|
|
124
|
+
sx={{
|
|
125
|
+
marginRight: 5,
|
|
126
|
+
...(open && { display: "none" })
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
<MenuIcon />
|
|
130
|
+
</IconButton>
|
|
131
|
+
|
|
132
|
+
<div
|
|
133
|
+
style={{
|
|
134
|
+
display: "flex",
|
|
135
|
+
flexDirection: "row",
|
|
136
|
+
justifyContent: "space-between",
|
|
137
|
+
alignItems: "center",
|
|
138
|
+
width: "100%",
|
|
139
|
+
margin: 0
|
|
140
|
+
}}
|
|
141
|
+
>
|
|
142
|
+
<Typography
|
|
143
|
+
variant="h6"
|
|
144
|
+
noWrap
|
|
145
|
+
component="div"
|
|
146
|
+
sx={{
|
|
147
|
+
display: {
|
|
148
|
+
xs: open ? "none" : "flex",
|
|
149
|
+
sm: "flex"
|
|
150
|
+
}
|
|
151
|
+
}}
|
|
152
|
+
>
|
|
153
|
+
{props.pageTitle}
|
|
154
|
+
</Typography>
|
|
155
|
+
|
|
156
|
+
<Box style={{ position: "absolute", right: 10 }}>
|
|
157
|
+
<Tooltip title="Open settings">
|
|
158
|
+
<IconButton
|
|
159
|
+
onClick={handleOpenUserMenu}
|
|
160
|
+
// sx={{ p: 0 }}
|
|
161
|
+
size="small"
|
|
162
|
+
>
|
|
163
|
+
<Avatar
|
|
164
|
+
style={{ width: 30, height: 30 }}
|
|
165
|
+
fontSize="inherit"
|
|
166
|
+
/>
|
|
167
|
+
</IconButton>
|
|
168
|
+
</Tooltip>
|
|
169
|
+
<HawaPopMenu
|
|
170
|
+
menuItems={props.accountMenu}
|
|
171
|
+
anchor={anchorElUser}
|
|
172
|
+
handleClose={handleCloseUserMenu}
|
|
173
|
+
/>
|
|
174
|
+
</Box>
|
|
175
|
+
</div>
|
|
176
|
+
</Toolbar>
|
|
177
|
+
</AppBar>
|
|
178
|
+
|
|
179
|
+
<Drawer
|
|
180
|
+
// anchor="left"
|
|
181
|
+
|
|
182
|
+
variant="permanent"
|
|
183
|
+
open={open}
|
|
184
|
+
// sx={{ display: { xs: open ? "flex" : "none", md: "flex" } }}
|
|
185
|
+
>
|
|
186
|
+
<DrawerHeader direction={isArabic ? "rtl" : "ltr"}>
|
|
187
|
+
{props.logo}
|
|
188
|
+
<IconButton onClick={handleDrawerClose}>
|
|
189
|
+
{theme.direction === "rtl" ? (
|
|
190
|
+
<ChevronRightIcon />
|
|
191
|
+
) : (
|
|
192
|
+
<ChevronLeftIcon />
|
|
193
|
+
)}
|
|
194
|
+
</IconButton>
|
|
195
|
+
</DrawerHeader>
|
|
196
|
+
{/* <Divider /> */}
|
|
197
|
+
<List
|
|
198
|
+
// sx={{
|
|
199
|
+
// display: {
|
|
200
|
+
// xs: open ? "flex" : "none",
|
|
201
|
+
// sm: open ? "flex" : "none",
|
|
202
|
+
// md: "flex"
|
|
203
|
+
// },
|
|
204
|
+
// flexDirection: "column",
|
|
205
|
+
// padding: 0
|
|
206
|
+
// }}
|
|
207
|
+
>
|
|
208
|
+
{props.pages.map((p, jk) => {
|
|
209
|
+
return (
|
|
210
|
+
<Tooltip
|
|
211
|
+
title={p.text}
|
|
212
|
+
key={jk}
|
|
213
|
+
placement={"right"}
|
|
214
|
+
arrow={true}
|
|
215
|
+
PopperProps={{ style: { opacity: open ? 0 : 1 } }}
|
|
216
|
+
>
|
|
217
|
+
<ListItemButton
|
|
218
|
+
variant={
|
|
219
|
+
props.pageName?.toLowerCase() === p.slug?.toLowerCase() &&
|
|
220
|
+
"clicked"
|
|
221
|
+
}
|
|
222
|
+
onClick={p.action}
|
|
223
|
+
key={p.text}
|
|
224
|
+
sx={{
|
|
225
|
+
minHeight: 48,
|
|
226
|
+
justifyContent: open ? "initial" : "center",
|
|
227
|
+
px: 2.5
|
|
228
|
+
}}
|
|
229
|
+
>
|
|
230
|
+
<p.icon />
|
|
231
|
+
<div style={{ width: 20 }} />
|
|
232
|
+
<ListItemText
|
|
233
|
+
primary={p.text}
|
|
234
|
+
sx={{ opacity: open ? 1 : 0 }}
|
|
235
|
+
/>
|
|
236
|
+
</ListItemButton>
|
|
237
|
+
</Tooltip>
|
|
238
|
+
);
|
|
239
|
+
})}
|
|
240
|
+
</List>
|
|
241
|
+
</Drawer>
|
|
242
|
+
<Box
|
|
243
|
+
onClick={open && (() => setOpen(false))}
|
|
244
|
+
sx={{
|
|
245
|
+
flexGrow: 1,
|
|
246
|
+
p: 3,
|
|
247
|
+
position: "absolute",
|
|
248
|
+
left: {
|
|
249
|
+
xs: open ? 4 : 4,
|
|
250
|
+
sm: open ? drawerWidth + 4 : 70
|
|
251
|
+
},
|
|
252
|
+
right: { xs: 4 }
|
|
253
|
+
}}
|
|
254
|
+
>
|
|
255
|
+
<DrawerHeader />
|
|
256
|
+
<div style={{ marginTop: -10 }}>{props.children}</div>
|
|
257
|
+
</Box>
|
|
258
|
+
</Box>
|
|
259
|
+
);
|
|
260
|
+
}
|