@campxdev/react-blueprint 0.1.5 → 0.1.7

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,13 +1,13 @@
1
1
  {
2
2
  "name": "@campxdev/react-blueprint",
3
- "version": "0.1.5",
4
- "main":"./export.ts",
3
+ "version": "0.1.7",
4
+ "main": "./export.ts",
5
5
  "private": false,
6
6
  "dependencies": {
7
7
  "@emotion/react": "^11.11.4",
8
8
  "@emotion/styled": "^11.11.5",
9
- "@mui/icons-material": "^5.14.11",
10
- "@mui/material": "^5.14.11",
9
+ "@mui/icons-material": "^5.15.18",
10
+ "@mui/material": "^5.15.18",
11
11
  "@testing-library/jest-dom": "^5.14.1",
12
12
  "@testing-library/react": "^13.0.0",
13
13
  "@testing-library/user-event": "^13.2.1",
@@ -22,7 +22,7 @@
22
22
  "react-dom": "^18.3.1",
23
23
  "react-router-dom": "^6.4.2",
24
24
  "react-scripts": "5.0.1",
25
- "typescript": "^4.4.2",
25
+ "typescript": "^5.3.3",
26
26
  "web-vitals": "^2.1.0"
27
27
  },
28
28
  "scripts": {
@@ -54,7 +54,6 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
57
- "@types/js-cookie": "^3.0.5",
58
57
  "@chromatic-com/storybook": "^1.4.0",
59
58
  "@storybook/addon-essentials": "^8.1.1",
60
59
  "@storybook/addon-interactions": "^8.1.1",
@@ -66,6 +65,7 @@
66
65
  "@storybook/react": "^8.1.1",
67
66
  "@storybook/react-webpack5": "^8.1.1",
68
67
  "@storybook/test": "^8.1.1",
68
+ "@types/js-cookie": "^3.0.5",
69
69
  "eslint-plugin-storybook": "^0.8.0",
70
70
  "prop-types": "^15.8.1",
71
71
  "storybook": "^8.1.1",
@@ -2,8 +2,8 @@ import { IconButton } from "@mui/material";
2
2
  import { Meta, StoryObj } from "@storybook/react";
3
3
  import { CareerIcon, ExamResultIcon } from "../../../assets/images/icons";
4
4
  import { MenuItemButton } from "../../DropDownMenu/MenuItemButton";
5
- import AppHeader, { AppHeaderProps } from "./AppHeader";
6
- import AppsMenu from "./AppsMenu";
5
+ import { AppHeader, AppHeaderProps } from "./AppHeader";
6
+ import { AppsMenu } from "./AppsMenu";
7
7
 
8
8
  // Define the default export with Meta type including the component type
9
9
  const meta: Meta<typeof AppHeader> = {
@@ -1,6 +1,6 @@
1
1
  import { Stack } from "@mui/material";
2
2
  import { ReactNode } from "react";
3
- import AppLogo from "./AppLogo";
3
+ import { AppLogo } from "./AppLogo";
4
4
  import HeaderActions from "./HeaderActions/HeaderActions";
5
5
  import {
6
6
  StyledActionBox,
@@ -27,7 +27,7 @@ export interface AppHeaderProps {
27
27
  profileSx?: any;
28
28
  }
29
29
 
30
- const AppHeader = ({
30
+ export const AppHeader = ({
31
31
  actions = [],
32
32
  appsMenu,
33
33
  clientLogo,
@@ -66,5 +66,3 @@ const AppHeader = ({
66
66
  </StyledHeader>
67
67
  );
68
68
  };
69
-
70
- export default AppHeader;
@@ -13,7 +13,7 @@ export interface AppLogoProps {
13
13
  imageSx?: any;
14
14
  }
15
15
 
16
- const AppLogo = ({ clientLogo, imageSx }: AppLogoProps) => {
16
+ export const AppLogo = ({ clientLogo, imageSx }: AppLogoProps) => {
17
17
  const originSubdomain =
18
18
  window.location.host.split(".")?.slice(-3)[0] ?? "ums";
19
19
  const currentApp: string =
@@ -49,5 +49,3 @@ const AppLogo = ({ clientLogo, imageSx }: AppLogoProps) => {
49
49
  </StyledRouterLink>
50
50
  );
51
51
  };
52
-
53
- export default AppLogo;
@@ -25,7 +25,6 @@ export const AppsMenu = ({ apps }: { apps: string[] }) => {
25
25
  <StyledIconButton onClick={handleClick}>
26
26
  <AppsIcon />
27
27
  </StyledIconButton>
28
-
29
28
  <Menu
30
29
  transitionDuration={150}
31
30
  elevation={2}
@@ -109,9 +108,7 @@ const MenuItem = ({ item }: any) => {
109
108
  );
110
109
  };
111
110
 
112
- export default AppsMenu;
113
-
114
- export const StyledIconButton = styled(IconButton)(({ theme }) => ({
111
+ const StyledIconButton = styled(IconButton)(({ theme }) => ({
115
112
  padding: "18px",
116
113
  backgroundColor: "black",
117
114
  display: "flex",
@@ -123,12 +120,12 @@ export const StyledIconButton = styled(IconButton)(({ theme }) => ({
123
120
  border: `1px solid ${theme.palette.background.default}`,
124
121
  }));
125
122
 
126
- export const StyledMenuItemContainer = styled(Box)(({ theme }) => ({
123
+ const StyledMenuItemContainer = styled(Box)(({ theme }) => ({
127
124
  cursor: "pointer",
128
125
  padding: "5px 0px",
129
126
  }));
130
127
 
131
- export const StyledMenuItem = styled(Box)({
128
+ const StyledMenuItem = styled(Box)({
132
129
  height: "68px",
133
130
  width: "380px",
134
131
  padding: "40px 20px",
@@ -141,7 +138,7 @@ export const StyledMenuItem = styled(Box)({
141
138
  gap: "20px",
142
139
  });
143
140
 
144
- export const StyledImageBox = styled(Box)(() => ({
141
+ const StyledImageBox = styled(Box)(() => ({
145
142
  height: "40px",
146
143
  width: "40px",
147
144
  boxShadow: "0px 5px 5px 0px rgba(48, 62, 99,0.1) ",
@@ -151,7 +148,7 @@ export const StyledImageBox = styled(Box)(() => ({
151
148
  borderRadius: "5px",
152
149
  }));
153
150
 
154
- export const StyledNoAppContainer = styled(Box)({
151
+ const StyledNoAppContainer = styled(Box)({
155
152
  width: "300px",
156
153
  height: "300px",
157
154
  display: "flex",
@@ -0,0 +1,160 @@
1
+ import { Box, Button } from "@mui/material";
2
+ import { Meta, StoryObj } from "@storybook/react/*";
3
+ import DialogButton, { DialogButtonProps } from "./DialogButton";
4
+
5
+ // Define the default export with Meta type including the component type
6
+ const meta: Meta<typeof DialogButton> = {
7
+ title: "Navigation/DialogButton",
8
+ component: DialogButton,
9
+ tags: ["autodocs"],
10
+ argTypes: {
11
+ anchor: {
12
+ description:
13
+ "A function that returns a React node used as the dropdown anchor. It provides a method to open the dialog.",
14
+ control: "object",
15
+ },
16
+ content: {
17
+ description:
18
+ "A function that returns a React node used as the dialog content. It provides a method to close the dialog.",
19
+ control: "object",
20
+ },
21
+ dialogProps: {
22
+ description:
23
+ "Props to pass to the MUI Dialog component. Allows customization of the dialog's appearance and behavior.",
24
+ control: "object",
25
+ },
26
+ title: {
27
+ description:
28
+ "The title of the dialog. This can be a string or a React node.",
29
+ control: "text",
30
+ },
31
+ },
32
+ };
33
+
34
+ export default meta;
35
+ type Story = StoryObj<typeof DialogButton>;
36
+
37
+ export const WithMaxWidthXs: Story = {
38
+ render: (args: DialogButtonProps) => <DialogButton {...args} />,
39
+ args: {
40
+ anchor: ({ open }: { open: (e: any) => void }) => (
41
+ <Button color="primary" variant="contained" onClick={open}>
42
+ DialogButton
43
+ </Button>
44
+ ),
45
+ content: ({ close }: { close: (e: any) => void }) => (
46
+ <>
47
+ <Box
48
+ sx={{
49
+ height: "100px",
50
+ width: "100px",
51
+ }}
52
+ ></Box>
53
+ </>
54
+ ),
55
+ dialogProps: {
56
+ maxWidth: "xs",
57
+ },
58
+ title: "Add Title Name",
59
+ },
60
+ };
61
+
62
+ export const WithMaxWidthSm: Story = {
63
+ render: (args: DialogButtonProps) => <DialogButton {...args} />,
64
+ args: {
65
+ anchor: ({ open }: { open: (e: any) => void }) => (
66
+ <Button color="primary" variant="contained" onClick={open}>
67
+ DialogButton
68
+ </Button>
69
+ ),
70
+ content: ({ close }: { close: (e: any) => void }) => (
71
+ <>
72
+ <Box
73
+ sx={{
74
+ height: "500px",
75
+ width: "100px",
76
+ }}
77
+ ></Box>
78
+ </>
79
+ ),
80
+ dialogProps: {
81
+ maxWidth: "sm",
82
+ },
83
+ title: "Add Title Name",
84
+ },
85
+ };
86
+
87
+ export const WithMaxWidthMd: Story = {
88
+ render: (args: DialogButtonProps) => <DialogButton {...args} />,
89
+ args: {
90
+ anchor: ({ open }: { open: (e: any) => void }) => (
91
+ <Button color="primary" variant="contained" onClick={open}>
92
+ DialogButton
93
+ </Button>
94
+ ),
95
+ content: ({ close }: { close: (e: any) => void }) => (
96
+ <>
97
+ <Box
98
+ sx={{
99
+ height: "500px",
100
+ width: "100px",
101
+ }}
102
+ ></Box>
103
+ </>
104
+ ),
105
+ dialogProps: {
106
+ maxWidth: "md",
107
+ },
108
+ title: "Add Title Name",
109
+ },
110
+ };
111
+
112
+ export const WithMaxWidthLg: Story = {
113
+ render: (args: DialogButtonProps) => <DialogButton {...args} />,
114
+ args: {
115
+ anchor: ({ open }: { open: (e: any) => void }) => (
116
+ <Button color="primary" variant="contained" onClick={open}>
117
+ DialogButton
118
+ </Button>
119
+ ),
120
+ content: ({ close }: { close: (e: any) => void }) => (
121
+ <>
122
+ <Box
123
+ sx={{
124
+ height: "500px",
125
+ width: "100px",
126
+ }}
127
+ ></Box>
128
+ </>
129
+ ),
130
+ dialogProps: {
131
+ maxWidth: "lg",
132
+ },
133
+ title: "Add Title Name",
134
+ },
135
+ };
136
+
137
+ export const WithMaxWidthXl: Story = {
138
+ render: (args: DialogButtonProps) => <DialogButton {...args} />,
139
+ args: {
140
+ anchor: ({ open }: { open: (e: any) => void }) => (
141
+ <Button color="primary" variant="contained" onClick={open}>
142
+ DialogButton
143
+ </Button>
144
+ ),
145
+ content: ({ close }: { close: (e: any) => void }) => (
146
+ <>
147
+ <Box
148
+ sx={{
149
+ height: "500px",
150
+ width: "100px",
151
+ }}
152
+ ></Box>
153
+ </>
154
+ ),
155
+ dialogProps: {
156
+ maxWidth: "xl",
157
+ },
158
+ title: "Add Title Name",
159
+ },
160
+ };
@@ -0,0 +1,116 @@
1
+ import { Close } from "@mui/icons-material";
2
+ import {
3
+ Box,
4
+ Dialog,
5
+ DialogProps,
6
+ DialogTitle,
7
+ Grow,
8
+ IconButton,
9
+ styled,
10
+ } from "@mui/material";
11
+ import { TransitionProps } from "@mui/material/transitions";
12
+ import { ReactNode, forwardRef, useState } from "react";
13
+
14
+ const StyledDialogHeader = styled(Box)(({ theme }) => ({
15
+ height: "60px",
16
+ backgroundColor: theme.palette.grey[200],
17
+ display: "flex",
18
+ justifyContent: "space-between",
19
+ alignItems: "center",
20
+ padding: "25px 20px 15px 20px",
21
+ }));
22
+
23
+ export const Transition = forwardRef(function Transition(
24
+ props: TransitionProps & {
25
+ children: React.ReactElement;
26
+ },
27
+ ref: React.Ref<unknown>
28
+ ) {
29
+ return <Grow timeout={1000} ref={ref} {...props} />;
30
+ });
31
+
32
+ export interface DialogButtonProps {
33
+ anchor: (props: { open: () => void }) => ReactNode;
34
+ content: (props: { close: () => void }) => ReactNode;
35
+ title: string;
36
+ dialogProps?: Omit<DialogProps, "open">;
37
+ onDialogClose?: () => void;
38
+ }
39
+
40
+ export default function DialogButton({
41
+ content,
42
+ title,
43
+ dialogProps,
44
+ onDialogClose,
45
+ anchor,
46
+ }: DialogButtonProps) {
47
+ const [open, setOpen] = useState(false);
48
+
49
+ const onClose = () => {
50
+ onDialogClose && onDialogClose();
51
+ setOpen(false);
52
+ };
53
+
54
+ const onOpen = () => {
55
+ setOpen(true);
56
+ };
57
+
58
+ return (
59
+ <>
60
+ {anchor({
61
+ open: onOpen,
62
+ })}
63
+ <CustomDialog
64
+ open={open}
65
+ content={content}
66
+ dialogProps={dialogProps}
67
+ onClose={onClose}
68
+ title={title}
69
+ />
70
+ </>
71
+ );
72
+ }
73
+
74
+ interface CustomDialogProps {
75
+ content: (props: { close: () => void }) => ReactNode;
76
+ title?: string;
77
+ onClose: () => void;
78
+ open: boolean;
79
+ dialogProps?: Omit<DialogProps, "open">;
80
+ }
81
+
82
+ export const CustomDialog = ({
83
+ onClose,
84
+ dialogProps,
85
+ title,
86
+ content,
87
+ open,
88
+ }: CustomDialogProps) => {
89
+ const props = {
90
+ PaperProps: {
91
+ ...dialogProps?.PaperProps,
92
+ },
93
+ onClose: onClose,
94
+ open: open,
95
+ transitionDuration: 140,
96
+ TransitionComponent: Transition,
97
+ sx: {
98
+ ...dialogProps?.sx,
99
+ },
100
+ ...dialogProps,
101
+ };
102
+
103
+ return (
104
+ <Dialog {...props}>
105
+ {title && (
106
+ <StyledDialogHeader>
107
+ <DialogTitle>{title}</DialogTitle>
108
+ <IconButton onClick={onClose} sx={{ color: "black" }}>
109
+ <Close />
110
+ </IconButton>
111
+ </StyledDialogHeader>
112
+ )}
113
+ <Box sx={{ padding: "20px" }}>{content({ close: onClose })}</Box>
114
+ </Dialog>
115
+ );
116
+ };
@@ -4,3 +4,6 @@ export * from "./Input/Button/Button";
4
4
  export * from "./Input/SingleSelect/SingleSelect";
5
5
  export * from "./Input/Switch/Switch";
6
6
  export * from "./Input/TextField/TextField";
7
+ export * from "./Layout/Header/AppHeader";
8
+ export * from "./Layout/Header/AppLogo";
9
+ export * from "./Layout/Header/AppsMenu";
@@ -18,6 +18,10 @@ export enum Theme {
18
18
  export const getCommonTheme = (mode: Theme) => {
19
19
  const ColorTokens = mode == Theme.DARK ? DarkColorTokens : LightColorTokens;
20
20
  return {
21
+ borders: {
22
+ primary: `1px solid ${ColorTokens.grey.main}`,
23
+ grayLight: `1px solid ${ColorTokens.grey.main}`,
24
+ },
21
25
  typography: {
22
26
  fontFamily: ["Heebo", "Poppins", "sans-serif"].join(","),
23
27
  },
@@ -34,6 +38,36 @@ export const getCommonTheme = (mode: Theme) => {
34
38
  },
35
39
  },
36
40
  },
41
+
42
+ MuiDialogTitle: {
43
+ styleOverrides: {
44
+ root: {
45
+ fontFamily: "poppins",
46
+ fontWeight: 400,
47
+ fontSize: "16px",
48
+ padding: 0,
49
+ },
50
+ paper: {
51
+ elevation: 2,
52
+ borderRadius: "10px",
53
+ },
54
+ },
55
+ },
56
+ MuiDialog: {
57
+ styleOverrides: {
58
+ root: {
59
+ fullWidth: true,
60
+ },
61
+ paper: {
62
+ color: ColorTokens.background.default,
63
+ borderRadius: "5px",
64
+ width: "100%",
65
+ maxHeight: "calc(100vh - 64px)",
66
+ overflow: "auto",
67
+ boxShadow: "none",
68
+ },
69
+ },
70
+ },
37
71
  MuiMenu: {
38
72
  styleOverrides: {
39
73
  list: {