@campxdev/react-blueprint 0.1.15 → 0.1.16

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.
Files changed (62) hide show
  1. package/.storybook/preview.tsx +3 -3
  2. package/package.json +15 -14
  3. package/src/components/DataDisplay/DataTable/DataTable.stories.tsx +34 -17
  4. package/src/components/DataDisplay/DataTable/DataTable.tsx +32 -7
  5. package/src/components/DataDisplay/DataTable/TablePagination.tsx +60 -6
  6. package/src/components/DataDisplay/styles.tsx +2 -0
  7. package/src/components/DropDownMenu/DropDownButton.tsx +3 -25
  8. package/src/components/DropDownMenu/DropDownMenu.stories.tsx +34 -31
  9. package/src/components/DropDownMenu/DropDownMenu.tsx +4 -4
  10. package/src/components/DropDownMenu/DropdownMenuItem.tsx +25 -0
  11. package/src/components/DropDownMenu/styles.tsx +1 -7
  12. package/src/components/Icons/IconComponents/AppsIcon.tsx +36 -0
  13. package/src/components/Icons/IconComponents/CareerIcon.tsx +24 -0
  14. package/src/components/Icons/IconComponents/ClogWheelIcon.tsx +38 -0
  15. package/src/components/Icons/IconComponents/DashBoardIcon.tsx +65 -0
  16. package/src/components/Icons/IconComponents/ExamResultIcon.tsx +26 -0
  17. package/src/components/Icons/IconComponents/HelpIcon.tsx +57 -0
  18. package/src/components/Icons/IconComponents/HomeIcon.tsx +52 -0
  19. package/src/components/Icons/IconComponents/LeftIcon.tsx +72 -0
  20. package/src/components/Icons/IconComponents/LogoutIcon.tsx +66 -0
  21. package/src/components/Icons/IconComponents/NotificationIcon.tsx +29 -0
  22. package/src/components/Icons/IconComponents/RightIcon.tsx +65 -0
  23. package/src/components/Icons/IconComponents/TicketsIcon.tsx +74 -0
  24. package/src/components/Icons/Icons.stories.tsx +21 -0
  25. package/src/components/Icons/Icons.tsx +14 -0
  26. package/src/components/Icons/export.ts +26 -0
  27. package/src/components/Input/Button/Button.tsx +10 -8
  28. package/src/components/Input/LabelWrapper/LabelWrapper.tsx +35 -0
  29. package/src/components/Input/SingleSelect/SingleSelect.stories.tsx +85 -36
  30. package/src/components/Input/SingleSelect/SingleSelect.tsx +17 -69
  31. package/src/components/Input/TextField/TextField.tsx +9 -5
  32. package/src/components/Input/components/FetchingOptionsLoader.tsx +16 -4
  33. package/src/components/Input/styles.tsx +9 -1
  34. package/src/components/Layout/Header/AppHeader.stories.tsx +5 -5
  35. package/src/components/Layout/Header/AppsMenu.tsx +2 -2
  36. package/src/components/Layout/Header/HeaderActions/CogWheelMenu.tsx +4 -4
  37. package/src/components/Layout/Header/HeaderActions/HeaderActions.tsx +2 -2
  38. package/src/components/Layout/Header/HeaderActions/UserBox.tsx +33 -18
  39. package/src/components/Layout/LayoutWrapper/LayoutWrapper.stories.tsx +33 -8
  40. package/src/components/Layout/LayoutWrapper/LayoutWrapper.tsx +3 -3
  41. package/src/components/Layout/LayoutWrapper/styles.tsx +1 -1
  42. package/src/components/Layout/PageContent/PageContent.stories.tsx +26 -0
  43. package/src/components/Layout/PageContent/PageContent.tsx +8 -2
  44. package/src/components/Layout/SideNavigation/SideNavigation.stories.tsx +57 -0
  45. package/src/components/Layout/SideNavigation/SideNavigation.tsx +28 -18
  46. package/src/components/Layout/SideNavigation/styles/styles.tsx +7 -2
  47. package/src/components/Layout/Spinner/Spinner.css +1 -1
  48. package/src/components/Layout/Spinner/Spinner.stories.tsx +1 -1
  49. package/src/components/Layout/Spinner/Spinner.tsx +1 -1
  50. package/src/components/Modals/DialogButton.tsx +1 -1
  51. package/src/components/TabsContainer/TabsContainer.stories.tsx +48 -0
  52. package/src/components/TabsContainer/TabsContainer.tsx +58 -0
  53. package/src/components/export.ts +1 -0
  54. package/src/themes/commonTheme.ts +60 -19
  55. package/src/themes/darkTheme.ts +2 -3
  56. package/src/themes/lightTheme.ts +2 -3
  57. package/src/utils/campxAxios.ts +1 -1
  58. package/tsconfig.json +1 -3
  59. package/types/theme.d.ts +38 -0
  60. package/src/assets/images/icons.tsx +0 -427
  61. package/src/components/DropDownMenu/MenuItemButton.tsx +0 -24
  62. package/src/components/Input/Label/Label.tsx +0 -11
@@ -0,0 +1,57 @@
1
+ import { Typography } from "@mui/material";
2
+ import { Meta, StoryObj } from "@storybook/react";
3
+ import { Icons } from "../../export";
4
+ import {
5
+ SideNavigation,
6
+ SideNavigationProps,
7
+ } from "../SideNavigation/SideNavigation";
8
+
9
+ // Define the default export with Meta type including the component type
10
+ const meta: Meta<typeof SideNavigation> = {
11
+ title: "Layout/SideNavigation",
12
+ component: SideNavigation,
13
+ tags: ["autodocs"],
14
+ argTypes: {
15
+ menu: {
16
+ control: "object",
17
+ description: "Array of menu item props",
18
+ },
19
+ open: {
20
+ control: "boolean",
21
+ description: "State to control if the drawer is open",
22
+ },
23
+ handleDrawer: {
24
+ control: false,
25
+ description: "Function to handle drawer state",
26
+ type: { name: "function", required: false },
27
+ },
28
+ },
29
+ };
30
+
31
+ export default meta;
32
+ type Story = StoryObj<typeof SideNavigation>;
33
+
34
+ // Primary story
35
+ export const Primary: Story = {
36
+ render: (args: SideNavigationProps) => <SideNavigation {...args} />,
37
+ args: {
38
+ open: true,
39
+ menu: [
40
+ { name: "Tickets", path: "/home", icon: Icons.DashBoardIcon },
41
+ { name: "Item 2", path: "/item2" },
42
+ ],
43
+ },
44
+ };
45
+
46
+ export const WithoutMenu: Story = {
47
+ render: (args: SideNavigationProps) => <SideNavigation {...args} />,
48
+ args: {
49
+ open: true,
50
+ children: (
51
+ <Typography variant="body2">
52
+ Vestibulum blandit viverra conv allis. Pellentesque ligula urna,
53
+ fermentum ut semper in, tincidunt nec dui.
54
+ </Typography>
55
+ ),
56
+ },
57
+ };
@@ -1,37 +1,38 @@
1
1
  import { ListItemIcon, Stack } from "@mui/material";
2
+ import { ReactNode } from "react";
2
3
  import { useMatch, useResolvedPath } from "react-router-dom";
3
- import { HomeIcon } from "../../../assets/images/icons";
4
4
  import { activeStore } from "../../../store/activeStore";
5
5
  import { Typography } from "../../Typography/Typography";
6
+ import { Icons } from "../../export";
6
7
  import {
8
+ StyledBox,
9
+ StyledContainer,
7
10
  StyledDrawer,
8
11
  StyledLinkButton,
9
- StyledList,
10
12
  StyledListItem,
11
13
  StyledListItemButton,
12
14
  } from "./styles/styles";
13
15
 
14
16
  export interface SideNavigationProps {
15
- menu?: any;
17
+ menu?: MenuItemProps[];
18
+ children?: ReactNode;
16
19
  open?: any;
17
20
  handleDrawer?: any;
18
21
  }
19
22
 
20
23
  export interface MenuItemProps {
21
- menuItem: {
22
- name: string;
23
- path: string;
24
- icon: any;
25
- permissionKey: string;
26
- iconType: string;
27
- };
28
- index: number;
24
+ name: string;
25
+ path: string;
26
+ icon?: any;
27
+ permissionKey?: string;
28
+ iconType?: string;
29
29
  }
30
30
 
31
31
  export const SideNavigation = ({
32
32
  menu,
33
33
  open,
34
34
  handleDrawer,
35
+ children,
35
36
  }: SideNavigationProps) => {
36
37
  return (
37
38
  <Stack gap="20px" direction={"row"} marginTop={"10px"}>
@@ -41,17 +42,26 @@ export const SideNavigation = ({
41
42
  open={open}
42
43
  onClose={handleDrawer}
43
44
  >
44
- <StyledList>
45
- {menu?.map((item: any, index: number) => (
46
- <MenuItem menuItem={item} index={index} key={index} />
47
- ))}
48
- </StyledList>
45
+ <StyledBox>
46
+ {menu &&
47
+ menu.length > 0 &&
48
+ menu?.map((item: any, index: number) => (
49
+ <MenuItem menuItem={item} index={index} key={index} />
50
+ ))}
51
+ <StyledContainer>{children}</StyledContainer>
52
+ </StyledBox>
49
53
  </StyledDrawer>
50
54
  </Stack>
51
55
  );
52
56
  };
53
57
 
54
- const MenuItem = ({ menuItem, index }: MenuItemProps) => {
58
+ const MenuItem = ({
59
+ menuItem,
60
+ index,
61
+ }: {
62
+ menuItem: MenuItemProps;
63
+ index: number;
64
+ }) => {
55
65
  const { path, icon: Icon, name, permissionKey, iconType } = menuItem;
56
66
 
57
67
  let resolved = useResolvedPath(path);
@@ -80,7 +90,7 @@ const MenuItem = ({ menuItem, index }: MenuItemProps) => {
80
90
  marginRight: "8px",
81
91
  }}
82
92
  >
83
- {Icon ? <Icon /> : <HomeIcon />}
93
+ {Icon ? <Icon /> : <Icons.HomeIcon />}
84
94
  </ListItemIcon>
85
95
  <Typography variant="subtitle3">{name}</Typography>
86
96
  </StyledListItemButton>
@@ -1,4 +1,4 @@
1
- import { Drawer, List, ListItem, ListItemButton, styled } from "@mui/material";
1
+ import { Box, Drawer, ListItem, ListItemButton, styled } from "@mui/material";
2
2
  import { Link } from "react-router-dom";
3
3
  const drawerWidth: number = 240;
4
4
 
@@ -32,6 +32,11 @@ export const StyledListItem = styled(ListItem)<StyledListItemProps>(
32
32
  borderRadius: "5px",
33
33
  })
34
34
  );
35
+
36
+ export const StyledContainer = styled(Box)(({ theme }) => ({
37
+ width: "auto",
38
+ margin: "5px 10px",
39
+ }));
35
40
  export const StyledListItemButton = styled(ListItemButton)(() => ({
36
41
  alignItems: "center",
37
42
  display: "flex",
@@ -46,7 +51,7 @@ export const StyledLinkButton = styled(Link)({
46
51
  },
47
52
  });
48
53
 
49
- export const StyledList = styled(List)(({ theme }) => ({
54
+ export const StyledBox = styled(Box)(({ theme }) => ({
50
55
  backgroundColor: theme.palette.background.paper,
51
56
  height: "calc(100vh - 120px)",
52
57
  paddingTop: "20px",
@@ -4,7 +4,7 @@
4
4
  border-radius: 50%;
5
5
  position: relative;
6
6
  animation: rotate 1s linear infinite;
7
- scale: 0.5;
7
+ scale: 0.4;
8
8
  }
9
9
  .spinner::before , .spinner::after {
10
10
  content: "";
@@ -7,7 +7,7 @@ import { Spinner } from "./Spinner";
7
7
 
8
8
  // Define the default export with Meta type including the component type
9
9
  export default {
10
- title: "Layout/Spinner",
10
+ title: "FeedBack/Spinner",
11
11
  component: Spinner,
12
12
  tags: ["autodocs"],
13
13
  argTypes: {},
@@ -1,5 +1,5 @@
1
1
  import "./Spinner.css";
2
2
 
3
3
  export const Spinner = () => {
4
- return <div className="spinner" style={{}}></div>;
4
+ return <div className="spinner"></div>;
5
5
  };
@@ -13,7 +13,7 @@ import { ReactNode, forwardRef, useState } from "react";
13
13
 
14
14
  const StyledDialogHeader = styled(Box)(({ theme }) => ({
15
15
  height: "60px",
16
- backgroundColor: theme.palette.grey[200],
16
+
17
17
  display: "flex",
18
18
  justifyContent: "space-between",
19
19
  alignItems: "center",
@@ -0,0 +1,48 @@
1
+ import { Box } from "@mui/material";
2
+ import { Meta, StoryObj } from "@storybook/react";
3
+ import { PageContent } from "../Layout/PageContent/PageContent";
4
+ import { TabsContainer, TabsContainerProps } from "./TabsContainer";
5
+
6
+ // Define the default export with Meta type including the component type
7
+ const meta: Meta<typeof TabsContainer> = {
8
+ title: "Navigation/TabsContainer",
9
+ component: TabsContainer,
10
+ tags: ["autodocs"],
11
+ // argTypes: {
12
+ // menu: {
13
+ // control: "object",
14
+ // description: "Menu items to be displayed in the side navigation.",
15
+ // },
16
+ // },
17
+ };
18
+
19
+ export default meta;
20
+ type Story = StoryObj<typeof TabsContainer>;
21
+
22
+ // Primary story
23
+ export const Primary: Story = {
24
+ render: (args: TabsContainerProps) => (
25
+ <PageContent sx={{ padding: "0px" }}>
26
+ <TabsContainer {...args} />{" "}
27
+ </PageContent>
28
+ ),
29
+ args: {
30
+ tabs: [
31
+ {
32
+ key: "1",
33
+ label: "Personal Details",
34
+ component: <Box>First Year</Box>,
35
+ },
36
+ {
37
+ key: "2",
38
+ label: "Overview",
39
+ component: <>Second Year</>,
40
+ },
41
+ {
42
+ key: "3",
43
+ label: "year 3",
44
+ component: <>Third Year</>,
45
+ },
46
+ ],
47
+ },
48
+ };
@@ -0,0 +1,58 @@
1
+ import { Box, Tab, TabProps, Tabs, TabsProps } from "@mui/material";
2
+ import { ChangeEvent, useEffect, useState } from "react";
3
+
4
+ interface CustomTabProps extends Omit<TabProps, "component"> {
5
+ component: React.ReactNode;
6
+ highlight?: boolean;
7
+ key: string | number;
8
+ }
9
+
10
+ export interface TabsContainerProps {
11
+ tabs: CustomTabProps[];
12
+ onTabChange?: (tabKey: string) => void;
13
+ currentTabIndex?: number;
14
+ tabsProps: TabsProps;
15
+ }
16
+
17
+ export const TabsContainer = ({
18
+ tabs,
19
+ onTabChange,
20
+ currentTabIndex = 0,
21
+ tabsProps,
22
+ }: TabsContainerProps) => {
23
+ const [currentTab, setCurrentTab] = useState(tabs[currentTabIndex]?.key);
24
+
25
+ const handleTabsChange = (_event: ChangeEvent<{}>, value: string): void => {
26
+ setCurrentTab(value);
27
+ onTabChange && onTabChange(value);
28
+ };
29
+ useEffect(() => {
30
+ setCurrentTab(tabs[currentTabIndex]?.key);
31
+ }, []);
32
+
33
+ return (
34
+ <>
35
+ <Tabs
36
+ onChange={handleTabsChange}
37
+ value={currentTab}
38
+ variant="scrollable"
39
+ scrollButtons="auto"
40
+ TabIndicatorProps={{
41
+ children: <span className="MuiTabs-indicatorSpan" />,
42
+ }}
43
+ {...tabsProps}
44
+ >
45
+ {tabs.map(({ component, ...tab }) => (
46
+ <Tab
47
+ label={tab.label}
48
+ value={tab?.key}
49
+ icon={tab.highlight ? <span>{"."}</span> : <></>}
50
+ iconPosition="end"
51
+ {...tab}
52
+ />
53
+ ))}
54
+ </Tabs>
55
+ <Box p={2}>{tabs.find((tab) => tab?.key === currentTab)?.component}</Box>
56
+ </>
57
+ );
58
+ };
@@ -1,5 +1,6 @@
1
1
  export * from "./DropDownMenu/DropDownButton";
2
2
  export * from "./DropDownMenu/DropDownMenu";
3
+ export * from "./Icons/export";
3
4
  export * from "./Input/Button/Button";
4
5
  export * from "./Input/SingleSelect/SingleSelect";
5
6
  export * from "./Input/Switch/Switch";
@@ -3,14 +3,6 @@ import { TypographyOptions } from "@mui/material/styles/createTypography";
3
3
  import { DarkColorTokens, LightColorTokens } from "./colorTokens";
4
4
  import { customCssBaseline } from "./customCssBaseline";
5
5
 
6
- declare module "@mui/material/Typography" {
7
- interface TypographyPropsVariantOverrides {
8
- label1: true;
9
- label2: true;
10
- subtitle3: true;
11
- }
12
- }
13
-
14
6
  export enum Theme {
15
7
  LIGHT = "light",
16
8
  DARK = "dark",
@@ -73,13 +65,6 @@ export const getCommonTheme = (mode: Theme) => {
73
65
  list: {
74
66
  minWidth: "240px",
75
67
  padding: 0,
76
- "& li": {
77
- borderBottom: "1212121A",
78
- minHeight: "55px",
79
- // ":hover": {
80
- // backgroundColor: "rgba(0, 0, 0, 0.025)",
81
- // },
82
- },
83
68
  "& > :last-child": {
84
69
  borderBottom: "none",
85
70
  "& li": {
@@ -91,18 +76,40 @@ export const getCommonTheme = (mode: Theme) => {
91
76
  borderRadius: "5px",
92
77
  border: `1px solid ${ColorTokens.secondary.main}`,
93
78
  marginTop: "10px",
94
- boxShadow: "0px 5px 15px #0000001A",
79
+ boxShadow: `0px 5px 15px ${ColorTokens.secondary.main}`,
95
80
  "&::-webkit-scrollbar": {
96
81
  width: "0.5em",
97
82
  height: "0.5em",
98
83
  },
99
84
  "&::-webkit-scrollbar-thumb": {
100
- backgroundColor: "rgba(0, 0, 0, 0.15)",
85
+ backgroundColor: ColorTokens.background.paper,
101
86
  borderRadius: "3px",
102
87
  },
103
88
  },
104
89
  },
105
90
  },
91
+ MuiMenuItem: {
92
+ styleOverrides: {
93
+ root: {
94
+ minHeight: "50px !important",
95
+ padding: "10px 16px",
96
+ },
97
+ },
98
+ },
99
+ MuiPagination: {
100
+ styleOverrides: {},
101
+ },
102
+ MuiPaginationItem: {
103
+ styleOverrides: {
104
+ root: {
105
+ background: ColorTokens.background.default,
106
+ "&.Mui-selected": {
107
+ background: ColorTokens.background.paper,
108
+ border: `1px solid ${ColorTokens.highlight.main}`,
109
+ },
110
+ },
111
+ },
112
+ },
106
113
  MuiButton: {
107
114
  defaultProps: {},
108
115
  styleOverrides: {
@@ -110,6 +117,7 @@ export const getCommonTheme = (mode: Theme) => {
110
117
  textTransform: "none",
111
118
  padding: "5px 30px ",
112
119
  maxHeight: "40px ",
120
+ minWidth: "250px",
113
121
  borderRadius: "5px ",
114
122
  boxShadow: "none ",
115
123
  fontSize: "14px ",
@@ -208,6 +216,9 @@ export const getCommonTheme = (mode: Theme) => {
208
216
  maxWidth: "400px",
209
217
  },
210
218
  },
219
+ paper: {
220
+ borderRadius: "10px",
221
+ },
211
222
  },
212
223
  },
213
224
  MuiOutlinedInput: {
@@ -235,11 +246,41 @@ export const getCommonTheme = (mode: Theme) => {
235
246
  underline: "none",
236
247
  },
237
248
  },
238
- MuiFormLabel: {
249
+ MuiTabs: {
250
+ styleOverrides: {
251
+ root: {
252
+ "& .MuiTabs-flexContainer": {
253
+ borderBottom: `1px solid ${ColorTokens.grey.main}`,
254
+ },
255
+ },
256
+ indicator: {
257
+ display: "flex",
258
+ justifyContent: "center",
259
+ backgroundColor: "transparent",
260
+ height: "3px",
261
+ "& .MuiTabs-indicatorSpan": {
262
+ borderRadius: "30px",
263
+ width: "60%",
264
+ backgroundColor: ColorTokens.highlight.main,
265
+ },
266
+ },
267
+ },
268
+ },
269
+ MuiTab: {
270
+ defaultProps: {
271
+ disableRipple: true,
272
+ },
239
273
  styleOverrides: {
240
274
  root: {
275
+ color: ColorTokens.text.secondary,
241
276
  fontSize: "14px",
242
- color: "#959595",
277
+ fontWeight: "600",
278
+ textTransform: "initial",
279
+ minHeight: "50px",
280
+ paddingBottom: "0px",
281
+ "&.Mui-selected": {
282
+ color: ColorTokens.text.primary,
283
+ },
243
284
  },
244
285
  },
245
286
  },
@@ -9,9 +9,8 @@ export const darkTheme = createTheme({
9
9
  secondary: DarkColorTokens.secondary,
10
10
  background: DarkColorTokens.background,
11
11
  text: DarkColorTokens.text,
12
- // highlight: {
13
- // main: "#D4483E", // Highlight color for dark mode
14
- // },
12
+ highlight: DarkColorTokens.highlight,
13
+ grey: DarkColorTokens.grey,
15
14
  // defaultProfileIcon: {
16
15
  // main: "#293640", // Default profile images and icons color for dark mode
17
16
  // },
@@ -9,9 +9,8 @@ export const lightTheme = createTheme({
9
9
  secondary: LightColorTokens.secondary,
10
10
  background: LightColorTokens.background,
11
11
  text: LightColorTokens.text,
12
- // highlight: {
13
- // main: "#D4483E", // Highlight color
14
- // },
12
+ highlight: LightColorTokens.highlight,
13
+ grey: LightColorTokens.grey,
15
14
  // defaultProfileIcon: {
16
15
  // main: "#BDD6E8", // Default profile images and icons color
17
16
  // },
@@ -14,7 +14,7 @@ export const campxAxios = axios.create({
14
14
  headers: {
15
15
  "x-tenant-id": tenantCode,
16
16
  ...(!isProduction
17
- ? { campx_session_key: sessionKey || "6653ed32f34cbc245f22e7c8" }
17
+ ? { campx_session_key: sessionKey || "6658507d9912823dcae621cf" }
18
18
  : {}),
19
19
  "x-institution-id": institutionCode,
20
20
  },
package/tsconfig.json CHANGED
@@ -21,7 +21,5 @@
21
21
  "types": ["node"],
22
22
  "jsx": "react-jsx"
23
23
  },
24
- "include": [
25
- "src"
26
- ]
24
+ "include": ["src", "./types" ]
27
25
  }
@@ -0,0 +1,38 @@
1
+ import "@mui/material/styles";
2
+
3
+ declare module "@mui/material/styles" {
4
+ interface Theme {
5
+ palette: {
6
+ primary: {
7
+ dark: string;
8
+ main: string;
9
+ light: string;
10
+ };
11
+ secondary: {
12
+ main: string;
13
+ light: string;
14
+ dark: string;
15
+ };
16
+ text: {
17
+ primary: string;
18
+ secondary: string;
19
+ };
20
+ background: {
21
+ paper: string;
22
+ default: string;
23
+ };
24
+ highlight: {
25
+ main: string;
26
+ };
27
+ };
28
+ }
29
+ export function createTheme(options?: CustomThemeOptions): CustomTheme;
30
+ }
31
+
32
+ declare module "@mui/material/Typography" {
33
+ interface TypographyPropsVariantOverrides {
34
+ label1: true;
35
+ label2: true;
36
+ subtitle3: true;
37
+ }
38
+ }