@symply.io/basic-components 1.0.7 → 1.0.8-beta.1
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/Sidebar/SidebarItem.js +34 -35
- package/Sidebar/SidebarItemsGroup.js +4 -5
- package/Sidebar/SidebarLink.js +6 -7
- package/Sidebar/index.js +2 -2
- package/package.json +1 -1
package/Sidebar/SidebarItem.js
CHANGED
@@ -18,45 +18,44 @@ import ListItemIcon from "@mui/material/ListItemIcon";
|
|
18
18
|
import LockIcon from "@mui/icons-material/LockRounded";
|
19
19
|
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
|
20
20
|
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
21
|
-
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
22
21
|
import useCustomTheme from "../useCustomTheme";
|
23
22
|
function SidebarItem(props) {
|
24
|
-
var icon = props.icon, name = props.name, active = props.active, expand = props.expand, lock = props.lock, beta = props.beta, isSub = props.isSub, hasChildren = props.hasChildren, _a = props.betaTagColor, betaTagColor = _a === void 0 ? "#00A2A9" : _a,
|
25
|
-
var theme = useCustomTheme(
|
26
|
-
return (
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
23
|
+
var icon = props.icon, name = props.name, active = props.active, expand = props.expand, lock = props.lock, beta = props.beta, isSub = props.isSub, hasChildren = props.hasChildren, _a = props.betaTagColor, betaTagColor = _a === void 0 ? "#00A2A9" : _a, onClick = props.onClick;
|
24
|
+
var theme = useCustomTheme();
|
25
|
+
return (_jsxs(ListItem, __assign({ button: true, onClick: onClick, disabled: lock, sx: {
|
26
|
+
paddingLeft: isSub ? theme.spacing(4) : undefined,
|
27
|
+
display: "flex",
|
28
|
+
width: "100%",
|
29
|
+
"&:hover": {
|
30
|
+
backgroundColor: colorAlpha(theme.palette.primary.main, 0.3)
|
31
|
+
},
|
32
|
+
backgroundColor: active
|
33
|
+
? colorAlpha(theme.palette.primary.main, 0.2)
|
34
|
+
: undefined
|
35
|
+
} }, { children: [_jsx(ListItemIcon, __assign({ sx: {
|
36
|
+
color: active ? theme.palette.primary.main : undefined,
|
37
|
+
borderRadius: active ? "5px" : undefined,
|
38
|
+
opacity: active ? "1" : undefined,
|
39
|
+
fontWeight: active ? 600 : undefined
|
40
|
+
} }, { children: icon })), _jsx(ListItemText, { primaryTypographyProps: {
|
41
|
+
color: active ? theme.palette.primary.main : "textPrimary",
|
42
|
+
sx: {
|
43
|
+
overflow: "hidden",
|
44
|
+
textOverflow: "ellipsis",
|
45
|
+
whiteSpace: "nowrap",
|
38
46
|
borderRadius: active ? "5px" : undefined,
|
39
47
|
opacity: active ? "1" : undefined,
|
40
48
|
fontWeight: active ? 600 : undefined
|
41
|
-
}
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
fontSize: "1rem"
|
53
|
-
}, "data-nw": "".concat(name, "_lock") })), beta && (_jsx(Chip, { label: "BETA", color: "primary", size: "small", sx: {
|
54
|
-
borderRadius: theme.spacing(0.5),
|
55
|
-
backgroundColor: betaTagColor,
|
56
|
-
color: "white",
|
57
|
-
height: theme.spacing(2.5),
|
58
|
-
fontSize: theme.spacing(1.25),
|
59
|
-
padding: theme.spacing(0, 0.75)
|
60
|
-
} })), hasChildren && (expand ? _jsx(ExpandMoreIcon, {}) : _jsx(ChevronRightIcon, {}))] })) })));
|
49
|
+
}
|
50
|
+
}, primary: name }), lock && (_jsx(LockIcon, { fontSize: "small", color: "error", sx: {
|
51
|
+
fontSize: "1rem"
|
52
|
+
}, "data-nw": "".concat(name, "_lock") })), beta && (_jsx(Chip, { label: "BETA", color: "primary", size: "small", sx: {
|
53
|
+
borderRadius: theme.spacing(0.5),
|
54
|
+
backgroundColor: betaTagColor,
|
55
|
+
color: "white",
|
56
|
+
height: theme.spacing(2.5),
|
57
|
+
fontSize: theme.spacing(1.25),
|
58
|
+
padding: theme.spacing(0, 0.75)
|
59
|
+
} })), hasChildren && (expand ? _jsx(ExpandMoreIcon, {}) : _jsx(ChevronRightIcon, {}))] })));
|
61
60
|
}
|
62
61
|
export default SidebarItem;
|
@@ -9,10 +9,9 @@ var __assign = (this && this.__assign) || function () {
|
|
9
9
|
};
|
10
10
|
return __assign.apply(this, arguments);
|
11
11
|
};
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
13
13
|
import { useState, memo, useMemo, useEffect, useCallback } from "react";
|
14
14
|
import { Match, useLocation } from "@reach/router";
|
15
|
-
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
16
15
|
import Collapse from "@mui/material/Collapse";
|
17
16
|
import List from "@mui/material/List";
|
18
17
|
import useCustomTheme from "../useCustomTheme";
|
@@ -20,7 +19,7 @@ import SidebarItem from "./SidebarItem";
|
|
20
19
|
import SidebarLink from "./SidebarLink";
|
21
20
|
function SidebarItemsGroup(props) {
|
22
21
|
var item = props.item;
|
23
|
-
var name = item.name, path = item.path, icon = item.icon, children = item.children, lock = item.lock, beta = item.beta, titleForLock = item.titleForLock, betaTagColor = item.betaTagColor
|
22
|
+
var name = item.name, path = item.path, icon = item.icon, children = item.children, lock = item.lock, beta = item.beta, titleForLock = item.titleForLock, betaTagColor = item.betaTagColor;
|
24
23
|
var pathname = useLocation().pathname;
|
25
24
|
var match = useMemo(function () {
|
26
25
|
return pathname.includes(path);
|
@@ -32,7 +31,7 @@ function SidebarItemsGroup(props) {
|
|
32
31
|
useEffect(function () {
|
33
32
|
setExpand(match);
|
34
33
|
}, [match]);
|
35
|
-
var theme = useCustomTheme(
|
36
|
-
return (_jsxs(
|
34
|
+
var theme = useCustomTheme();
|
35
|
+
return (_jsxs(_Fragment, { children: [_jsx(List, __assign({ component: "div", disablePadding: true }, { children: _jsx(SidebarItem, { active: false, name: name, icon: icon, lock: lock, beta: beta, expand: expand, hasChildren: true, betaTagColor: betaTagColor, onClick: onToggleExpand }) })), children && (_jsx(Collapse, __assign({ in: expand, timeout: "auto" }, { children: _jsx(List, __assign({ component: "div", disablePadding: true }, { children: children.map(function (c) { return (_jsx(Match, __assign({ path: c.path }, { children: function (prop) { return (_jsx(SidebarLink, { name: c.name, path: c.path, icon: c.icon, lock: c.lock, beta: c.beta, titleForLock: titleForLock, active: prop.match !== null, betaTagColor: c.betaTagColor, isSub: true })); } }), c.name)); }) })) })))] }));
|
37
36
|
}
|
38
37
|
export default memo(SidebarItemsGroup);
|
package/Sidebar/SidebarLink.js
CHANGED
@@ -22,16 +22,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
22
22
|
};
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
24
24
|
import { Link, useLocation } from "@reach/router";
|
25
|
-
import ThemeProvider from "@mui/material/styles/ThemeProvider";
|
26
25
|
import useCustomTheme from "../useCustomTheme";
|
27
26
|
import SidebarItem from "./SidebarItem";
|
28
27
|
function SidebarLink(props) {
|
29
28
|
var pathname = useLocation().pathname;
|
30
|
-
var name = props.name, path = props.path, icon = props.icon, lock = props.lock, beta = props.beta, active = props.active, titleForLock = props.titleForLock, betaTagColor = props.betaTagColor,
|
31
|
-
var theme = useCustomTheme(
|
32
|
-
return (_jsx(
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
var name = props.name, path = props.path, icon = props.icon, lock = props.lock, beta = props.beta, active = props.active, titleForLock = props.titleForLock, betaTagColor = props.betaTagColor, rest = __rest(props, ["name", "path", "icon", "lock", "beta", "active", "titleForLock", "betaTagColor"]);
|
30
|
+
var theme = useCustomTheme();
|
31
|
+
return (_jsx(Link, __assign({ to: lock ? pathname : path, title: lock ? titleForLock || "Feature is unavailable on Free plan" : name, style: {
|
32
|
+
color: theme.palette.primary.main,
|
33
|
+
textDecoration: "none"
|
34
|
+
} }, { children: _jsx(SidebarItem, __assign({ name: name, icon: icon, lock: lock, beta: beta, active: active, betaTagColor: betaTagColor }, rest), name) })));
|
36
35
|
}
|
37
36
|
export default SidebarLink;
|
package/Sidebar/index.js
CHANGED
@@ -21,8 +21,8 @@ function Sidebar(props) {
|
|
21
21
|
var items = props.items, primaryColor = props.primaryColor, secondaryColor = props.secondaryColor;
|
22
22
|
var theme = useCustomTheme({ primaryColor: primaryColor, secondaryColor: secondaryColor });
|
23
23
|
return (_jsx(ThemeProvider, __assign({ theme: theme }, { children: _jsx(List, { children: items.map(function (i) {
|
24
|
-
var children = i.children, path = i.path, icon = i.icon, name = i.name, lock = i.lock, beta = i.beta, titleForLock = i.titleForLock, betaTagColor = i.betaTagColor
|
25
|
-
return children ? (_jsx(SidebarItemsGroup, { item: i }, name)) : (_jsx(Match, __assign({ path: path === "/" ? path : path.concat("/*") }, { children: function (prop) { return (_jsx(SidebarLink, { name: name, path: path, icon: icon, lock: lock, beta: beta, titleForLock: titleForLock, active: prop.match !== null, betaTagColor: betaTagColor
|
24
|
+
var children = i.children, path = i.path, icon = i.icon, name = i.name, lock = i.lock, beta = i.beta, titleForLock = i.titleForLock, betaTagColor = i.betaTagColor;
|
25
|
+
return children ? (_jsx(SidebarItemsGroup, { item: i }, name)) : (_jsx(Match, __assign({ path: path === "/" ? path : path.concat("/*") }, { children: function (prop) { return (_jsx(SidebarLink, { name: name, path: path, icon: icon, lock: lock, beta: beta, titleForLock: titleForLock, active: prop.match !== null, betaTagColor: betaTagColor }, name)); } }), name));
|
26
26
|
}) }) })));
|
27
27
|
}
|
28
28
|
export default Sidebar;
|