umwd-components 0.1.31 → 0.1.33
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.
|
@@ -28,16 +28,23 @@ NavBar.propTypes = {
|
|
|
28
28
|
pages: PropTypes.arrayOf(PropTypes.shape({
|
|
29
29
|
name: PropTypes.string.isRequired,
|
|
30
30
|
url: PropTypes.string.isRequired
|
|
31
|
-
}))
|
|
31
|
+
})),
|
|
32
|
+
tabs: PropTypes.arrayOf(PropTypes.shape({
|
|
33
|
+
name: PropTypes.string.isRequired,
|
|
34
|
+
url: PropTypes.string.isRequired
|
|
35
|
+
}))
|
|
32
36
|
};
|
|
33
37
|
function NavBar({
|
|
34
38
|
site_title,
|
|
35
39
|
logo,
|
|
36
|
-
pages
|
|
40
|
+
pages = [],
|
|
41
|
+
tabs = [],
|
|
42
|
+
maxWidth = "xl"
|
|
37
43
|
}) {
|
|
38
44
|
// handleMobileMenu
|
|
39
45
|
|
|
40
46
|
const [mobileNavOpen, setMobileNavOpen] = React.useState(false);
|
|
47
|
+
const [currentTab, setCurrentTab] = React.useState(tabs[0]?.name || "");
|
|
41
48
|
const handleOpenMobileMenu = e => {
|
|
42
49
|
setMobileNavOpen(true);
|
|
43
50
|
};
|
|
@@ -45,10 +52,14 @@ function NavBar({
|
|
|
45
52
|
setMobileNavOpen(false);
|
|
46
53
|
};
|
|
47
54
|
const router = navigation.useRouter();
|
|
55
|
+
const handleChange = (event, newValue) => {
|
|
56
|
+
console.log(newValue);
|
|
57
|
+
setCurrentTab(newValue);
|
|
58
|
+
};
|
|
48
59
|
return /*#__PURE__*/React.createElement(material.AppBar, {
|
|
49
60
|
position: "sticky"
|
|
50
61
|
}, /*#__PURE__*/React.createElement(material.Container, {
|
|
51
|
-
maxWidth:
|
|
62
|
+
maxWidth: maxWidth
|
|
52
63
|
}, /*#__PURE__*/React.createElement(material.Toolbar, {
|
|
53
64
|
disableGutters: true,
|
|
54
65
|
sx: {
|
|
@@ -91,7 +102,7 @@ function NavBar({
|
|
|
91
102
|
display: "flex",
|
|
92
103
|
textDecoration: "none"
|
|
93
104
|
}
|
|
94
|
-
}, site_title))), /*#__PURE__*/React.createElement(material.Box, {
|
|
105
|
+
}, site_title))), pages.length > 0 && /*#__PURE__*/React.createElement(material.Box, {
|
|
95
106
|
sx: {
|
|
96
107
|
flexGrow: 1,
|
|
97
108
|
display: {
|
|
@@ -243,7 +254,7 @@ function NavBar({
|
|
|
243
254
|
sx: {
|
|
244
255
|
color: "primary.contrastText"
|
|
245
256
|
}
|
|
246
|
-
}))))), /*#__PURE__*/React.createElement(material.List, null, pages.map(page => {
|
|
257
|
+
}))))), pages.length > 0 && /*#__PURE__*/React.createElement(material.List, null, pages.map(page => {
|
|
247
258
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(material.ListItem, {
|
|
248
259
|
key: page.name,
|
|
249
260
|
onClick: () => {
|
|
@@ -253,7 +264,23 @@ function NavBar({
|
|
|
253
264
|
}, /*#__PURE__*/React.createElement(material.ListItemText, {
|
|
254
265
|
primary: page.name
|
|
255
266
|
})), /*#__PURE__*/React.createElement(material.Divider, null));
|
|
256
|
-
})))))
|
|
267
|
+
}))))), tabs.length > 0 && /*#__PURE__*/React.createElement(material.Tabs, {
|
|
268
|
+
value: currentTab,
|
|
269
|
+
onChange: (event, newValue) => handleChange(event, newValue),
|
|
270
|
+
"aria-label": "wrapped label tabs example",
|
|
271
|
+
textColor: "secondary",
|
|
272
|
+
indicatorColor: "secondary",
|
|
273
|
+
variant: "fullWidth"
|
|
274
|
+
}, tabs.length > 0 && tabs.map(tab => {
|
|
275
|
+
return /*#__PURE__*/React.createElement(material.Tab, {
|
|
276
|
+
key: tab.name,
|
|
277
|
+
value: tab.name,
|
|
278
|
+
label: tab.name,
|
|
279
|
+
onClick: () => {
|
|
280
|
+
router.push(tab.url);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}))));
|
|
257
284
|
}
|
|
258
285
|
|
|
259
286
|
exports.default = NavBar;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import Link from 'next/link';
|
|
10
|
-
import { AppBar, Container, Toolbar, Box, Typography, Button, Dialog, List, ListItem, ListItemText, Divider } from '@mui/material';
|
|
10
|
+
import { AppBar, Container, Toolbar, Box, Typography, Button, Dialog, List, ListItem, ListItemText, Divider, Tabs, Tab } from '@mui/material';
|
|
11
11
|
import CloseIcon from '@mui/icons-material/Close';
|
|
12
12
|
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
|
13
13
|
import { useRouter } from 'next/navigation';
|
|
@@ -24,16 +24,23 @@ NavBar.propTypes = {
|
|
|
24
24
|
pages: PropTypes.arrayOf(PropTypes.shape({
|
|
25
25
|
name: PropTypes.string.isRequired,
|
|
26
26
|
url: PropTypes.string.isRequired
|
|
27
|
-
}))
|
|
27
|
+
})),
|
|
28
|
+
tabs: PropTypes.arrayOf(PropTypes.shape({
|
|
29
|
+
name: PropTypes.string.isRequired,
|
|
30
|
+
url: PropTypes.string.isRequired
|
|
31
|
+
}))
|
|
28
32
|
};
|
|
29
33
|
function NavBar({
|
|
30
34
|
site_title,
|
|
31
35
|
logo,
|
|
32
|
-
pages
|
|
36
|
+
pages = [],
|
|
37
|
+
tabs = [],
|
|
38
|
+
maxWidth = "xl"
|
|
33
39
|
}) {
|
|
34
40
|
// handleMobileMenu
|
|
35
41
|
|
|
36
42
|
const [mobileNavOpen, setMobileNavOpen] = React.useState(false);
|
|
43
|
+
const [currentTab, setCurrentTab] = React.useState(tabs[0]?.name || "");
|
|
37
44
|
const handleOpenMobileMenu = e => {
|
|
38
45
|
setMobileNavOpen(true);
|
|
39
46
|
};
|
|
@@ -41,10 +48,14 @@ function NavBar({
|
|
|
41
48
|
setMobileNavOpen(false);
|
|
42
49
|
};
|
|
43
50
|
const router = useRouter();
|
|
51
|
+
const handleChange = (event, newValue) => {
|
|
52
|
+
console.log(newValue);
|
|
53
|
+
setCurrentTab(newValue);
|
|
54
|
+
};
|
|
44
55
|
return /*#__PURE__*/React.createElement(AppBar, {
|
|
45
56
|
position: "sticky"
|
|
46
57
|
}, /*#__PURE__*/React.createElement(Container, {
|
|
47
|
-
maxWidth:
|
|
58
|
+
maxWidth: maxWidth
|
|
48
59
|
}, /*#__PURE__*/React.createElement(Toolbar, {
|
|
49
60
|
disableGutters: true,
|
|
50
61
|
sx: {
|
|
@@ -87,7 +98,7 @@ function NavBar({
|
|
|
87
98
|
display: "flex",
|
|
88
99
|
textDecoration: "none"
|
|
89
100
|
}
|
|
90
|
-
}, site_title))), /*#__PURE__*/React.createElement(Box, {
|
|
101
|
+
}, site_title))), pages.length > 0 && /*#__PURE__*/React.createElement(Box, {
|
|
91
102
|
sx: {
|
|
92
103
|
flexGrow: 1,
|
|
93
104
|
display: {
|
|
@@ -239,7 +250,7 @@ function NavBar({
|
|
|
239
250
|
sx: {
|
|
240
251
|
color: "primary.contrastText"
|
|
241
252
|
}
|
|
242
|
-
}))))), /*#__PURE__*/React.createElement(List, null, pages.map(page => {
|
|
253
|
+
}))))), pages.length > 0 && /*#__PURE__*/React.createElement(List, null, pages.map(page => {
|
|
243
254
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ListItem, {
|
|
244
255
|
key: page.name,
|
|
245
256
|
onClick: () => {
|
|
@@ -249,7 +260,23 @@ function NavBar({
|
|
|
249
260
|
}, /*#__PURE__*/React.createElement(ListItemText, {
|
|
250
261
|
primary: page.name
|
|
251
262
|
})), /*#__PURE__*/React.createElement(Divider, null));
|
|
252
|
-
})))))
|
|
263
|
+
}))))), tabs.length > 0 && /*#__PURE__*/React.createElement(Tabs, {
|
|
264
|
+
value: currentTab,
|
|
265
|
+
onChange: (event, newValue) => handleChange(event, newValue),
|
|
266
|
+
"aria-label": "wrapped label tabs example",
|
|
267
|
+
textColor: "secondary",
|
|
268
|
+
indicatorColor: "secondary",
|
|
269
|
+
variant: "fullWidth"
|
|
270
|
+
}, tabs.length > 0 && tabs.map(tab => {
|
|
271
|
+
return /*#__PURE__*/React.createElement(Tab, {
|
|
272
|
+
key: tab.name,
|
|
273
|
+
value: tab.name,
|
|
274
|
+
label: tab.name,
|
|
275
|
+
onClick: () => {
|
|
276
|
+
router.push(tab.url);
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
}))));
|
|
253
280
|
}
|
|
254
281
|
|
|
255
282
|
export { NavBar as default };
|
package/package.json
CHANGED
package/src/components/NavBar.js
CHANGED
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
ListItem,
|
|
16
16
|
Divider,
|
|
17
17
|
ListItemText,
|
|
18
|
+
Tabs,
|
|
19
|
+
Tab,
|
|
18
20
|
} from "@mui/material";
|
|
19
21
|
|
|
20
22
|
import CloseIcon from "@mui/icons-material/Close";
|
|
@@ -36,14 +38,22 @@ NavBar.propTypes = {
|
|
|
36
38
|
name: PropTypes.string.isRequired,
|
|
37
39
|
url: PropTypes.string.isRequired,
|
|
38
40
|
})
|
|
39
|
-
)
|
|
41
|
+
),
|
|
42
|
+
tabs: PropTypes.arrayOf(
|
|
43
|
+
PropTypes.shape({
|
|
44
|
+
name: PropTypes.string.isRequired,
|
|
45
|
+
url: PropTypes.string.isRequired,
|
|
46
|
+
})
|
|
47
|
+
),
|
|
40
48
|
};
|
|
41
49
|
|
|
42
|
-
function NavBar({ site_title, logo, pages }) {
|
|
50
|
+
function NavBar({ site_title, logo, pages = [], tabs = [], maxWidth = "xl" }) {
|
|
43
51
|
// handleMobileMenu
|
|
44
52
|
|
|
45
53
|
const [mobileNavOpen, setMobileNavOpen] = React.useState(false);
|
|
46
54
|
|
|
55
|
+
const [currentTab, setCurrentTab] = React.useState(tabs[0]?.name || "");
|
|
56
|
+
|
|
47
57
|
const handleOpenMobileMenu = (e) => {
|
|
48
58
|
setMobileNavOpen(true);
|
|
49
59
|
};
|
|
@@ -54,9 +64,15 @@ function NavBar({ site_title, logo, pages }) {
|
|
|
54
64
|
|
|
55
65
|
const router = useRouter();
|
|
56
66
|
|
|
67
|
+
const handleChange = (event, newValue) => {
|
|
68
|
+
console.log(newValue);
|
|
69
|
+
|
|
70
|
+
setCurrentTab(newValue);
|
|
71
|
+
};
|
|
72
|
+
|
|
57
73
|
return (
|
|
58
74
|
<AppBar position="sticky">
|
|
59
|
-
<Container maxWidth=
|
|
75
|
+
<Container maxWidth={maxWidth}>
|
|
60
76
|
<Toolbar disableGutters sx={{ py: 1 }}>
|
|
61
77
|
{/* logo and site title for big screens */}
|
|
62
78
|
<Link href="/" style={{ textDecoration: "none", color: "unset" }}>
|
|
@@ -93,31 +109,33 @@ function NavBar({ site_title, logo, pages }) {
|
|
|
93
109
|
</Link>
|
|
94
110
|
|
|
95
111
|
{/* Large screen menu */}
|
|
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
|
-
|
|
112
|
+
{pages.length > 0 && (
|
|
113
|
+
<Box
|
|
114
|
+
sx={{
|
|
115
|
+
flexGrow: 1,
|
|
116
|
+
display: { xs: "none", md: "flex" },
|
|
117
|
+
alignItems: "center",
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
{pages.map((page) => {
|
|
121
|
+
return (
|
|
122
|
+
<Button
|
|
123
|
+
key={page.name}
|
|
124
|
+
onClick={() => {
|
|
125
|
+
router.push(page.url);
|
|
126
|
+
}}
|
|
127
|
+
sx={{
|
|
128
|
+
my: 2,
|
|
129
|
+
color: "primary.contrastText",
|
|
130
|
+
display: "block",
|
|
131
|
+
}}
|
|
132
|
+
>
|
|
133
|
+
{page.name}
|
|
134
|
+
</Button>
|
|
135
|
+
);
|
|
136
|
+
})}
|
|
137
|
+
</Box>
|
|
138
|
+
)}
|
|
121
139
|
|
|
122
140
|
{/* small screen logo and site title */}
|
|
123
141
|
<Link href="/" style={{ textDecoration: "none", color: "unset" }}>
|
|
@@ -235,27 +253,55 @@ function NavBar({ site_title, logo, pages }) {
|
|
|
235
253
|
</Toolbar>
|
|
236
254
|
</Container>
|
|
237
255
|
</AppBar>
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
+
{pages.length > 0 && (
|
|
257
|
+
<List>
|
|
258
|
+
{pages.map((page) => {
|
|
259
|
+
return (
|
|
260
|
+
<>
|
|
261
|
+
<ListItem
|
|
262
|
+
key={page.name}
|
|
263
|
+
onClick={() => {
|
|
264
|
+
router.push(page.url);
|
|
265
|
+
handleCloseMobileMenu();
|
|
266
|
+
}}
|
|
267
|
+
>
|
|
268
|
+
<ListItemText primary={page.name} />
|
|
269
|
+
</ListItem>
|
|
270
|
+
<Divider />
|
|
271
|
+
</>
|
|
272
|
+
);
|
|
273
|
+
})}
|
|
274
|
+
</List>
|
|
275
|
+
)}
|
|
256
276
|
</Dialog>
|
|
257
277
|
</Box>
|
|
258
278
|
</Toolbar>
|
|
279
|
+
|
|
280
|
+
{/* Tabs */}
|
|
281
|
+
{tabs.length > 0 && (
|
|
282
|
+
<Tabs
|
|
283
|
+
value={currentTab}
|
|
284
|
+
onChange={(event, newValue) => handleChange(event, newValue)}
|
|
285
|
+
aria-label="wrapped label tabs example"
|
|
286
|
+
textColor="secondary"
|
|
287
|
+
indicatorColor="secondary"
|
|
288
|
+
variant="fullWidth"
|
|
289
|
+
>
|
|
290
|
+
{tabs.length > 0 &&
|
|
291
|
+
tabs.map((tab) => {
|
|
292
|
+
return (
|
|
293
|
+
<Tab
|
|
294
|
+
key={tab.name}
|
|
295
|
+
value={tab.name}
|
|
296
|
+
label={tab.name}
|
|
297
|
+
onClick={() => {
|
|
298
|
+
router.push(tab.url);
|
|
299
|
+
}}
|
|
300
|
+
/>
|
|
301
|
+
);
|
|
302
|
+
})}
|
|
303
|
+
</Tabs>
|
|
304
|
+
)}
|
|
259
305
|
</Container>
|
|
260
306
|
</AppBar>
|
|
261
307
|
);
|
|
@@ -36,3 +36,32 @@ Orefs.args = {
|
|
|
36
36
|
},
|
|
37
37
|
],
|
|
38
38
|
};
|
|
39
|
+
|
|
40
|
+
export const UMWD = Template.bind({});
|
|
41
|
+
|
|
42
|
+
UMWD.args = {
|
|
43
|
+
site_title: "UMWD",
|
|
44
|
+
logo: {
|
|
45
|
+
url: thumbnail.src,
|
|
46
|
+
width: 100,
|
|
47
|
+
height: 100,
|
|
48
|
+
alt: "Logo",
|
|
49
|
+
},
|
|
50
|
+
tabs: [
|
|
51
|
+
{
|
|
52
|
+
name: "Resources",
|
|
53
|
+
link: "/resources",
|
|
54
|
+
action: () => console.log("Resources"),
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "Shop",
|
|
58
|
+
link: "/shop",
|
|
59
|
+
action: () => console.log("Shop"),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: "Contact",
|
|
63
|
+
link: "/contact",
|
|
64
|
+
action: () => console.log("Contact"),
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
};
|