@campxdev/react-blueprint 0.1.8 → 0.1.9
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@campxdev/react-blueprint",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"main": "./export.ts",
|
|
5
5
|
"private": false,
|
|
6
6
|
"dependencies": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"build": "react-scripts build",
|
|
32
32
|
"test": "react-scripts test",
|
|
33
33
|
"eject": "react-scripts eject",
|
|
34
|
+
"push-package": "npm run build && npm publish",
|
|
34
35
|
"storybook": "storybook dev -p 6006",
|
|
35
36
|
"build-storybook": "storybook build"
|
|
36
37
|
},
|
|
@@ -22,10 +22,9 @@ export const Primary: Story = {
|
|
|
22
22
|
render: (args: LayoutWrapperProps) => <LayoutWrapper {...args} />,
|
|
23
23
|
args: {
|
|
24
24
|
menu: [
|
|
25
|
-
{ name: "
|
|
25
|
+
{ name: "Home", path: "/home" },
|
|
26
26
|
{ name: "Item 2", path: "/item2" },
|
|
27
27
|
],
|
|
28
|
-
title: "Home",
|
|
29
28
|
children: <>hi</>,
|
|
30
29
|
},
|
|
31
30
|
};
|
|
@@ -22,6 +22,8 @@ export const LayoutWrapper = ({
|
|
|
22
22
|
);
|
|
23
23
|
const [isHovered, setIsHovered] = useState<boolean>(false);
|
|
24
24
|
|
|
25
|
+
const [active, setActive] = useState(0);
|
|
26
|
+
|
|
25
27
|
const handleDrawer = () => {
|
|
26
28
|
setOpen(!open);
|
|
27
29
|
};
|
|
@@ -49,7 +51,7 @@ export const LayoutWrapper = ({
|
|
|
49
51
|
</IconButton>
|
|
50
52
|
)}
|
|
51
53
|
<Typography variant="subtitle1" noWrap>
|
|
52
|
-
{title}
|
|
54
|
+
{title ? title : menu[active].name}
|
|
53
55
|
</Typography>
|
|
54
56
|
</Toolbar>
|
|
55
57
|
|
|
@@ -58,6 +60,7 @@ export const LayoutWrapper = ({
|
|
|
58
60
|
children={children}
|
|
59
61
|
open={open}
|
|
60
62
|
handleDrawer={handleDrawer}
|
|
63
|
+
setActive={setActive}
|
|
61
64
|
/>
|
|
62
65
|
</Box>
|
|
63
66
|
);
|
|
@@ -15,6 +15,7 @@ export interface SideNavigationProps {
|
|
|
15
15
|
children: React.ReactNode;
|
|
16
16
|
open?: any;
|
|
17
17
|
handleDrawer?: any;
|
|
18
|
+
setActive: any;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export interface MenuItemProps {
|
|
@@ -26,6 +27,7 @@ export interface MenuItemProps {
|
|
|
26
27
|
iconType: string;
|
|
27
28
|
};
|
|
28
29
|
index: number;
|
|
30
|
+
setActive: any;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
export const SideNavigation = ({
|
|
@@ -33,6 +35,7 @@ export const SideNavigation = ({
|
|
|
33
35
|
children,
|
|
34
36
|
open,
|
|
35
37
|
handleDrawer,
|
|
38
|
+
setActive,
|
|
36
39
|
}: SideNavigationProps) => {
|
|
37
40
|
return (
|
|
38
41
|
<Stack gap="20px" direction={"row"}>
|
|
@@ -44,7 +47,12 @@ export const SideNavigation = ({
|
|
|
44
47
|
>
|
|
45
48
|
<StyledList>
|
|
46
49
|
{menu?.map((item: any, index: number) => (
|
|
47
|
-
<MenuItem
|
|
50
|
+
<MenuItem
|
|
51
|
+
menuItem={item}
|
|
52
|
+
index={index}
|
|
53
|
+
key={index}
|
|
54
|
+
setActive={setActive}
|
|
55
|
+
/>
|
|
48
56
|
))}
|
|
49
57
|
</StyledList>
|
|
50
58
|
</StyledDrawer>
|
|
@@ -53,7 +61,7 @@ export const SideNavigation = ({
|
|
|
53
61
|
);
|
|
54
62
|
};
|
|
55
63
|
|
|
56
|
-
const MenuItem = ({ menuItem, index }: MenuItemProps) => {
|
|
64
|
+
const MenuItem = ({ menuItem, index, setActive }: MenuItemProps) => {
|
|
57
65
|
const { path, icon: Icon, name, permissionKey, iconType } = menuItem;
|
|
58
66
|
|
|
59
67
|
let resolved = useResolvedPath(path);
|
|
@@ -69,20 +77,13 @@ const MenuItem = ({ menuItem, index }: MenuItemProps) => {
|
|
|
69
77
|
<StyledLinkButton
|
|
70
78
|
to={path}
|
|
71
79
|
style={{ width: "100%" }}
|
|
72
|
-
|
|
73
|
-
// // sideNavStore.update((s) => {
|
|
74
|
-
// // s.active = index
|
|
75
|
-
// // })
|
|
76
|
-
// }
|
|
80
|
+
onClick={() => setActive(index)}
|
|
77
81
|
>
|
|
78
82
|
<StyledListItemButton>
|
|
79
83
|
<ListItemIcon
|
|
80
84
|
sx={{
|
|
81
85
|
minWidth: "16px",
|
|
82
86
|
marginRight: "8px",
|
|
83
|
-
display: "flex",
|
|
84
|
-
alignItems: "center",
|
|
85
|
-
justifyContent: "center",
|
|
86
87
|
}}
|
|
87
88
|
>
|
|
88
89
|
<Box
|
package/src/components/export.ts
CHANGED