@campxdev/react-blueprint 0.1.11 → 0.1.12

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.11",
3
+ "version": "0.1.12",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "dependencies": {
@@ -23,7 +23,7 @@ export const Primary: Story = {
23
23
  render: (args: LayoutWrapperProps) => <LayoutWrapper {...args} />,
24
24
  args: {
25
25
  menu: [
26
- { name: "Tickets", path: "/home", icon: DashBoardIcon },
26
+ { name: "Tickets", path: "/", icon: DashBoardIcon },
27
27
  { name: "Item 2", path: "/item2" },
28
28
  ],
29
29
  children: <>hi</>,
@@ -3,6 +3,7 @@ import { IconButton, Toolbar, Typography } from "@mui/material";
3
3
  import MenuIcon from "@mui/icons-material/Menu";
4
4
  import { useState } from "react";
5
5
  import { LeftIcon, RightIcon } from "../../../assets/images/icons";
6
+ import { activeStore } from "../../../store/activeStore";
6
7
  import { SideNavigation } from "../SideNavigation/SideNavigation";
7
8
  import {
8
9
  StyledLayoutContainer,
@@ -26,14 +27,12 @@ export const LayoutWrapper = ({
26
27
  );
27
28
  const [isHovered, setIsHovered] = useState<boolean>(false);
28
29
 
29
- const [active, setActive] = useState(0);
30
+ const { active } = activeStore.useState((s) => s);
30
31
 
31
32
  const handleDrawer = () => {
32
33
  setOpen(!open);
33
34
  };
34
35
 
35
- console.log(active, menu[active].name);
36
-
37
36
  return (
38
37
  <StyledLayoutContainer>
39
38
  <StyledMainContainer>
@@ -44,7 +43,7 @@ export const LayoutWrapper = ({
44
43
  aria-label="open drawer"
45
44
  onClick={handleDrawer}
46
45
  edge="start"
47
- sx={{ mr: 0.5 }}
46
+ sx={{ mr: 0.5, padding: "6px", marginLeft: "0px" }}
48
47
  onMouseEnter={() => setIsHovered(true)}
49
48
  onMouseLeave={() => setIsHovered(false)}
50
49
  >
@@ -67,7 +66,6 @@ export const LayoutWrapper = ({
67
66
  children={children}
68
67
  open={open}
69
68
  handleDrawer={handleDrawer}
70
- setActive={setActive}
71
69
  />
72
70
  </StyledMainContainer>
73
71
  </StyledLayoutContainer>
@@ -1,11 +1,11 @@
1
- import { ListItemIcon, Stack } from "@mui/material";
1
+ import { Link, ListItemIcon, Stack } from "@mui/material";
2
2
  import { useMatch, useResolvedPath } from "react-router-dom";
3
3
  import { HomeIcon } from "../../../assets/images/icons";
4
+ import { activeStore } from "../../../store/activeStore";
4
5
  import { Typography } from "../../Typography/Typography";
5
6
  import {
6
7
  Main,
7
8
  StyledDrawer,
8
- StyledLinkButton,
9
9
  StyledList,
10
10
  StyledListItem,
11
11
  StyledListItemButton,
@@ -16,7 +16,6 @@ export interface SideNavigationProps {
16
16
  children: React.ReactNode;
17
17
  open?: any;
18
18
  handleDrawer?: any;
19
- setActive: any;
20
19
  }
21
20
 
22
21
  export interface MenuItemProps {
@@ -28,7 +27,6 @@ export interface MenuItemProps {
28
27
  iconType: string;
29
28
  };
30
29
  index: number;
31
- setActive: any;
32
30
  }
33
31
 
34
32
  export const SideNavigation = ({
@@ -36,7 +34,6 @@ export const SideNavigation = ({
36
34
  children,
37
35
  open,
38
36
  handleDrawer,
39
- setActive,
40
37
  }: SideNavigationProps) => {
41
38
  return (
42
39
  <Stack gap="20px" direction={"row"}>
@@ -48,12 +45,7 @@ export const SideNavigation = ({
48
45
  >
49
46
  <StyledList>
50
47
  {menu?.map((item: any, index: number) => (
51
- <MenuItem
52
- menuItem={item}
53
- index={index}
54
- key={index}
55
- setActive={setActive}
56
- />
48
+ <MenuItem menuItem={item} index={index} key={index} />
57
49
  ))}
58
50
  </StyledList>
59
51
  </StyledDrawer>
@@ -62,7 +54,7 @@ export const SideNavigation = ({
62
54
  );
63
55
  };
64
56
 
65
- const MenuItem = ({ menuItem, index, setActive }: MenuItemProps) => {
57
+ const MenuItem = ({ menuItem, index }: MenuItemProps) => {
66
58
  const { path, icon: Icon, name, permissionKey, iconType } = menuItem;
67
59
 
68
60
  let resolved = useResolvedPath(path);
@@ -73,14 +65,16 @@ const MenuItem = ({ menuItem, index, setActive }: MenuItemProps) => {
73
65
 
74
66
  // if (!hasAccess) return null
75
67
 
76
- console.log(index, "path");
77
-
78
68
  return (
79
69
  <StyledListItem key={path} disablePadding match={match}>
80
- <StyledLinkButton
81
- to={path}
70
+ <Link
71
+ href={path}
82
72
  style={{ width: "100%" }}
83
- onClick={() => setActive(index)}
73
+ onClick={() =>
74
+ activeStore.update((s) => {
75
+ s.active = index;
76
+ })
77
+ }
84
78
  >
85
79
  <StyledListItemButton>
86
80
  <ListItemIcon
@@ -93,7 +87,7 @@ const MenuItem = ({ menuItem, index, setActive }: MenuItemProps) => {
93
87
  </ListItemIcon>
94
88
  <Typography variant="subtitle3">{name}</Typography>
95
89
  </StyledListItemButton>
96
- </StyledLinkButton>
90
+ </Link>
97
91
  </StyledListItem>
98
92
  );
99
93
  };
@@ -0,0 +1,5 @@
1
+ import { Store } from "pullstate";
2
+
3
+ export const activeStore = new Store({
4
+ active: 0,
5
+ });
@@ -76,9 +76,9 @@ export const getCommonTheme = (mode: Theme) => {
76
76
  "& li": {
77
77
  borderBottom: "1212121A",
78
78
  minHeight: "55px",
79
- ":hover": {
80
- backgroundColor: "rgba(0, 0, 0, 0.025)",
81
- },
79
+ // ":hover": {
80
+ // backgroundColor: "rgba(0, 0, 0, 0.025)",
81
+ // },
82
82
  },
83
83
  "& > :last-child": {
84
84
  borderBottom: "none",