@sikka/hawa 0.0.32 → 0.0.35
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 +0 -1
- package/es/index.es.js +1 -1
- package/lib/index.js +1 -1
- package/package.json +4 -2
- package/rollup.config.js +2 -2
- package/src/blocks/Pricing/index.js +1 -0
- package/src/blocks/index.js +4 -0
- package/src/elements/AdaptiveButton.js +1 -1
- package/src/elements/DragDropImages.js +149 -140
- package/src/elements/DraggableCard.js +36 -0
- package/src/elements/HawaPopMenu.js +6 -2
- package/src/elements/index.js +2 -0
- package/src/index.js +1 -3
- package/src/layout/HawaAppBar.js +37 -64
- package/src/layout/HawaAppLayout.js +31 -29
- package/src/layout/HawaPageControls.js +61 -0
- package/src/layout/index.js +1 -0
- package/storybook-static/iframe.html +1 -1
- package/storybook-static/index.html +1 -1
- package/storybook-static/main.6eab4ef6.iframe.bundle.js +1 -0
- package/storybook-static/vendors~main.07e1611f.iframe.bundle.js +76 -0
- package/storybook-static/{vendors~main.924b4d3c.iframe.bundle.js.LICENSE.txt → vendors~main.07e1611f.iframe.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/vendors~main.07e1611f.iframe.bundle.js.map +1 -0
- package/storybook-static/{vendors~main.a697e07137d366f95f76.manager.bundle.js → vendors~main.11281b487bf96f5ff19e.manager.bundle.js} +2 -2
- package/storybook-static/{vendors~main.a697e07137d366f95f76.manager.bundle.js.LICENSE.txt → vendors~main.11281b487bf96f5ff19e.manager.bundle.js.LICENSE.txt} +0 -0
- package/storybook-static/main.c86d0451.iframe.bundle.js +0 -1
- package/storybook-static/vendors~main.924b4d3c.iframe.bundle.js +0 -76
- package/storybook-static/vendors~main.924b4d3c.iframe.bundle.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
// import axios from "axios";
|
|
3
|
-
import { getToken } from "../token";
|
|
4
3
|
import { useDropzone } from "react-dropzone";
|
|
5
|
-
import useTranslation from "next-translate/useTranslation";
|
|
6
|
-
import Badge from "@mui/material/Badge";
|
|
7
4
|
import CloseIcon from "@mui/icons-material/Close";
|
|
8
|
-
import
|
|
5
|
+
// import styled from "@emotion/styled";
|
|
6
|
+
import { Container, IconButton, Typography } from "@mui/material";
|
|
7
|
+
import { useTheme } from "@mui/system";
|
|
8
|
+
import { HawaAlert } from "./HawaAlert";
|
|
9
9
|
|
|
10
10
|
const thumbsContainer = {
|
|
11
11
|
display: "flex",
|
|
@@ -14,23 +14,31 @@ const thumbsContainer = {
|
|
|
14
14
|
marginTop: 10
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
export const DragDropImages = ({
|
|
18
|
+
texts,
|
|
18
19
|
files,
|
|
19
20
|
setFiles,
|
|
20
21
|
itemId,
|
|
21
22
|
setDeletedFiles,
|
|
22
|
-
refetchSingleMenu
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
refetchSingleMenu,
|
|
24
|
+
maxFiles
|
|
25
|
+
}) =>
|
|
26
|
+
// props
|
|
27
|
+
{
|
|
28
|
+
const [cmp, setCmp] = useState(0);
|
|
29
|
+
//const [thumbs, setThumbs] = useState("");
|
|
30
|
+
const theme = useTheme();
|
|
31
|
+
const {
|
|
32
|
+
getRootProps,
|
|
33
|
+
getInputProps,
|
|
34
|
+
fileRejections,
|
|
35
|
+
acceptedFiles,
|
|
36
|
+
isDragActive
|
|
37
|
+
} = useDropzone({
|
|
38
|
+
multiple: true,
|
|
31
39
|
accept: "image/*",
|
|
32
40
|
maxSize: 5000000,
|
|
33
|
-
maxFiles:
|
|
41
|
+
maxFiles: maxFiles,
|
|
34
42
|
onDrop: (acceptedFiles) => {
|
|
35
43
|
setFiles(
|
|
36
44
|
acceptedFiles.map((file, index) =>
|
|
@@ -41,140 +49,141 @@ const DragDropItemImage = ({
|
|
|
41
49
|
);
|
|
42
50
|
}
|
|
43
51
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
const handleRemoveFile = async (file) => {
|
|
53
|
+
console.log("fezafezaf", acceptedFiles[file]);
|
|
54
|
+
if (acceptedFiles[file]?.isFromDB) {
|
|
55
|
+
setDeletedFiles((old) => [
|
|
56
|
+
...old,
|
|
57
|
+
{
|
|
58
|
+
img_url: acceptedFiles[file]?.img_url,
|
|
59
|
+
_id: acceptedFiles[file]?._id
|
|
60
|
+
}
|
|
61
|
+
]);
|
|
62
|
+
try {
|
|
63
|
+
// await axios.post(
|
|
64
|
+
// `${process.env.NEXT_PUBLIC_QAWAIM_API_URL}/deleteImages`,
|
|
65
|
+
// {
|
|
66
|
+
// deletedFiles: [
|
|
67
|
+
// {
|
|
68
|
+
// img_url: acceptedFiles[file]?.img_url,
|
|
69
|
+
// _id: acceptedFiles[file]?._id
|
|
70
|
+
// }
|
|
71
|
+
// ],
|
|
72
|
+
// itemId: itemId
|
|
73
|
+
// }
|
|
74
|
+
// );
|
|
75
|
+
refetchSingleMenu();
|
|
76
|
+
acceptedFiles.splice(file, 1);
|
|
77
|
+
setFiles(acceptedFiles);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.error(err);
|
|
52
80
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// `${process.env.NEXT_PUBLIC_QAWAIM_API_URL}/deleteImages`,
|
|
57
|
-
// {
|
|
58
|
-
// deletedFiles: [
|
|
59
|
-
// {
|
|
60
|
-
// img_url: acceptedFiles[file]?.img_url,
|
|
61
|
-
// _id: acceptedFiles[file]?._id
|
|
62
|
-
// }
|
|
63
|
-
// ],
|
|
64
|
-
// itemId: itemId
|
|
65
|
-
// }
|
|
66
|
-
// );
|
|
67
|
-
refetchSingleMenu();
|
|
68
|
-
acceptedFiles.splice(file, 1);
|
|
69
|
-
setFiles(acceptedFiles);
|
|
70
|
-
} catch (err) {
|
|
71
|
-
console.error(err);
|
|
81
|
+
console.log("accepted files after delete : ", acceptedFiles);
|
|
82
|
+
setCmp((old) => old + 1);
|
|
83
|
+
return;
|
|
72
84
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// console.log("Yes");
|
|
79
|
-
// return;
|
|
80
|
-
// }
|
|
81
|
-
acceptedFiles.splice(file, 1);
|
|
85
|
+
// if (file.hasOwnProperty("_id")) {
|
|
86
|
+
// console.log("Yes");
|
|
87
|
+
// return;
|
|
88
|
+
// }
|
|
89
|
+
acceptedFiles.splice(file, 1);
|
|
82
90
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
setFiles(
|
|
92
|
+
acceptedFiles.map((f) =>
|
|
93
|
+
Object.assign(f, { preview: URL.createObjectURL(f) })
|
|
94
|
+
)
|
|
95
|
+
);
|
|
96
|
+
// setFiles(acceptedFiles);
|
|
97
|
+
};
|
|
98
|
+
useEffect(
|
|
99
|
+
() => () => {
|
|
100
|
+
files?.forEach((file) => {
|
|
101
|
+
URL.revokeObjectURL(file.preview);
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
[files]
|
|
87
105
|
);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
[files]
|
|
98
|
-
);
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
if (files[0]?.hasOwnProperty("_id")) {
|
|
101
|
-
files?.map((file, index) => {
|
|
102
|
-
acceptedFiles.push({
|
|
103
|
-
preview: `https://qawaim-images.s3-ap-southeast-1.amazonaws.com/${file.image_url}`,
|
|
104
|
-
isFromDB: true,
|
|
105
|
-
_id: file._id,
|
|
106
|
-
img_url: file.image_url
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (files[0]?.hasOwnProperty("_id")) {
|
|
108
|
+
files?.map((file, index) => {
|
|
109
|
+
acceptedFiles.push({
|
|
110
|
+
// preview: `https://qawaim-images.s3-ap-southeast-1.amazonaws.com/${file.image_url}`,
|
|
111
|
+
isFromDB: true,
|
|
112
|
+
_id: file._id,
|
|
113
|
+
img_url: file.image_url
|
|
114
|
+
});
|
|
107
115
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
116
|
+
console.log("accepted files : ", acceptedFiles);
|
|
117
|
+
setFiles(acceptedFiles);
|
|
118
|
+
}
|
|
119
|
+
return () => {
|
|
120
|
+
acceptedFiles.splice(0, acceptedFiles?.length);
|
|
121
|
+
};
|
|
122
|
+
}, []);
|
|
123
|
+
const errs = fileRejections.map((rej, i) => {
|
|
124
|
+
return (
|
|
125
|
+
<div key={i}>
|
|
126
|
+
<div>{rej.file.name}</div>
|
|
127
|
+
<div>{rej.errors[0].code}</div>
|
|
128
|
+
</div>
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
console.log(fileRejections[0]?.errors[0]?.code);
|
|
132
|
+
const thumbs = files?.map((file, index) => (
|
|
133
|
+
<div style={{ position: "relative", margin: 10 }}>
|
|
134
|
+
<IconButton
|
|
135
|
+
onClick={(e) => {
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
console.log("delete");
|
|
138
|
+
}}
|
|
139
|
+
size="small"
|
|
140
|
+
variant="contained"
|
|
141
|
+
style={{
|
|
142
|
+
position: "absolute",
|
|
143
|
+
top: -10,
|
|
144
|
+
right: -10,
|
|
145
|
+
backgroundColor: theme.primaryActionColor,
|
|
146
|
+
color: "white",
|
|
147
|
+
padding: 3
|
|
148
|
+
}}
|
|
149
|
+
>
|
|
150
|
+
<CloseIcon fontSize="small" />
|
|
151
|
+
</IconButton>
|
|
152
|
+
<div
|
|
153
|
+
style={{
|
|
154
|
+
display: "flex",
|
|
155
|
+
justifyContent: "center",
|
|
156
|
+
alignItems: "center",
|
|
157
|
+
overflow: "hidden",
|
|
158
|
+
height: 100,
|
|
159
|
+
width: 100,
|
|
160
|
+
backgroundImage: `url(${file.preview})`,
|
|
161
|
+
backgroundSize: "cover",
|
|
162
|
+
backgroundPosition: "center",
|
|
163
|
+
border: "1px solid black"
|
|
164
|
+
}}
|
|
165
|
+
key={file.name}
|
|
166
|
+
/>
|
|
121
167
|
</div>
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const thumbs = files.map((file, index) => (
|
|
126
|
-
<Badge
|
|
127
|
-
key={index}
|
|
128
|
-
onClick={(e) => {
|
|
129
|
-
e.preventDefault();
|
|
130
|
-
e.stopPropagation();
|
|
131
|
-
console.log("Clicking", index);
|
|
132
|
-
handleRemoveFile(index);
|
|
133
|
-
}}
|
|
134
|
-
badgeContent={<CloseIcon fontSize="small" />}
|
|
135
|
-
color="primary"
|
|
136
|
-
style={{
|
|
137
|
-
margin: 10,
|
|
138
|
-
width: 100,
|
|
139
|
-
height: 100
|
|
140
|
-
}}
|
|
141
|
-
>
|
|
142
|
-
<div
|
|
143
|
-
style={{
|
|
144
|
-
display: "flex",
|
|
145
|
-
justifyContent: "center",
|
|
146
|
-
alignItems: "center",
|
|
147
|
-
overflow: "hidden",
|
|
148
|
-
height: 100,
|
|
149
|
-
width: 100,
|
|
150
|
-
backgroundImage: `url(${file.preview})`,
|
|
151
|
-
backgroundSize: "cover",
|
|
152
|
-
backgroundPosition: "center"
|
|
153
|
-
}}
|
|
154
|
-
key={file.name}
|
|
155
|
-
/>
|
|
156
|
-
</Badge>
|
|
157
|
-
));
|
|
168
|
+
));
|
|
158
169
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
170
|
+
return (
|
|
171
|
+
<Container
|
|
172
|
+
variant="drop-area"
|
|
162
173
|
{...getRootProps({
|
|
163
|
-
|
|
164
|
-
console.log("e : ", e);
|
|
165
|
-
e.preventDefault(), console.log("khobza");
|
|
166
|
-
},
|
|
167
|
-
style: { height: "100%", width: "100%", padding: 10 }
|
|
174
|
+
style: { backgroundColor: isDragActive && "white" }
|
|
168
175
|
})}
|
|
169
176
|
>
|
|
170
177
|
<input {...getInputProps()} />
|
|
171
|
-
<
|
|
172
|
-
<
|
|
178
|
+
<Typography>Click here or drop files here to upload</Typography>
|
|
179
|
+
<Typography>Max file size is 5MB</Typography>
|
|
173
180
|
{thumbs ? <aside style={thumbsContainer}>{thumbs}</aside> : null}
|
|
174
|
-
{
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
+
{fileRejections[0]?.errors[0]?.code !== "too-many-files" ? (
|
|
182
|
+
// <Typography variant="">{texts.tooManyFiles}</Typography>
|
|
183
|
+
<HawaAlert text={texts.tooManyFiles} severity="error" />
|
|
184
|
+
) : (
|
|
185
|
+
errs
|
|
186
|
+
)}
|
|
187
|
+
</Container>
|
|
188
|
+
);
|
|
189
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { MoreVert } from "@mui/icons-material";
|
|
2
|
+
import { Container, Stack } from "@mui/material";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
export const DraggableCard = (props) => {
|
|
6
|
+
return (
|
|
7
|
+
<Stack
|
|
8
|
+
variant="card"
|
|
9
|
+
direction="row"
|
|
10
|
+
maxWidth={props.maxWidth}
|
|
11
|
+
style={{ paddingLeft: 5 }}
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
style={{
|
|
15
|
+
// backgroundColor: "blue",
|
|
16
|
+
display: "flex",
|
|
17
|
+
alignItems: "center",
|
|
18
|
+
// paddingRight: 5,
|
|
19
|
+
borderRight: "1px solid grey",
|
|
20
|
+
marginRight: 20
|
|
21
|
+
}}
|
|
22
|
+
>
|
|
23
|
+
<MoreVert />
|
|
24
|
+
</div>
|
|
25
|
+
|
|
26
|
+
<div
|
|
27
|
+
style={{
|
|
28
|
+
// backgroundColor: "red",
|
|
29
|
+
width: "100%"
|
|
30
|
+
}}
|
|
31
|
+
>
|
|
32
|
+
{props.children}
|
|
33
|
+
</div>
|
|
34
|
+
</Stack>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useTheme } from "@mui/material";
|
|
2
|
+
import Typography from "@mui/material/Typography";
|
|
3
|
+
import Menu from "@mui/material/Menu";
|
|
4
|
+
import MenuItem from "@mui/material/MenuItem";
|
|
2
5
|
import PropTypes from "prop-types";
|
|
3
6
|
|
|
4
7
|
export const HawaPopMenu = (props) => {
|
|
@@ -31,7 +34,7 @@ export const HawaPopMenu = (props) => {
|
|
|
31
34
|
{props.menuItems.map((item) => (
|
|
32
35
|
<MenuItem key={item.label} onClick={item.action}>
|
|
33
36
|
{item.icon && <item.icon />}
|
|
34
|
-
<div style={{ width: 10 }} />
|
|
37
|
+
{item.icon && <div style={{ width: 10 }} />}
|
|
35
38
|
<Typography textAlign="center">{item.label}</Typography>
|
|
36
39
|
</MenuItem>
|
|
37
40
|
))}
|
|
@@ -40,6 +43,7 @@ export const HawaPopMenu = (props) => {
|
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
HawaPopMenu.propTypes = {
|
|
46
|
+
anchor: PropTypes.any,
|
|
43
47
|
handleClose: PropTypes.func,
|
|
44
48
|
menuItems: PropTypes.arrayOf(
|
|
45
49
|
PropTypes.shape({
|
package/src/elements/index.js
CHANGED
package/src/index.js
CHANGED
package/src/layout/HawaAppBar.js
CHANGED
|
@@ -3,105 +3,62 @@ import AppBar from "@mui/material/AppBar";
|
|
|
3
3
|
import Box from "@mui/material/Box";
|
|
4
4
|
import Toolbar from "@mui/material/Toolbar";
|
|
5
5
|
import IconButton from "@mui/material/IconButton";
|
|
6
|
-
import Typography from "@mui/material/Typography";
|
|
7
|
-
import Menu from "@mui/material/Menu";
|
|
8
6
|
import MenuIcon from "@mui/icons-material/Menu";
|
|
9
7
|
import Container from "@mui/material/Container";
|
|
10
8
|
import Avatar from "@mui/material/Avatar";
|
|
11
9
|
import Button from "@mui/material/Button";
|
|
12
10
|
import Tooltip from "@mui/material/Tooltip";
|
|
13
|
-
import MenuItem from "@mui/material/MenuItem";
|
|
14
11
|
import { useTheme } from "@mui/material";
|
|
15
12
|
import { HawaPopMenu } from "../elements/HawaPopMenu";
|
|
16
|
-
|
|
17
|
-
const pages = ["Products", "Pricing", "Blog"];
|
|
18
|
-
const settings = ["Profile", "Account", "Dashboard", "Logout"];
|
|
13
|
+
import PropTypes from "prop-types";
|
|
19
14
|
|
|
20
15
|
export const HawaAppBar = (props) => {
|
|
21
16
|
const theme = useTheme();
|
|
22
17
|
const [anchorElNav, setAnchorElNav] = React.useState(null);
|
|
23
18
|
const [anchorElUser, setAnchorElUser] = React.useState(null);
|
|
24
19
|
|
|
25
|
-
const handleOpenNavMenu = (event) =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
setAnchorElUser(event.currentTarget);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const handleCloseNavMenu = () => {
|
|
33
|
-
setAnchorElNav(null);
|
|
34
|
-
};
|
|
20
|
+
const handleOpenNavMenu = (event) => setAnchorElNav(event.currentTarget);
|
|
21
|
+
const handleOpenUserMenu = (event) => setAnchorElUser(event.currentTarget);
|
|
22
|
+
const handleCloseNavMenu = () => setAnchorElNav(null);
|
|
23
|
+
const handleCloseUserMenu = () => setAnchorElUser(null);
|
|
35
24
|
|
|
36
|
-
const handleCloseUserMenu = () => {
|
|
37
|
-
setAnchorElUser(null);
|
|
38
|
-
};
|
|
39
25
|
console.log("theme is ", theme);
|
|
40
26
|
return (
|
|
41
27
|
<AppBar position="static" variant="appbar">
|
|
42
|
-
<Container
|
|
28
|
+
<Container variant="appbar">
|
|
43
29
|
<Toolbar disableGutters>
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
component="div"
|
|
48
|
-
sx={{ mr: 2, display: { xs: "none", md: "flex" } }}
|
|
49
|
-
>
|
|
50
|
-
LOGO
|
|
51
|
-
</Typography>
|
|
52
|
-
|
|
30
|
+
<Box sx={{ flexGrow: 1, display: { xs: "none", md: "flex" } }}>
|
|
31
|
+
{props.logo}
|
|
32
|
+
</Box>
|
|
53
33
|
<Box sx={{ flexGrow: 1, display: { xs: "flex", md: "none" } }}>
|
|
54
34
|
<IconButton
|
|
55
35
|
size="large"
|
|
56
36
|
aria-label="account of current user"
|
|
57
37
|
aria-controls="menu-appbar"
|
|
58
38
|
aria-haspopup="true"
|
|
59
|
-
onClick={
|
|
39
|
+
onClick={handleOpenNavMenu}
|
|
60
40
|
color="inherit"
|
|
61
41
|
>
|
|
62
42
|
<MenuIcon />
|
|
63
43
|
</IconButton>
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
vertical: "top",
|
|
74
|
-
horizontal: "left"
|
|
75
|
-
}}
|
|
76
|
-
open={Boolean(anchorElNav)}
|
|
77
|
-
onClose={handleCloseNavMenu}
|
|
78
|
-
sx={{
|
|
79
|
-
display: { xs: "block", md: "none" }
|
|
80
|
-
}}
|
|
81
|
-
>
|
|
82
|
-
{pages.map((page) => (
|
|
83
|
-
<MenuItem key={page} onClick={handleCloseNavMenu}>
|
|
84
|
-
<Typography textAlign="center">{page}</Typography>
|
|
85
|
-
</MenuItem>
|
|
86
|
-
))}
|
|
87
|
-
</Menu>
|
|
44
|
+
<HawaPopMenu
|
|
45
|
+
anchor={anchorElNav}
|
|
46
|
+
handleClose={handleCloseNavMenu}
|
|
47
|
+
menuItems={props.pages}
|
|
48
|
+
/>
|
|
49
|
+
</Box>
|
|
50
|
+
|
|
51
|
+
<Box sx={{ flexGrow: 1, display: { xs: "flex", md: "none" } }}>
|
|
52
|
+
{props.logo}
|
|
88
53
|
</Box>
|
|
89
|
-
<Typography
|
|
90
|
-
variant="h6"
|
|
91
|
-
noWrap
|
|
92
|
-
component="div"
|
|
93
|
-
sx={{ flexGrow: 1, display: { xs: "flex", md: "none" } }}
|
|
94
|
-
>
|
|
95
|
-
LOGO
|
|
96
|
-
</Typography>
|
|
97
54
|
<Box sx={{ flexGrow: 1, display: { xs: "none", md: "flex" } }}>
|
|
98
|
-
{pages.map((page) => (
|
|
55
|
+
{props.pages.map((page) => (
|
|
99
56
|
<Button
|
|
100
57
|
key={page}
|
|
101
58
|
onClick={handleCloseNavMenu}
|
|
102
59
|
sx={{ my: 2, display: "block" }}
|
|
103
60
|
>
|
|
104
|
-
{page}
|
|
61
|
+
{page.label}
|
|
105
62
|
</Button>
|
|
106
63
|
))}
|
|
107
64
|
</Box>
|
|
@@ -123,3 +80,19 @@ export const HawaAppBar = (props) => {
|
|
|
123
80
|
</AppBar>
|
|
124
81
|
);
|
|
125
82
|
};
|
|
83
|
+
HawaAppBar.propTypes = {
|
|
84
|
+
pages: PropTypes.arrayOf(
|
|
85
|
+
PropTypes.shape({
|
|
86
|
+
icon: PropTypes.element,
|
|
87
|
+
label: PropTypes.string,
|
|
88
|
+
action: PropTypes.func
|
|
89
|
+
})
|
|
90
|
+
),
|
|
91
|
+
accountMenu: PropTypes.arrayOf(
|
|
92
|
+
PropTypes.shape({
|
|
93
|
+
icon: PropTypes.element,
|
|
94
|
+
label: PropTypes.string,
|
|
95
|
+
action: PropTypes.func
|
|
96
|
+
})
|
|
97
|
+
)
|
|
98
|
+
};
|
|
@@ -16,10 +16,6 @@ import ListItemText from "@mui/material/ListItemText";
|
|
|
16
16
|
import Avatar from "@mui/material/Avatar";
|
|
17
17
|
import Tooltip from "@mui/material/Tooltip";
|
|
18
18
|
import { HawaPopMenu } from "../elements/HawaPopMenu";
|
|
19
|
-
// use this to detect size and change things accordingly
|
|
20
|
-
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
21
|
-
import { BottomNavigation, BottomNavigationAction } from "@mui/material";
|
|
22
|
-
import { RestoreOutlined } from "@mui/icons-material";
|
|
23
19
|
|
|
24
20
|
const drawerWidth = 240;
|
|
25
21
|
|
|
@@ -44,10 +40,10 @@ const closedMixin = (theme) => ({
|
|
|
44
40
|
}
|
|
45
41
|
});
|
|
46
42
|
|
|
47
|
-
const DrawerHeader = styled("div")(({ theme }) => ({
|
|
43
|
+
const DrawerHeader = styled("div")(({ theme, direction }) => ({
|
|
48
44
|
display: "flex",
|
|
49
45
|
alignItems: "center",
|
|
50
|
-
justifyContent: "flex-end",
|
|
46
|
+
justifyContent: direction === "rtl" ? "flex-start" : "flex-end",
|
|
51
47
|
padding: theme.spacing(0, 1),
|
|
52
48
|
// necessary for content to be below app bar
|
|
53
49
|
...theme.mixins.toolbar
|
|
@@ -55,14 +51,16 @@ const DrawerHeader = styled("div")(({ theme }) => ({
|
|
|
55
51
|
|
|
56
52
|
const AppBar = styled(MuiAppBar, {
|
|
57
53
|
shouldForwardProp: (prop) => prop !== "open"
|
|
58
|
-
})(({ theme, open }) => ({
|
|
54
|
+
})(({ theme, open, direction }) => ({
|
|
59
55
|
zIndex: theme.zIndex.drawer + 1,
|
|
60
56
|
transition: theme.transitions.create(["width", "margin"], {
|
|
61
57
|
easing: theme.transitions.easing.sharp,
|
|
62
58
|
duration: theme.transitions.duration.leavingScreen
|
|
63
59
|
}),
|
|
60
|
+
|
|
64
61
|
...(open && {
|
|
65
|
-
marginLeft: drawerWidth,
|
|
62
|
+
marginLeft: direction === "rtl" ? 0 : drawerWidth,
|
|
63
|
+
marginRight: direction === "rtl" ? drawerWidth : 0,
|
|
66
64
|
width: `calc(100% - ${drawerWidth}px)`,
|
|
67
65
|
transition: theme.transitions.create(["width", "margin"], {
|
|
68
66
|
easing: theme.transitions.easing.sharp,
|
|
@@ -91,11 +89,10 @@ const Drawer = styled(MuiDrawer, {
|
|
|
91
89
|
export function HawaAppLayout(props) {
|
|
92
90
|
const theme = useTheme();
|
|
93
91
|
const [open, setOpen] = React.useState(true);
|
|
94
|
-
const
|
|
95
|
-
|
|
92
|
+
const isArabic = props.lang === "ar";
|
|
96
93
|
const [anchorElNav, setAnchorElNav] = React.useState(null);
|
|
97
94
|
const [anchorElUser, setAnchorElUser] = React.useState(null);
|
|
98
|
-
|
|
95
|
+
|
|
99
96
|
const handleOpenNavMenu = (event) => setAnchorElNav(event.currentTarget);
|
|
100
97
|
const handleOpenUserMenu = (event) => setAnchorElUser(event.currentTarget);
|
|
101
98
|
const handleCloseNavMenu = () => setAnchorElNav(null);
|
|
@@ -104,27 +101,23 @@ export function HawaAppLayout(props) {
|
|
|
104
101
|
const handleDrawerClose = () => setOpen(false);
|
|
105
102
|
|
|
106
103
|
return (
|
|
107
|
-
<Box sx={{ display: "flex" }}>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
104
|
+
<Box sx={{ display: "flex", direction: isArabic ? "rtl" : "ltr" }}>
|
|
105
|
+
<AppBar
|
|
106
|
+
variant="appbar"
|
|
107
|
+
position="fixed"
|
|
108
|
+
open={open}
|
|
109
|
+
direction={isArabic ? "rtl" : "ltr"}
|
|
110
|
+
>
|
|
111
|
+
<Toolbar
|
|
112
|
+
variant="appbar"
|
|
113
|
+
sx={{ paddingLeft: { xs: 3 }, paddingRight: { xs: 3 } }}
|
|
115
114
|
>
|
|
116
|
-
<BottomNavigationAction label="Recents" icon={<RestoreOutlined />} />
|
|
117
|
-
<BottomNavigationAction label="Favorites" icon={<RestoreOutlined />} />
|
|
118
|
-
<BottomNavigationAction label="Nearby" icon={<RestoreOutlined />} />
|
|
119
|
-
</BottomNavigation>
|
|
120
|
-
)}{" "}
|
|
121
|
-
<AppBar variant="appbar" position="fixed" open={open}>
|
|
122
|
-
<Toolbar variant="appbar">
|
|
123
115
|
<IconButton
|
|
124
116
|
color="inherit"
|
|
125
117
|
aria-label="open drawer"
|
|
126
118
|
onClick={handleDrawerOpen}
|
|
127
119
|
edge="start"
|
|
120
|
+
s
|
|
128
121
|
sx={{
|
|
129
122
|
marginRight: 5,
|
|
130
123
|
...(open && { display: "none" })
|
|
@@ -150,7 +143,11 @@ export function HawaAppLayout(props) {
|
|
|
150
143
|
|
|
151
144
|
<Box>
|
|
152
145
|
<Tooltip title="Open settings">
|
|
153
|
-
<IconButton
|
|
146
|
+
<IconButton
|
|
147
|
+
onClick={handleOpenUserMenu}
|
|
148
|
+
sx={{ p: 0 }}
|
|
149
|
+
size="small"
|
|
150
|
+
>
|
|
154
151
|
<Avatar />
|
|
155
152
|
</IconButton>
|
|
156
153
|
</Tooltip>
|
|
@@ -163,8 +160,13 @@ export function HawaAppLayout(props) {
|
|
|
163
160
|
</div>
|
|
164
161
|
</Toolbar>
|
|
165
162
|
</AppBar>
|
|
166
|
-
<Drawer
|
|
167
|
-
|
|
163
|
+
<Drawer
|
|
164
|
+
// anchor="left"
|
|
165
|
+
|
|
166
|
+
variant="permanent"
|
|
167
|
+
open={open}
|
|
168
|
+
>
|
|
169
|
+
<DrawerHeader direction={isArabic ? "rtl" : "ltr"}>
|
|
168
170
|
{props.logo}
|
|
169
171
|
<IconButton onClick={handleDrawerClose}>
|
|
170
172
|
{theme.direction === "rtl" ? (
|