@campxdev/react-blueprint 1.2.1 → 1.2.2

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.2.1",
3
+ "version": "1.2.2",
4
4
  "main": "./export.ts",
5
5
  "private": false,
6
6
  "dependencies": {
@@ -31,12 +31,10 @@ export interface CardProps {
31
31
  endIcon?: ReactNode;
32
32
  buttonProps?: any;
33
33
  };
34
- fields?: [
35
- {
36
- title: string;
37
- value: string;
38
- },
39
- ];
34
+ fields?: {
35
+ title: string;
36
+ value: string;
37
+ }[];
40
38
  titleProps?: {
41
39
  variant: Variant;
42
40
  sx?: SxProps;
@@ -35,7 +35,7 @@ export const TablePagination = (props: PaginationProps) => {
35
35
  {...props}
36
36
  variant="outlined"
37
37
  shape="rounded"
38
- onChange={(e, v) => onPageChange(Number(v) * limit)}
38
+ onChange={(e, v) => onPageChange((Number(v) - 1) * limit)}
39
39
  />
40
40
  <DropdownMenu
41
41
  anchor={({ open }) => (
@@ -1,9 +1,79 @@
1
+ import { SxProps, Typography } from '@mui/material';
1
2
  import { ReactNode } from 'react';
3
+ import Image from '../../Image/Image';
4
+ import {
5
+ StyledSidePanelContainer,
6
+ StyledTextContainer,
7
+ StyledTypography,
8
+ StyledValueContainer,
9
+ } from './styles';
2
10
 
3
11
  export interface SidePanelProps {
4
- children?: ReactNode;
12
+ variables?: { label: string; value: string }[];
13
+ bottomChildren?: ReactNode;
14
+ containerSx?: SxProps;
15
+ variablesContainerSX?: SxProps;
16
+ imageUrl?: string;
17
+ imageWidth?: string;
18
+ imageHeight?: string;
19
+ title?: string;
5
20
  }
21
+ interface variablesProps {
22
+ data?: { label: string; value: string }[];
23
+ variablesContainerSX?: SxProps;
24
+ }
25
+ export const SidePanelVariables = ({
26
+ data,
27
+ variablesContainerSX,
28
+ }: variablesProps) => {
29
+ return (
30
+ <>
31
+ {data?.map((item, index) => (
32
+ <>
33
+ <StyledValueContainer key={index} sx={variablesContainerSX}>
34
+ <Typography variant="label1">{item.label}</Typography>
35
+ <Typography variant="body2">{item.value}</Typography>
36
+ </StyledValueContainer>
37
+ </>
38
+ ))}
39
+ </>
40
+ );
41
+ };
42
+
43
+ export const SidePanel = ({
44
+ variables,
45
+ bottomChildren,
46
+ containerSx,
47
+ variablesContainerSX,
48
+ imageUrl,
49
+ imageHeight = '100%',
50
+ imageWidth = '100%',
51
+ title = 'Default Title',
52
+ }: SidePanelProps) => {
53
+ return (
54
+ <>
55
+ <StyledSidePanelContainer sx={containerSx}>
56
+ {imageUrl ? (
57
+ <Image
58
+ radius={'4px'}
59
+ src={imageUrl || ''}
60
+ alt="Image"
61
+ width={imageWidth}
62
+ height={imageHeight}
63
+ />
64
+ ) : (
65
+ <StyledTextContainer>
66
+ <StyledTypography variant="subtitle1">{title}</StyledTypography>
67
+ </StyledTextContainer>
68
+ )}
69
+
70
+ <SidePanelVariables
71
+ data={variables}
72
+ variablesContainerSX={variablesContainerSX}
73
+ />
6
74
 
7
- export const SidePanel = ({ children }: SidePanelProps) => {
8
- return <></>;
75
+ {bottomChildren}
76
+ </StyledSidePanelContainer>
77
+ </>
78
+ );
9
79
  };
@@ -0,0 +1,33 @@
1
+ import { Box, Stack, styled, Typography } from '@mui/material';
2
+
3
+ export const StyledSidePanelContainer = styled(Stack)(({ theme }) => ({
4
+ width: '250px',
5
+ backgroundColor: theme.palette.surface.paperBackground,
6
+ padding: '12px',
7
+ borderRadius: '8px',
8
+ gap: '12px',
9
+ margin: '20px',
10
+ }));
11
+
12
+ export const StyledValueContainer = styled(Box)(({ theme }) => ({
13
+ backgroundColor: theme.palette.surface.defaultBackground,
14
+ display: 'flex',
15
+ alignItems: 'center',
16
+ justifyContent: 'space-between',
17
+ height: '50px',
18
+ width: '226px',
19
+ padding: '14px 12px',
20
+ borderRadius: '4px',
21
+ }));
22
+
23
+ export const StyledTextContainer = styled(Stack)(({ theme }) => ({
24
+ width: '226px',
25
+ height: '128px',
26
+ backgroundColor: theme.palette.surface.defaultBackground,
27
+ alignItems: 'center',
28
+ justifyContent: 'center',
29
+ }));
30
+
31
+ export const StyledTypography = styled(Typography)(({ theme }) => ({
32
+ color: theme.palette.text.tertiary,
33
+ }));
@@ -3,4 +3,5 @@ export * from './Avatar/Avatar';
3
3
  export * from './Card/Card';
4
4
  export * from './Chips/Chips';
5
5
  export * from './DataTable/DataTable';
6
+ export * from './SidePanel/SidePanel';
6
7
  export * from './Typography/Typography';
@@ -4,11 +4,15 @@ import {
4
4
  } from '@mui/material';
5
5
  import './ButtonLoader.css';
6
6
 
7
- export type ButtonProps = { loading?: boolean } & MuiButtonProps;
7
+ export type ButtonProps = {
8
+ loading?: boolean;
9
+ color?: string;
10
+ } & Omit<MuiButtonProps, 'color'>;
8
11
 
9
- export const Button = ({ loading = false, ...props }: ButtonProps) => {
12
+ export const Button = ({ loading = false, color, ...props }: ButtonProps) => {
10
13
  return (
11
14
  <MuiButton
15
+ sx={{ color, ...props.sx }}
12
16
  {...props}
13
17
  endIcon={loading ? <div className="buttonLoader"></div> : props.endIcon}
14
18
  disabled={props.disabled || loading}
@@ -1,4 +1,4 @@
1
- import { Box, Stack } from '@mui/material';
1
+ import { Box, Stack, useTheme } from '@mui/material';
2
2
  import { AnimatedGifs } from '../../../assets/images/gif';
3
3
  import { Button, Dialog, Typography } from '../../export';
4
4
 
@@ -11,6 +11,8 @@ export type ConfirmDialogProps = {
11
11
  onConfirm: () => void;
12
12
  onCancel: () => void;
13
13
  type: ConfirmDialogType;
14
+ confirmButtonText?: string;
15
+ cancelButtonText?: string;
14
16
  };
15
17
 
16
18
  export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
@@ -20,7 +22,10 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
20
22
  onConfirm,
21
23
  onCancel,
22
24
  type,
25
+ confirmButtonText = type === 'delete' ? 'Confirm Delete' : 'Confirm',
26
+ cancelButtonText = 'Cancel',
23
27
  }) => {
28
+ const theme = useTheme();
24
29
  if (!isOpen) return null;
25
30
 
26
31
  return (
@@ -54,15 +59,16 @@ export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({
54
59
  close();
55
60
  }}
56
61
  variant="text"
62
+ color={theme.palette.text.tertiary}
57
63
  >
58
- Cancel
64
+ {cancelButtonText}
59
65
  </Button>
60
66
  <Button
61
67
  onClick={onConfirm}
62
68
  variant="contained"
63
69
  color={type === 'delete' ? 'error' : 'primary'}
64
70
  >
65
- {type === 'delete' ? 'Confirm Delete' : 'Confirm'}
71
+ {confirmButtonText}
66
72
  </Button>
67
73
  </Stack>
68
74
  </>
@@ -1,3 +1,4 @@
1
+ import { Box } from '@mui/material';
1
2
  import { Meta } from '@storybook/react/*';
2
3
  import {
3
4
  SidePanel,
@@ -7,33 +8,66 @@ import {
7
8
  export default {
8
9
  title: 'DataDisplay/SidePanel',
9
10
  component: SidePanel,
10
- tags: ['autodocs'],
11
- argTypes: {
12
- children: {
13
- control: 'text',
14
- description: 'Content inside the Avatar component',
15
- },
16
- src: {
17
- control: 'text',
18
- description: 'Image source for the Avatar component',
19
- },
20
- variant: {
21
- control: {
22
- type: 'select',
23
- options: ['circular', 'rounded', 'square'],
24
- },
25
- description: 'Variant of the Avatar component',
26
- },
27
- sx: {
28
- control: 'object',
29
- description: 'Custom styling for the Avatar component',
30
- },
31
- },
32
11
  } as Meta<typeof SidePanel>;
33
12
 
34
13
  export const withText = {
35
14
  render: (args: SidePanelProps) => <SidePanel {...args} />,
36
15
  args: {
37
- children: 'SS',
16
+ variables: [
17
+ {
18
+ label: 'Frequency',
19
+ value: 'Daily',
20
+ },
21
+ {
22
+ label: 'Start Date',
23
+ value: '5 July, 2024',
24
+ },
25
+ {
26
+ label: 'Time',
27
+ value: '04:00 PM',
28
+ },
29
+ ],
30
+ },
31
+ };
32
+
33
+ export const WithImage = {
34
+ render: (args: SidePanelProps) => <SidePanel {...args} />,
35
+ args: {
36
+ imageUrl: `https://fastly.picsum.photos/id/1063/536/354.jpg?hmac=c-ouc6pAVYGm1E0uLcnK_cavuLd8J0VPbodIe_CG8s0`,
37
+ variables: [
38
+ {
39
+ label: 'Frequency',
40
+ value: 'Daily',
41
+ },
42
+ {
43
+ label: 'Start Date',
44
+ value: '5 July, 2024',
45
+ },
46
+ {
47
+ label: 'Time',
48
+ value: '04:00 PM',
49
+ },
50
+ ],
51
+ },
52
+ };
53
+ export const WithBottomComponent = {
54
+ render: (args: SidePanelProps) => <SidePanel {...args} />,
55
+ args: {
56
+ imageUrl: `https://fastly.picsum.photos/id/1063/536/354.jpg?hmac=c-ouc6pAVYGm1E0uLcnK_cavuLd8J0VPbodIe_CG8s0`,
57
+ variables: [
58
+ {
59
+ label: 'Frequency',
60
+ value: 'Daily',
61
+ },
62
+ {
63
+ label: 'Start Date',
64
+ value: '5 July, 2024',
65
+ },
66
+ {
67
+ label: 'Time',
68
+ value: '04:00 PM',
69
+ },
70
+ ],
71
+ bottomChildren: <Box>here your component</Box>,
38
72
  },
39
73
  };
@@ -19,6 +19,14 @@ const meta: Meta<typeof ConfirmDialog> = {
19
19
  description: 'Message text displayed in the dialog',
20
20
  control: 'text',
21
21
  },
22
+ cancelButtonText: {
23
+ description: 'Text displayed on the cancel button',
24
+ control: 'text',
25
+ },
26
+ confirmButtonText: {
27
+ description: 'Text displayed on the confirm button',
28
+ control: 'text',
29
+ },
22
30
  type: {
23
31
  description: "Type of confirmation dialog ('confirm' or 'delete')",
24
32
  control: {
@@ -16,6 +16,9 @@ export const DarkColorTokens = {
16
16
  primary: ColorPalette.GreyColors.White,
17
17
  secondary: ColorPalette.GreyColors.White70,
18
18
  tertiary: ColorPalette.GreyColors.White50,
19
+ black: ColorPalette.GreyColors.Black,
20
+ white: ColorPalette.GreyColors.White,
21
+ primaryContrast: ColorPalette.BlueGreyColors.BlueGrey800,
19
22
  },
20
23
  surface: {
21
24
  defaultBackground: ColorPalette.BlueGreyColors.BlueGrey600,
@@ -16,6 +16,9 @@ export const LightColorTokens = {
16
16
  primary: ColorPalette.GreyColors.Black,
17
17
  secondary: ColorPalette.GreyColors.Black70,
18
18
  tertiary: ColorPalette.GreyColors.Black50,
19
+ black: ColorPalette.GreyColors.Black,
20
+ white: ColorPalette.GreyColors.White,
21
+ primaryContrast: ColorPalette.GreyColors.White,
19
22
  },
20
23
  surface: {
21
24
  defaultBackground: ColorPalette.BlueGreyColors.BlueGrey100,
@@ -479,7 +479,7 @@ export const getCommonTheme = (mode: Theme) => {
479
479
  },
480
480
  subtitle2: {
481
481
  fontSize: '16px',
482
- fontWeight: 500,
482
+ fontWeight: 600,
483
483
  fontFamily: 'Poppins',
484
484
  color: ColorTokens.text.primary,
485
485
  },
@@ -489,6 +489,12 @@ export const getCommonTheme = (mode: Theme) => {
489
489
  fontFamily: 'Poppins',
490
490
  color: ColorTokens.text.primary,
491
491
  },
492
+ button1: {
493
+ fontSize: '14px',
494
+ fontWeight: 600,
495
+ fontFamily: 'Poppins',
496
+ color: ColorTokens.text.primary,
497
+ },
492
498
  body1: {
493
499
  fontSize: '16px',
494
500
  fontWeight: 600,
@@ -501,12 +507,6 @@ export const getCommonTheme = (mode: Theme) => {
501
507
  fontFamily: 'Heebo',
502
508
  color: ColorTokens.text.primary,
503
509
  },
504
- caption: {
505
- fontSize: '12px',
506
- fontWeight: 400,
507
- fontFamily: 'Heebo',
508
- color: ColorTokens.text.secondary,
509
- },
510
510
  label1: {
511
511
  fontSize: '14px',
512
512
  fontWeight: 400,
@@ -514,16 +514,16 @@ export const getCommonTheme = (mode: Theme) => {
514
514
  color: ColorTokens.text.secondary,
515
515
  },
516
516
  label2: {
517
- fontSize: '12px',
517
+ fontSize: '14px',
518
518
  fontWeight: 400,
519
519
  fontFamily: 'Poppins',
520
520
  color: ColorTokens.text.secondary,
521
521
  },
522
- button1: {
523
- fontSize: '14px',
524
- fontWeight: 600,
525
- fontFamily: 'Poppins',
526
- color: ColorTokens.text.primary,
522
+ caption: {
523
+ fontSize: '12px',
524
+ fontWeight: 400,
525
+ fontFamily: 'Heebo',
526
+ color: ColorTokens.text.secondary,
527
527
  },
528
528
  } as TypographyOptions,
529
529
  },
package/types/theme.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import "@mui/material/styles";
1
+ import '@mui/material/styles';
2
2
 
3
- declare module "@mui/material/styles" {
3
+ declare module '@mui/material/styles' {
4
4
  interface Theme {
5
5
  palette: {
6
6
  [x: string]: any;
@@ -21,6 +21,9 @@ declare module "@mui/material/styles" {
21
21
  primary: string;
22
22
  secondary: string;
23
23
  tertiary: string;
24
+ black: string;
25
+ white: string;
26
+ primaryContrast: string;
24
27
  };
25
28
  surface: {
26
29
  defaultBackground: string;
@@ -49,7 +52,7 @@ declare module "@mui/material/styles" {
49
52
  export function createTheme(options?: CustomThemeOptions): CustomTheme;
50
53
  }
51
54
 
52
- declare module "@mui/material/Typography" {
55
+ declare module '@mui/material/Typography' {
53
56
  interface TypographyPropsVariantOverrides {
54
57
  label1: true;
55
58
  label2: true;