@campxdev/react-blueprint 0.1.14 → 0.1.15

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.14",
3
+ "version": "0.1.15",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "dependencies": {
@@ -1,12 +1,14 @@
1
+ import { Button, Stack } from "@mui/material";
1
2
  import { Meta, StoryObj } from "@storybook/react";
2
3
  import { DashBoardIcon } from "../../../assets/images/icons";
3
- import { LayoutWrapper, LayoutWrapperProps } from "./LayoutWrapper";
4
4
  import DialogButton from "../../Modals/DialogButton";
5
- import { Button } from "@mui/material";
5
+ import { PageContent } from "../PageContent/PageContent";
6
+ import { SideNavigation } from "../SideNavigation/SideNavigation";
7
+ import { LayoutWrapper, LayoutWrapperProps } from "./LayoutWrapper";
6
8
 
7
9
  const LayoutWrapperStory = (props: LayoutWrapperProps) => {
8
10
  return (
9
- <div style={{ minHeight: "300px" }}>
11
+ <div style={{ minHeight: "500px" }}>
10
12
  <LayoutWrapper {...props} />
11
13
  </div>
12
14
  );
@@ -32,11 +34,24 @@ type Story = StoryObj<typeof LayoutWrapperStory>;
32
34
  export const Primary: Story = {
33
35
  render: (args: LayoutWrapperProps) => <LayoutWrapperStory {...args} />,
34
36
  args: {
35
- menu: [
36
- { name: "Tickets", path: "/home", icon: DashBoardIcon },
37
- { name: "Item 2", path: "/item2" },
38
- ],
39
- children: <>hi</>,
37
+ sideBar: ({ open, handleClick }: any) => (
38
+ <SideNavigation
39
+ open={open}
40
+ handleDrawer={handleClick}
41
+ menu={[
42
+ { name: "Tickets", path: "/home", icon: DashBoardIcon },
43
+ { name: "Item 2", path: "/item2" },
44
+ ]}
45
+ />
46
+ ),
47
+ children: (
48
+ <>
49
+ <Stack alignItems={"flex-end"}>
50
+ <Button variant="contained">Add Tickets</Button>
51
+ </Stack>
52
+ <PageContent>Mahesh</PageContent>
53
+ </>
54
+ ),
40
55
  actionButtons: [
41
56
  <DialogButton
42
57
  anchor={({ open }) => (
@@ -50,25 +65,3 @@ export const Primary: Story = {
50
65
  ],
51
66
  },
52
67
  };
53
-
54
- export const WithActionButtons: Story = {
55
- render: (args: LayoutWrapperProps) => <LayoutWrapperStory {...args} />,
56
- args: {
57
- menu: [
58
- { name: "Tickets", path: "/home", icon: DashBoardIcon },
59
- { name: "Item 2", path: "/item2" },
60
- ],
61
- children: <>hi</>,
62
- actionButtons: [
63
- <DialogButton
64
- anchor={({ open }) => (
65
- <Button variant="contained" onClick={open}>
66
- Click Me
67
- </Button>
68
- )}
69
- content={({ close }) => <Button onClick={close}>Click Me</Button>}
70
- title="Dialog Title"
71
- />,
72
- ],
73
- },
74
- };
@@ -1,91 +1,72 @@
1
- import { Box, IconButton, Stack, Toolbar, Typography } from "@mui/material";
1
+ import { Box, IconButton, Stack, Typography } from "@mui/material";
2
2
 
3
3
  import MenuIcon from "@mui/icons-material/Menu";
4
- import { useState } from "react";
4
+ import { ReactNode, useState } from "react";
5
5
  import { LeftIcon, RightIcon } from "../../../assets/images/icons";
6
6
  import { activeStore } from "../../../store/activeStore";
7
- import { SideNavigation } from "../SideNavigation/SideNavigation";
8
- import {
9
- StyledLayoutContainer,
10
- StyledMainContainer,
11
- } from "../SideNavigation/styles/styles";
7
+ import { Main, StyledLayoutContainer, StyledMainContainer } from "./styles";
12
8
 
13
9
  export interface LayoutWrapperProps {
14
10
  title?: string;
15
- actionButtons?: React.ReactNode[];
16
- children: React.ReactNode;
17
- showIcon?: boolean;
18
- menu?: any;
11
+ actionButtons?: ReactNode[];
12
+ children: ReactNode;
13
+ sideBar: (props: {
14
+ open: boolean;
15
+ handleClick: (e: any) => void;
16
+ }) => ReactNode;
19
17
  }
18
+
20
19
  export const LayoutWrapper = ({
21
20
  children,
22
21
  title,
23
- showIcon = true,
24
- menu,
25
- actionButtons,
22
+ sideBar,
26
23
  }: LayoutWrapperProps) => {
27
- const [open, setOpen] = useState<boolean>(
28
- window.innerWidth > 1024 ? true : false
29
- );
30
24
  const [isHovered, setIsHovered] = useState<boolean>(false);
25
+ const { open } = activeStore.useState((s) => s);
31
26
 
32
- const { active } = activeStore.useState((s) => s);
33
-
34
- const handleDrawer = () => {
35
- setOpen(!open);
27
+ const handleClick = () => {
28
+ activeStore.update((s) => {
29
+ s.open = !open;
30
+ });
36
31
  };
37
32
 
38
33
  return (
39
34
  <StyledLayoutContainer>
40
35
  <StyledMainContainer>
41
- <Toolbar
42
- sx={{
43
- padding: "0px !important",
44
- }}
45
- >
46
- {showIcon && (
47
- <>
48
- <Stack
49
- direction={"row"}
50
- width={"100%"}
51
- justifyContent={"space-between"}
36
+ <Box>
37
+ <Stack
38
+ direction={"row"}
39
+ width={"100%"}
40
+ justifyContent={"space-between"}
41
+ >
42
+ <Stack direction={"row"} alignItems={"center"}>
43
+ <IconButton
44
+ color="inherit"
45
+ aria-label="open drawer"
46
+ onClick={handleClick}
47
+ edge="start"
48
+ sx={{ mr: 0.5, padding: "6px", marginLeft: "0px" }}
49
+ onMouseEnter={() => setIsHovered(true)}
50
+ onMouseLeave={() => setIsHovered(false)}
52
51
  >
53
- <Stack direction={"row"}>
54
- <IconButton
55
- color="inherit"
56
- aria-label="open drawer"
57
- onClick={handleDrawer}
58
- edge="start"
59
- sx={{ mr: 0.5, padding: "6px", marginLeft: "0px" }}
60
- onMouseEnter={() => setIsHovered(true)}
61
- onMouseLeave={() => setIsHovered(false)}
62
- >
63
- {open && isHovered ? (
64
- <LeftIcon />
65
- ) : !open && isHovered ? (
66
- <RightIcon />
67
- ) : (
68
- <MenuIcon />
69
- )}
70
- </IconButton>
71
- <Typography variant="subtitle1" noWrap>
72
- {title ? title : menu[active].name}
73
- </Typography>
74
- </Stack>
75
- <Stack direction={"row"} alignItems={"flex-end"}>
76
- {actionButtons?.map((element) => element)}
77
- </Stack>
78
- </Stack>
79
- </>
80
- )}
81
- </Toolbar>
52
+ {open && isHovered ? (
53
+ <LeftIcon />
54
+ ) : !open && isHovered ? (
55
+ <RightIcon />
56
+ ) : (
57
+ <MenuIcon />
58
+ )}
59
+ </IconButton>
60
+ <Typography variant="subtitle1" noWrap>
61
+ {title ? title : ""}
62
+ </Typography>
63
+ </Stack>
64
+ </Stack>
65
+
66
+ {sideBar({ open: open, handleClick: handleClick })}
67
+ </Box>
82
68
 
83
- <SideNavigation
84
- menu={menu}
85
- children={children}
86
- open={open}
87
- handleDrawer={handleDrawer}
88
- />
69
+ <Main open={open}>{children}</Main>
89
70
  </StyledMainContainer>
90
71
  </StyledLayoutContainer>
91
72
  );
@@ -0,0 +1,52 @@
1
+ import { Box, styled } from "@mui/material";
2
+
3
+ const drawerWidth: number = 240;
4
+
5
+ export const Main = styled("main", {
6
+ shouldForwardProp: (prop) => prop !== "open",
7
+ })<{
8
+ open?: boolean;
9
+ }>(({ theme, open }) => ({
10
+ padding: "0px 25px",
11
+ transition: theme.transitions.create("margin", {
12
+ easing: theme.transitions.easing.sharp,
13
+ duration: theme.transitions.duration.leavingScreen,
14
+ }),
15
+ marginLeft: `-${drawerWidth}px`,
16
+ ...(open && {
17
+ transition: theme.transitions.create("margin", {
18
+ easing: theme.transitions.easing.easeOut,
19
+ duration: theme.transitions.duration.enteringScreen,
20
+ }),
21
+ marginLeft: 0,
22
+ }),
23
+ width: "100%",
24
+ overflowY: "auto",
25
+ borderRadius: "5px",
26
+ "&::-webkit-scrollbar": {
27
+ width: "0.4em",
28
+ height: "0.4em",
29
+ },
30
+
31
+ "&::-webkit-scrollbar-thumb": {
32
+ backgroundColor: "rgba(0, 0, 0, 0.2)",
33
+ borderRadius: "3px",
34
+ },
35
+ "@media (max-width: 1024px)": {
36
+ marginLeft: 0,
37
+ },
38
+ }));
39
+
40
+ export const StyledLayoutContainer = styled(Box)(({ theme }) => ({
41
+ width: "100%",
42
+ position: "fixed",
43
+ top: "70px",
44
+ backgroundColor: theme.palette.background.default,
45
+ }));
46
+
47
+ export const StyledMainContainer = styled("main")(() => ({
48
+ width: "90%",
49
+ margin: "auto",
50
+ overflowY: "auto",
51
+ display: "flex",
52
+ }));
@@ -0,0 +1,26 @@
1
+ import { Box, styled } from "@mui/material";
2
+
3
+ export const StyledContainer = styled(Box)(({ theme }) => ({
4
+ width: "100%",
5
+ height: "calc(100vh - 120px)",
6
+ overflowY: "auto",
7
+ backgroundColor: theme.palette.background.paper,
8
+ borderRadius: "5px",
9
+ "&::-webkit-scrollbar": {
10
+ width: "0.4em",
11
+ height: "0.4em",
12
+ },
13
+ "&::-webkit-scrollbar-thumb": {
14
+ backgroundColor: "rgba(0, 0, 0, 0.2)",
15
+ borderRadius: "3px",
16
+ },
17
+ "@media (max-width: 1024px)": {
18
+ marginLeft: 0,
19
+ },
20
+ padding: "25px",
21
+ marginTop: "10px",
22
+ }));
23
+
24
+ export const PageContent = ({ children }: { children: React.ReactNode }) => {
25
+ return <StyledContainer> {children}</StyledContainer>;
26
+ };
@@ -4,7 +4,6 @@ import { HomeIcon } from "../../../assets/images/icons";
4
4
  import { activeStore } from "../../../store/activeStore";
5
5
  import { Typography } from "../../Typography/Typography";
6
6
  import {
7
- Main,
8
7
  StyledDrawer,
9
8
  StyledLinkButton,
10
9
  StyledList,
@@ -14,7 +13,6 @@ import {
14
13
 
15
14
  export interface SideNavigationProps {
16
15
  menu?: any;
17
- children: React.ReactNode;
18
16
  open?: any;
19
17
  handleDrawer?: any;
20
18
  }
@@ -32,12 +30,11 @@ export interface MenuItemProps {
32
30
 
33
31
  export const SideNavigation = ({
34
32
  menu,
35
- children,
36
33
  open,
37
34
  handleDrawer,
38
35
  }: SideNavigationProps) => {
39
36
  return (
40
- <Stack gap="20px" direction={"row"}>
37
+ <Stack gap="20px" direction={"row"} marginTop={"10px"}>
41
38
  <StyledDrawer
42
39
  variant={window.innerWidth > 1024 ? "persistent" : "temporary"}
43
40
  anchor="left"
@@ -50,7 +47,6 @@ export const SideNavigation = ({
50
47
  ))}
51
48
  </StyledList>
52
49
  </StyledDrawer>
53
- <Main open={open}>{children}</Main>
54
50
  </Stack>
55
51
  );
56
52
  };
@@ -1,11 +1,4 @@
1
- import {
2
- Box,
3
- Drawer,
4
- List,
5
- ListItem,
6
- ListItemButton,
7
- styled,
8
- } from "@mui/material";
1
+ import { Drawer, List, ListItem, ListItemButton, styled } from "@mui/material";
9
2
  import { Link } from "react-router-dom";
10
3
  const drawerWidth: number = 240;
11
4
 
@@ -53,56 +46,6 @@ export const StyledLinkButton = styled(Link)({
53
46
  },
54
47
  });
55
48
 
56
- export const Main = styled("main", {
57
- shouldForwardProp: (prop) => prop !== "open",
58
- })<{
59
- open?: boolean;
60
- }>(({ theme, open }) => ({
61
- padding: "25px",
62
- transition: theme.transitions.create("margin", {
63
- easing: theme.transitions.easing.sharp,
64
- duration: theme.transitions.duration.leavingScreen,
65
- }),
66
- marginLeft: `-${drawerWidth}px`,
67
- ...(open && {
68
- transition: theme.transitions.create("margin", {
69
- easing: theme.transitions.easing.easeOut,
70
- duration: theme.transitions.duration.enteringScreen,
71
- }),
72
- marginLeft: 0,
73
- }),
74
- width: "100%",
75
- height: "calc(100vh - 120px)",
76
- overflowY: "auto",
77
- backgroundColor: theme.palette.background.paper,
78
- borderRadius: "5px",
79
- "&::-webkit-scrollbar": {
80
- width: "0.4em",
81
- height: "0.4em",
82
- },
83
-
84
- "&::-webkit-scrollbar-thumb": {
85
- backgroundColor: "rgba(0, 0, 0, 0.2)",
86
- borderRadius: "3px",
87
- },
88
- "@media (max-width: 1024px)": {
89
- marginLeft: 0,
90
- },
91
- }));
92
-
93
- export const StyledMainContainer = styled("main")(() => ({
94
- width: "90%",
95
- margin: "auto",
96
- overflowY: "auto",
97
- }));
98
-
99
- export const StyledLayoutContainer = styled(Box)(({ theme }) => ({
100
- width: "100%",
101
- position: "fixed",
102
- top: "60px",
103
- backgroundColor: theme.palette.background.default,
104
- }));
105
-
106
49
  export const StyledList = styled(List)(({ theme }) => ({
107
50
  backgroundColor: theme.palette.background.paper,
108
51
  height: "calc(100vh - 120px)",
@@ -8,3 +8,5 @@ export * from "./Layout/Header/AppHeader";
8
8
  export * from "./Layout/Header/AppLogo";
9
9
  export * from "./Layout/Header/AppsMenu";
10
10
  export * from "./Layout/LayoutWrapper/LayoutWrapper";
11
+ export * from "./Layout/PageContent/PageContent";
12
+ export * from "./Layout/SideNavigation/SideNavigation";
@@ -2,4 +2,5 @@ import { Store } from "pullstate";
2
2
 
3
3
  export const activeStore = new Store({
4
4
  active: 0,
5
+ open: window.innerWidth > 1024 ? true : false,
5
6
  });