@campxdev/react-blueprint 0.1.8 → 0.1.10

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.8",
3
+ "version": "0.1.10",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "dependencies": {
@@ -314,3 +314,114 @@ export const LeftIcon = () => (
314
314
  </g>
315
315
  </svg>
316
316
  );
317
+
318
+ export const DashBoardIcon = () => {
319
+ const theme = useTheme();
320
+ const color = theme.palette.text.primary;
321
+ return (
322
+ <svg
323
+ xmlns="http://www.w3.org/2000/svg"
324
+ width="16"
325
+ height="16"
326
+ viewBox="0 0 16 16"
327
+ >
328
+ <g
329
+ id="vuesax_linear_chart-2"
330
+ data-name="vuesax/linear/chart-2"
331
+ transform="translate(-236 -188)"
332
+ >
333
+ <g id="chart-2" transform="translate(236 188)">
334
+ <path
335
+ id="Vector"
336
+ d="M4.667,13.333h4c3.333,0,4.667-1.333,4.667-4.667v-4C13.333,1.333,12,0,8.667,0h-4C1.333,0,0,1.333,0,4.667v4C0,12,1.333,13.333,4.667,13.333Z"
337
+ transform="translate(1.333 1.333)"
338
+ fill="none"
339
+ stroke={color}
340
+ stroke-linecap="round"
341
+ stroke-linejoin="round"
342
+ stroke-width="1.2"
343
+ />
344
+ <path
345
+ id="Vector-2"
346
+ data-name="Vector"
347
+ d="M1.333,8.667A1.337,1.337,0,0,0,2.667,7.333v-6A1.333,1.333,0,0,0,0,1.333v6A1.333,1.333,0,0,0,1.333,8.667Z"
348
+ transform="translate(9 3.667)"
349
+ fill="none"
350
+ stroke={color}
351
+ stroke-linecap="round"
352
+ stroke-linejoin="round"
353
+ stroke-width="1.2"
354
+ />
355
+ <path
356
+ id="Vector-3"
357
+ data-name="Vector"
358
+ d="M1.333,5A1.337,1.337,0,0,0,2.667,3.667V1.333A1.333,1.333,0,0,0,0,1.333V3.667A1.333,1.333,0,0,0,1.333,5Z"
359
+ transform="translate(4.333 7.333)"
360
+ fill="none"
361
+ stroke={color}
362
+ stroke-linecap="round"
363
+ stroke-linejoin="round"
364
+ stroke-width="1.2"
365
+ />
366
+ <path
367
+ id="Vector-4"
368
+ data-name="Vector"
369
+ d="M0,0H16V16H0Z"
370
+ fill="none"
371
+ opacity="0"
372
+ />
373
+ </g>
374
+ </g>
375
+ </svg>
376
+ );
377
+ };
378
+
379
+ export const HomeIcon = () => {
380
+ const theme = useTheme();
381
+ const color = theme.palette.text.primary;
382
+ return (
383
+ <svg
384
+ xmlns="http://www.w3.org/2000/svg"
385
+ width="16"
386
+ height="16"
387
+ viewBox="0 0 16 16"
388
+ >
389
+ <g
390
+ id="vuesax_linear_home-2"
391
+ data-name="vuesax/linear/home-2"
392
+ transform="translate(-620 -188)"
393
+ >
394
+ <g id="home-2" transform="translate(620 188)">
395
+ <path
396
+ id="Vector"
397
+ d="M4.68.548l-3.593,2.8A3.172,3.172,0,0,0,0,5.562V10.5a2.817,2.817,0,0,0,2.807,2.813h7.72a2.815,2.815,0,0,0,2.807-2.807V5.655a3.149,3.149,0,0,0-1.2-2.3L8.013.468A2.991,2.991,0,0,0,4.68.548Z"
398
+ transform="translate(1.333 1.345)"
399
+ fill="none"
400
+ stroke={color}
401
+ stroke-linecap="round"
402
+ stroke-linejoin="round"
403
+ stroke-width="1.2"
404
+ />
405
+ <path
406
+ id="Vector-2"
407
+ data-name="Vector"
408
+ d="M0,2V0"
409
+ transform="translate(8 9.993)"
410
+ fill="none"
411
+ stroke={color}
412
+ stroke-linecap="round"
413
+ stroke-linejoin="round"
414
+ stroke-width="1.2"
415
+ />
416
+ <path
417
+ id="Vector-3"
418
+ data-name="Vector"
419
+ d="M0,0H16V16H0Z"
420
+ fill="none"
421
+ opacity="0"
422
+ />
423
+ </g>
424
+ </g>
425
+ </svg>
426
+ );
427
+ };
@@ -1,4 +1,5 @@
1
1
  import { Meta, StoryObj } from "@storybook/react";
2
+ import { DashBoardIcon } from "../../../assets/images/icons";
2
3
  import { LayoutWrapper, LayoutWrapperProps } from "./LayoutWrapper";
3
4
 
4
5
  // Define the default export with Meta type including the component type
@@ -22,10 +23,9 @@ export const Primary: Story = {
22
23
  render: (args: LayoutWrapperProps) => <LayoutWrapper {...args} />,
23
24
  args: {
24
25
  menu: [
25
- { name: "Item 1", path: "/" },
26
+ { name: "Tickets", path: "/home", icon: DashBoardIcon },
26
27
  { name: "Item 2", path: "/item2" },
27
28
  ],
28
- title: "Home",
29
29
  children: <>hi</>,
30
30
  },
31
31
  };
@@ -1,9 +1,13 @@
1
- import { Box, IconButton, Toolbar, Typography } from "@mui/material";
1
+ import { IconButton, Toolbar, Typography } from "@mui/material";
2
2
 
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
6
  import { SideNavigation } from "../SideNavigation/SideNavigation";
7
+ import {
8
+ StyledLayoutContainer,
9
+ StyledMainContainer,
10
+ } from "../SideNavigation/styles/styles";
7
11
 
8
12
  export interface LayoutWrapperProps {
9
13
  title?: string;
@@ -22,43 +26,50 @@ export const LayoutWrapper = ({
22
26
  );
23
27
  const [isHovered, setIsHovered] = useState<boolean>(false);
24
28
 
29
+ const [active, setActive] = useState(0);
30
+
25
31
  const handleDrawer = () => {
26
32
  setOpen(!open);
27
33
  };
28
34
 
35
+ console.log(active, menu[active].name);
36
+
29
37
  return (
30
- <Box width={"100%"}>
31
- <Toolbar sx={{ paddingLeft: "0px !important" }}>
32
- {showIcon && (
33
- <IconButton
34
- color="inherit"
35
- aria-label="open drawer"
36
- onClick={handleDrawer}
37
- edge="start"
38
- sx={{ mr: 0.5 }}
39
- onMouseEnter={() => setIsHovered(true)}
40
- onMouseLeave={() => setIsHovered(false)}
41
- >
42
- {open && isHovered ? (
43
- <LeftIcon />
44
- ) : !open && isHovered ? (
45
- <RightIcon />
46
- ) : (
47
- <MenuIcon />
48
- )}
49
- </IconButton>
50
- )}
51
- <Typography variant="subtitle1" noWrap>
52
- {title}
53
- </Typography>
54
- </Toolbar>
38
+ <StyledLayoutContainer>
39
+ <StyledMainContainer>
40
+ <Toolbar sx={{ paddingLeft: "0px !important" }}>
41
+ {showIcon && (
42
+ <IconButton
43
+ color="inherit"
44
+ aria-label="open drawer"
45
+ onClick={handleDrawer}
46
+ edge="start"
47
+ sx={{ mr: 0.5 }}
48
+ onMouseEnter={() => setIsHovered(true)}
49
+ onMouseLeave={() => setIsHovered(false)}
50
+ >
51
+ {open && isHovered ? (
52
+ <LeftIcon />
53
+ ) : !open && isHovered ? (
54
+ <RightIcon />
55
+ ) : (
56
+ <MenuIcon />
57
+ )}
58
+ </IconButton>
59
+ )}
60
+ <Typography variant="subtitle1" noWrap>
61
+ {title ? title : menu[active].name}
62
+ </Typography>
63
+ </Toolbar>
55
64
 
56
- <SideNavigation
57
- menu={menu}
58
- children={children}
59
- open={open}
60
- handleDrawer={handleDrawer}
61
- />
62
- </Box>
65
+ <SideNavigation
66
+ menu={menu}
67
+ children={children}
68
+ open={open}
69
+ handleDrawer={handleDrawer}
70
+ setActive={setActive}
71
+ />
72
+ </StyledMainContainer>
73
+ </StyledLayoutContainer>
63
74
  );
64
75
  };
@@ -1,5 +1,6 @@
1
- import { Box, ListItemIcon, ListItemText, Stack } from "@mui/material";
1
+ import { ListItemIcon, Stack } from "@mui/material";
2
2
  import { useMatch, useResolvedPath } from "react-router-dom";
3
+ import { HomeIcon } from "../../../assets/images/icons";
3
4
  import { Typography } from "../../Typography/Typography";
4
5
  import {
5
6
  Main,
@@ -15,6 +16,7 @@ export interface SideNavigationProps {
15
16
  children: React.ReactNode;
16
17
  open?: any;
17
18
  handleDrawer?: any;
19
+ setActive: any;
18
20
  }
19
21
 
20
22
  export interface MenuItemProps {
@@ -26,6 +28,7 @@ export interface MenuItemProps {
26
28
  iconType: string;
27
29
  };
28
30
  index: number;
31
+ setActive: any;
29
32
  }
30
33
 
31
34
  export const SideNavigation = ({
@@ -33,6 +36,7 @@ export const SideNavigation = ({
33
36
  children,
34
37
  open,
35
38
  handleDrawer,
39
+ setActive,
36
40
  }: SideNavigationProps) => {
37
41
  return (
38
42
  <Stack gap="20px" direction={"row"}>
@@ -44,7 +48,12 @@ export const SideNavigation = ({
44
48
  >
45
49
  <StyledList>
46
50
  {menu?.map((item: any, index: number) => (
47
- <MenuItem menuItem={item} index={index} key={index} />
51
+ <MenuItem
52
+ menuItem={item}
53
+ index={index}
54
+ key={index}
55
+ setActive={setActive}
56
+ />
48
57
  ))}
49
58
  </StyledList>
50
59
  </StyledDrawer>
@@ -53,7 +62,7 @@ export const SideNavigation = ({
53
62
  );
54
63
  };
55
64
 
56
- const MenuItem = ({ menuItem, index }: MenuItemProps) => {
65
+ const MenuItem = ({ menuItem, index, setActive }: MenuItemProps) => {
57
66
  const { path, icon: Icon, name, permissionKey, iconType } = menuItem;
58
67
 
59
68
  let resolved = useResolvedPath(path);
@@ -64,46 +73,25 @@ const MenuItem = ({ menuItem, index }: MenuItemProps) => {
64
73
 
65
74
  // if (!hasAccess) return null
66
75
 
76
+ console.log(index, "path");
77
+
67
78
  return (
68
79
  <StyledListItem key={path} disablePadding match={match}>
69
80
  <StyledLinkButton
70
81
  to={path}
71
82
  style={{ width: "100%" }}
72
- // onClick={() =>
73
- // // sideNavStore.update((s) => {
74
- // // s.active = index
75
- // // })
76
- // }
83
+ onClick={() => setActive(index)}
77
84
  >
78
85
  <StyledListItemButton>
79
86
  <ListItemIcon
80
87
  sx={{
81
88
  minWidth: "16px",
82
89
  marginRight: "8px",
83
- display: "flex",
84
- alignItems: "center",
85
- justifyContent: "center",
86
90
  }}
87
91
  >
88
- <Box
89
- sx={{
90
- minWidth: "16px",
91
- marginRight: "8px",
92
- display: "flex",
93
- alignItems: "center",
94
- justifyContent: "center",
95
- }}
96
- >
97
- {/* <GetSidenavIconByType
98
- iconType={iconType}
99
- color={match ? '#323167' : '#000'}
100
- /> */}
101
- {/* {getSidenavIconByType(iconType, 'red')} */}
102
- </Box>
92
+ {Icon ? <Icon /> : <HomeIcon />}
103
93
  </ListItemIcon>
104
- <ListItemText
105
- primary={<Typography variant="subtitle3">{name}</Typography>}
106
- />
94
+ <Typography variant="subtitle3">{name}</Typography>
107
95
  </StyledListItemButton>
108
96
  </StyledLinkButton>
109
97
  </StyledListItem>
@@ -1,4 +1,11 @@
1
- import { Drawer, List, ListItem, ListItemButton, styled } from "@mui/material";
1
+ import {
2
+ Box,
3
+ Drawer,
4
+ List,
5
+ ListItem,
6
+ ListItemButton,
7
+ styled,
8
+ } from "@mui/material";
2
9
  import { Link } from "react-router-dom";
3
10
  const drawerWidth: number = 240;
4
11
 
@@ -20,12 +27,6 @@ export const StyledDrawer = styled(Drawer)(() => ({
20
27
  },
21
28
  }));
22
29
 
23
- export const StyledList = styled(List)(({ theme }) => ({
24
- backgroundColor: theme.palette.background.paper,
25
- height: "calc(100vh - 120px)",
26
- paddingTop: "20px",
27
- }));
28
-
29
30
  interface StyledListItemProps {
30
31
  match: any;
31
32
  }
@@ -33,13 +34,16 @@ interface StyledListItemProps {
33
34
  export const StyledListItem = styled(ListItem)<StyledListItemProps>(
34
35
  ({ theme, match }) => ({
35
36
  backgroundColor: match ? theme.palette.secondary.main : "none",
37
+ width: "auto",
38
+ margin: "5px 8px",
39
+ borderRadius: "5px",
36
40
  })
37
41
  );
38
42
  export const StyledListItemButton = styled(ListItemButton)(() => ({
39
43
  alignItems: "center",
40
44
  display: "flex",
41
- paddingBottom: "4px",
42
- paddingTop: "4px",
45
+ paddingBottom: "5px",
46
+ paddingTop: "5px",
43
47
  }));
44
48
 
45
49
  export const StyledLinkButton = styled(Link)({
@@ -82,3 +86,22 @@ export const Main = styled("main", {
82
86
  marginLeft: 0,
83
87
  },
84
88
  }));
89
+
90
+ export const StyledMainContainer = styled("main")(() => ({
91
+ width: "90%",
92
+ margin: "auto",
93
+ overflowY: "auto",
94
+ }));
95
+
96
+ export const StyledLayoutContainer = styled(Box)(({ theme }) => ({
97
+ width: "100%",
98
+ position: "fixed",
99
+ top: "60px",
100
+ backgroundColor: theme.palette.background.default,
101
+ }));
102
+
103
+ export const StyledList = styled(List)(({ theme }) => ({
104
+ backgroundColor: theme.palette.background.paper,
105
+ height: "calc(100vh - 120px)",
106
+ paddingTop: "20px",
107
+ }));