@campxdev/react-blueprint 1.0.9 → 1.0.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": "1.0.9",
3
+ "version": "1.0.12",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "dependencies": {
@@ -0,0 +1,145 @@
1
+ import { ChevronRight, MoreHoriz } from "@mui/icons-material";
2
+
3
+ import {
4
+ Checkbox,
5
+ Stack,
6
+ Typography,
7
+ Card as MuiCard,
8
+ SxProps,
9
+ CardContent,
10
+ } from "@mui/material";
11
+ import { ReactNode } from "react";
12
+ import {
13
+ StyledButton,
14
+ StyledCardActions,
15
+ StyledDivider,
16
+ StyledHeader,
17
+ StyledIcon,
18
+ StyledImage,
19
+ StyledStack,
20
+ StyledStatusText,
21
+ } from "./styles";
22
+ import { DropDownIcon, DropdownMenu } from "../../export";
23
+
24
+ export interface CardProps {
25
+ title: string;
26
+ caption?: string;
27
+ footer?: {
28
+ buttonText?: string | ReactNode;
29
+ onClick: () => void;
30
+ endIcon?: ReactNode;
31
+ buttonProps?: any;
32
+ };
33
+ fields?: [
34
+ {
35
+ title: string;
36
+ value: string;
37
+ },
38
+ ];
39
+ status?: string;
40
+ imageSrc?: string;
41
+ checkBox?: boolean;
42
+ moreOptions?: boolean;
43
+ menu?: Array<ReactNode>;
44
+ icon?: ReactNode;
45
+ statusSx?: SxProps;
46
+ cardSx?: SxProps;
47
+ }
48
+
49
+ export const Card = ({
50
+ title,
51
+ caption,
52
+ status,
53
+ footer,
54
+ fields,
55
+ imageSrc,
56
+ checkBox,
57
+ statusSx,
58
+ cardSx,
59
+ moreOptions,
60
+ icon,
61
+ menu = [],
62
+ }: CardProps) => {
63
+ const handleClick = (e: any) => {
64
+ footer?.onClick();
65
+ };
66
+
67
+ return (
68
+ <MuiCard sx={cardSx}>
69
+ {imageSrc && <StyledImage src={imageSrc} alt="Card image" />}
70
+ <StyledHeader>
71
+ <Stack gap={"8px"} flexDirection={"row"}>
72
+ {checkBox && (
73
+ <StyledStack>
74
+ <Checkbox />
75
+ </StyledStack>
76
+ )}
77
+
78
+ <Stack justifyContent={"center"}>
79
+ <Typography variant="subtitle2">{title}</Typography>
80
+ <Typography variant="caption">{caption}</Typography>
81
+ </Stack>
82
+ </Stack>
83
+ <Stack flexDirection={"row"} gap={"12px"} alignItems={"center"}>
84
+ {status && (
85
+ <StyledStatusText variant="label2" sx={statusSx}>
86
+ {status}{" "}
87
+ </StyledStatusText>
88
+ )}
89
+ {moreOptions && (
90
+ <>
91
+ <DropdownMenu
92
+ anchor={({ open }) => (
93
+ <DropDownIcon
94
+ handleClick={open}
95
+ icon={{
96
+ icon: (
97
+ <StyledIcon>{icon ? icon : <MoreHoriz />}</StyledIcon>
98
+ ),
99
+ iconProps: { color: "secondary" },
100
+ outlined: false,
101
+ }}
102
+ />
103
+ )}
104
+ menu={menu}
105
+ />
106
+ </>
107
+ )}
108
+ </Stack>
109
+ </StyledHeader>
110
+ {fields && (
111
+ <CardContent>
112
+ <Stack
113
+ sx={{
114
+ display: "grid",
115
+ gridTemplateColumns: "1fr 1fr",
116
+ gap: "20px",
117
+ }}
118
+ >
119
+ {fields.map((field, index) => (
120
+ <Stack key={index} flexDirection="row" gap="14px">
121
+ {index % 2 === 1 && <StyledDivider flexItem />}
122
+ <Stack gap="4px">
123
+ <Typography variant="caption">{field.title}</Typography>
124
+ <Typography variant="body2">{field.value}</Typography>
125
+ </Stack>
126
+ </Stack>
127
+ ))}
128
+ </Stack>
129
+ </CardContent>
130
+ )}
131
+
132
+ {footer && (
133
+ <StyledCardActions>
134
+ <StyledButton
135
+ variant="text"
136
+ onClick={handleClick}
137
+ endIcon={footer?.endIcon ?? <ChevronRight />}
138
+ >
139
+ {footer?.buttonText ?? "View"}
140
+ </StyledButton>
141
+ </StyledCardActions>
142
+ )}
143
+ </MuiCard>
144
+ );
145
+ };
@@ -0,0 +1,65 @@
1
+ import {
2
+ Box,
3
+ Button,
4
+ CardActions,
5
+ CardContent,
6
+ Divider,
7
+ IconButton,
8
+ Card as MuiCard,
9
+ Stack,
10
+ styled,
11
+ Typography,
12
+ } from "@mui/material";
13
+
14
+ export const StyledCardActions = styled(CardActions)(({ theme }) => ({
15
+ //${} add border color
16
+ borderTop: `1px solid ${theme.palette.border.primary}`,
17
+ padding: "0",
18
+ }));
19
+
20
+ export const StyledButton = styled(Button)(({ theme }) => ({
21
+ display: "flex",
22
+ alignItems: "center",
23
+ justifyContent: "space-between",
24
+ width: "100%",
25
+ padding: "8px 16px",
26
+
27
+ }));
28
+
29
+ export const StyledImage = styled("img")(({ theme }) => ({
30
+ height: "216px",
31
+ width: "385px",
32
+ objectFit: "cover",
33
+ }));
34
+
35
+ export const StyledHeader = styled(Stack)(({ theme }) => ({
36
+ padding: "12px 16px",
37
+ flexDirection: "row",
38
+ justifyContent: "space-between",
39
+ alignItems: "center",
40
+ }));
41
+
42
+ export const StyledStack = styled(Stack)(({ theme }) => ({
43
+ width: "50px",
44
+ height: "50px",
45
+ backgroundColor: theme.palette.surface.grey,
46
+ borderRadius: "50%",
47
+ justifyContent: "center",
48
+ alignItems: "center",
49
+ }));
50
+
51
+ export const StyledStatusText = styled(Typography)(({ theme }) => ({
52
+ color: theme.palette.highlight.highlightBlue,
53
+ padding: "5px 10px",
54
+ backgroundColor: theme.palette.highlight.blueBackground,
55
+ borderRadius: "4px",
56
+ }));
57
+
58
+ export const StyledIcon = styled(IconButton)(({ theme }) => ({
59
+ color: theme.palette.text.primary,
60
+ }));
61
+
62
+ export const StyledDivider = styled(Divider)(({ theme }) => ({
63
+ orientation: "vertical",
64
+ border: "1px solid #CECECE",
65
+ }));
@@ -1,6 +1,7 @@
1
1
  export * from "./Button/Button";
2
2
  export * from "./MultiCheckBox/MultiCheckBox";
3
3
  export * from "./SearchBar/SearchBar";
4
+ export * from "./SingleCheckBox/SIngleCheckBox";
4
5
  export * from "./SingleSelect/SingleSelect";
5
6
  export * from "./Switch/Switch";
6
7
  export * from "./TextField/TextField";
@@ -51,13 +51,8 @@ export const Sidebar = ({
51
51
  let resolved = useResolvedPath(path);
52
52
  let match = useMatch({ path: resolved.pathname, end: false });
53
53
  return (
54
- <StyledListItem
55
- key={path}
56
- disablePadding
57
- match={match}
58
- className="listItem"
59
- >
60
- <StyledLinkButton to={path}>
54
+ <StyledListItem key={path} disablePadding className="listItem">
55
+ <StyledLinkButton to={path} match={match}>
61
56
  {!collapsed && (
62
57
  <StyledListItemButton collapsed={collapsed}>
63
58
  <StyledListItemIcon collapsed={collapsed}>
@@ -44,36 +44,50 @@ export const createSidebarStyles = (collapsed: boolean) => {
44
44
  backgroundColor: theme.palette.surface.paperBackground,
45
45
  height: "60px",
46
46
  }));
47
- interface StyledListItemProps {
47
+
48
+ interface StyledLinkButtonProps {
48
49
  match: any;
49
50
  }
50
- const StyledListItem = styled(ListItem)<StyledListItemProps>(
51
+
52
+ const StyledListItem = styled(ListItem)(({ theme }) => ({
53
+ // width: collapsed ? "min-content" : "auto",
54
+ // backgroundColor: match ? theme.palette.secondary.main : "none",
55
+ display: "flex",
56
+ justifyContent: "center",
57
+ borderRadius: "4px",
58
+ }));
59
+
60
+ const StyledLinkButton = styled(Link)<StyledLinkButtonProps>(
51
61
  ({ theme, match }) => ({
62
+ width: collapsed ? "auto" : "100%",
63
+ textDecoration: "none",
64
+ display: "flex",
65
+ margin: collapsed ? "5px 0px 0px 0px" : "5px 8px",
66
+
52
67
  backgroundColor: match ? theme.palette.secondary.main : "none",
53
- width: collapsed ? "min-content" : "auto",
54
- margin: "5px 8px",
68
+ justifyContent: "center",
69
+ "&:hover": {
70
+ color: "unset",
71
+ },
55
72
  borderRadius: "4px",
56
73
  })
57
74
  );
58
75
 
59
- const StyledLinkButton = styled(Link)({
60
- width: "100%",
61
- textDecoration: "none",
62
- "&:hover": {
63
- color: "unset",
64
- },
65
- });
76
+ interface StyledListItemButtonProps {
77
+ collapsed: boolean;
78
+ }
66
79
 
67
- const StyledListItemButton = styled(ListItemButton)(
68
- ({ collapsed }: { collapsed: boolean }) => ({
69
- display: "flex",
70
- alignItems: "center",
71
- justifyContent: collapsed ? "center" : "flex-start",
72
- paddingBottom: "5px",
73
- paddingTop: "5px",
74
- width: "100%",
75
- })
76
- );
80
+ const StyledListItemButton = styled(
81
+ ListItemButton
82
+ )<StyledListItemButtonProps>(({ collapsed }) => ({
83
+ display: "flex",
84
+ alignItems: "center",
85
+ justifyContent: collapsed ? "center" : "flex-start",
86
+ paddingBottom: "5px",
87
+ paddingTop: "5px",
88
+ width: "100%",
89
+ borderRadius: "5px",
90
+ }));
77
91
 
78
92
  const StyledListItemIcon = styled(ListItemIcon)(
79
93
  ({ collapsed }: { collapsed: boolean }) => ({
@@ -0,0 +1,88 @@
1
+ import { Meta } from "@storybook/react";
2
+ import { Card, CardProps } from "../../components/DataDisplay/Card/Card";
3
+ import { Stack } from "@mui/material";
4
+ import { GridMenuIcon } from "@mui/x-data-grid";
5
+
6
+ export default {
7
+ title: "DataDisplay/Card",
8
+ component: Card,
9
+ tags: ["autodocs"],
10
+ argTypes: {},
11
+ } as Meta<typeof Card>;
12
+
13
+ export const Standard = {
14
+ render: (args: CardProps) => <Card {...args} />,
15
+ args: {
16
+ title: "Academic Administrator WS",
17
+ caption:
18
+ "A centralized hub designed to streamline and manage administrative tasks efficiently.",
19
+ fields: [
20
+ {
21
+ title: "Start year / End Year",
22
+ value: "2024 / 2028",
23
+ },
24
+ {
25
+ title: "Current Sem",
26
+ value: "1",
27
+ },
28
+ {
29
+ title: "Total Students",
30
+ value: "1324",
31
+ },
32
+ ],
33
+ footer: {
34
+ buttonText: "View Details",
35
+ onClick: () => alert(`Details Viewed`),
36
+ },
37
+ },
38
+ };
39
+ export const StandardWithImage = {
40
+ render: (args: CardProps) => (
41
+ <Stack flexDirection={"row"} gap={"20px"}>
42
+ <Card {...args} /> <Card {...args} /> <Card {...args} />{" "}
43
+ </Stack>
44
+ ),
45
+
46
+ args: {
47
+ title: "ECE 2024 - 25",
48
+ caption: "Started on July 24, 2024",
49
+ status: "Active",
50
+ fields: [
51
+ {
52
+ title: "Start year / End Year",
53
+ value: "2024 / 2028",
54
+ },
55
+ {
56
+ title: "Current Sem",
57
+ value: "1",
58
+ },
59
+ {
60
+ title: "Total Students",
61
+ value: "1324",
62
+ },
63
+ {
64
+ title: "Total Students",
65
+ value: "1324",
66
+ },
67
+ {
68
+ title: "Total Students",
69
+ value: "1324",
70
+ },
71
+ ],
72
+ footer: {
73
+ buttonText: "View Details",
74
+ onClick: () => alert(`Details Viewed`),
75
+ },
76
+ imageSrc:
77
+ "https://i.pinimg.com/564x/aa/a5/90/aaa5903de24897afa5b07fd9f4092866.jpg",
78
+ moreOptions: true,
79
+ },
80
+ };
81
+
82
+ export const Statistic = {
83
+ render: (args: CardProps) => <Card {...args} />,
84
+ args: {
85
+ title: "ECE 2024 - 25",
86
+ caption: "Started on July 24, 2024",
87
+ },
88
+ };
@@ -111,6 +111,15 @@ export const getCommonTheme = (mode: Theme) => {
111
111
  },
112
112
  },
113
113
  },
114
+ MuiCard: {
115
+ styleOverrides: {
116
+ root: {
117
+ boxShadow: "none",
118
+ border: `1px solid ${ColorTokens.border.primary}`,
119
+ borderRadius: "8px",
120
+ },
121
+ },
122
+ },
114
123
  MuiDialog: {
115
124
  styleOverrides: {
116
125
  root: {