@campxdev/react-blueprint 0.1.0
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/.storybook/main.ts +29 -0
- package/.storybook/preview.tsx +28 -0
- package/.vscode/settings.json +3 -0
- package/README.md +100 -0
- package/bitbucket-pipelines.yml +60 -0
- package/exports.ts +1 -0
- package/package.json +74 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/src/App.css +38 -0
- package/src/App.test.tsx +9 -0
- package/src/App.tsx +12 -0
- package/src/assets/fonts/heebo/Heebo-Medium.ttf +0 -0
- package/src/assets/fonts/heebo/Heebo-SemiBold.ttf +0 -0
- package/src/assets/fonts/heebo/index.ts +3 -0
- package/src/assets/fonts/poppins/Poppins-Bold.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Light.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Medium.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-Regular.ttf +0 -0
- package/src/assets/fonts/poppins/Poppins-SemiBold.ttf +0 -0
- package/src/assets/fonts/poppins/index.ts +14 -0
- package/src/assets/images/admin.png +0 -0
- package/src/assets/images/campx_logo__full_primary.png +0 -0
- package/src/assets/images/collegex.png +0 -0
- package/src/assets/images/commutex.png +0 -0
- package/src/assets/images/enrollx.png +0 -0
- package/src/assets/images/examx.png +0 -0
- package/src/assets/images/hostelx copy.png +0 -0
- package/src/assets/images/hostelx.png +0 -0
- package/src/assets/images/icons.tsx +193 -0
- package/src/assets/images/index.ts +25 -0
- package/src/assets/images/payx.png +0 -0
- package/src/assets/images/pepolex.png +0 -0
- package/src/assets/images/svg/commutex_small.svg +11 -0
- package/src/assets/images/svg/enroll_logo.svg +9 -0
- package/src/assets/images/svg/exams_small.svg +12 -0
- package/src/assets/images/svg/help-icon.svg +8 -0
- package/src/assets/images/svg/hostel_small.svg +13 -0
- package/src/assets/images/svg/index.ts +19 -0
- package/src/assets/images/svg/payx_small.svg +16 -0
- package/src/assets/images/svg/people_small.svg +9 -0
- package/src/assets/images/svg/squareSmall.svg +9 -0
- package/src/assets/images/svg/square_small.svg +9 -0
- package/src/components/DropDownMenu/DropDownButton.tsx +30 -0
- package/src/components/DropDownMenu/DropDownIcon.tsx +31 -0
- package/src/components/DropDownMenu/DropDownMenu.stories.tsx +139 -0
- package/src/components/DropDownMenu/DropDownMenu.tsx +65 -0
- package/src/components/DropDownMenu/MenuItemButton.tsx +29 -0
- package/src/components/DropDownMenu/styles.tsx +31 -0
- package/src/components/Input/Button/Button.stories.tsx +62 -0
- package/src/components/Input/Button/Button.tsx +11 -0
- package/src/components/Input/Label/Label.tsx +11 -0
- package/src/components/Input/SingleSelect/SingleSelect.stories.tsx +55 -0
- package/src/components/Input/SingleSelect/SingleSelect.tsx +4 -0
- package/src/components/Input/Switch/Switch.stories.tsx +62 -0
- package/src/components/Input/Switch/Switch.tsx +11 -0
- package/src/components/Input/TextField/TextField.stories.tsx +135 -0
- package/src/components/Input/TextField/TextField.tsx +35 -0
- package/src/components/Layout/ComponentBackground/ComponentBackground.tsx +82 -0
- package/src/components/Layout/ComponentBackground/DefaultBackground.tsx +12 -0
- package/src/components/Layout/ComponentBackground/PaperBackground.tsx +12 -0
- package/src/components/Layout/Header/AppHeader.stories.tsx +209 -0
- package/src/components/Layout/Header/AppHeader.tsx +70 -0
- package/src/components/Layout/Header/AppLogo.tsx +53 -0
- package/src/components/Layout/Header/AppsMenu.tsx +162 -0
- package/src/components/Layout/Header/HeaderActions/CogWheelMenu.tsx +30 -0
- package/src/components/Layout/Header/HeaderActions/HeaderActions.tsx +63 -0
- package/src/components/Layout/Header/HeaderActions/UserBox.tsx +117 -0
- package/src/components/Layout/Header/styles/styles.tsx +69 -0
- package/src/components/Typography/Typography.stories.tsx +95 -0
- package/src/components/Typography/Typography.tsx +12 -0
- package/src/components/index.ts +1 -0
- package/src/contexts/Providers.tsx +6 -0
- package/src/index.css +13 -0
- package/src/index.tsx +19 -0
- package/src/logo.svg +1 -0
- package/src/react-app-env.d.ts +1 -0
- package/src/reportWebVitals.ts +15 -0
- package/src/setupTests.ts +5 -0
- package/src/stories/Button.stories.ts +52 -0
- package/src/stories/Button.tsx +48 -0
- package/src/stories/Configure.mdx +364 -0
- package/src/stories/Header.stories.ts +33 -0
- package/src/stories/Header.tsx +56 -0
- package/src/stories/Page.stories.ts +32 -0
- package/src/stories/Page.tsx +73 -0
- package/src/stories/assets/accessibility.png +0 -0
- package/src/stories/assets/accessibility.svg +5 -0
- package/src/stories/assets/addon-library.png +0 -0
- package/src/stories/assets/assets.png +0 -0
- package/src/stories/assets/avif-test-image.avif +0 -0
- package/src/stories/assets/context.png +0 -0
- package/src/stories/assets/discord.svg +15 -0
- package/src/stories/assets/docs.png +0 -0
- package/src/stories/assets/figma-plugin.png +0 -0
- package/src/stories/assets/github.svg +3 -0
- package/src/stories/assets/share.png +0 -0
- package/src/stories/assets/styling.png +0 -0
- package/src/stories/assets/testing.png +0 -0
- package/src/stories/assets/theming.png +0 -0
- package/src/stories/assets/tutorials.svg +12 -0
- package/src/stories/assets/youtube.svg +4 -0
- package/src/stories/button.css +30 -0
- package/src/stories/header.css +32 -0
- package/src/stories/page.css +69 -0
- package/src/themes/MuiThemeProvider.tsx +18 -0
- package/src/themes/colorTokens.stories.tsx +71 -0
- package/src/themes/colorTokens.ts +77 -0
- package/src/themes/commonTheme.ts +443 -0
- package/src/themes/customCssBaseline.ts +39 -0
- package/src/themes/darkTheme.ts +24 -0
- package/src/themes/index.ts +4 -0
- package/src/themes/lightTheme.ts +22 -0
- package/src/themes/typography.stories.tsx +79 -0
- package/src/utils/applications.ts +140 -0
- package/src/utils/constants.ts +6 -0
- package/src/utils/imageMap.ts +22 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Button, IconButton, MenuItem, styled } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
export const StyledDropDownButton = styled(Button)(({}) => ({
|
|
4
|
+
minWidth: "180px",
|
|
5
|
+
justifyContent: "space-between",
|
|
6
|
+
}));
|
|
7
|
+
|
|
8
|
+
export const StyledIconButton = styled(IconButton, {
|
|
9
|
+
shouldForwardProp: (prop) => prop !== "outlined",
|
|
10
|
+
})<{ outlined?: boolean }>(({ theme, outlined }) => ({
|
|
11
|
+
...(outlined && {
|
|
12
|
+
border: `1px solid ${theme.palette.primary.main}`,
|
|
13
|
+
borderRadius: "5px",
|
|
14
|
+
height: "40px",
|
|
15
|
+
width: "40px",
|
|
16
|
+
}),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
export const StyledMenuItem = styled(MenuItem)(({}) => ({
|
|
20
|
+
display: "flex",
|
|
21
|
+
alignItems: "center",
|
|
22
|
+
height: "50px",
|
|
23
|
+
gap: "5px",
|
|
24
|
+
"& .MuiListItemIcon-root": {
|
|
25
|
+
minWidth: "24px",
|
|
26
|
+
},
|
|
27
|
+
"& .MuiSvgIcon-root": {
|
|
28
|
+
height: "14px",
|
|
29
|
+
width: "14px",
|
|
30
|
+
},
|
|
31
|
+
}));
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Import React and other necessary elements
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
|
|
4
|
+
// Make sure your TextField import is correct
|
|
5
|
+
|
|
6
|
+
import Button, { ButtonProps } from "./Button";
|
|
7
|
+
|
|
8
|
+
// Define the default export with Meta type including the component type
|
|
9
|
+
export default {
|
|
10
|
+
title: "Input/Button",
|
|
11
|
+
component: Button,
|
|
12
|
+
tags: ["autodocs"],
|
|
13
|
+
argTypes: {
|
|
14
|
+
variant: {
|
|
15
|
+
control: "select",
|
|
16
|
+
options: ["contained", "outlined", "text", "string"],
|
|
17
|
+
description: "The Button Variant to use",
|
|
18
|
+
},
|
|
19
|
+
children: {
|
|
20
|
+
control: "text",
|
|
21
|
+
description: "text in button",
|
|
22
|
+
},
|
|
23
|
+
color: {
|
|
24
|
+
control: "select",
|
|
25
|
+
options: ["primary", "secondary"],
|
|
26
|
+
description: "The Button Variant to use",
|
|
27
|
+
},
|
|
28
|
+
disabled: {
|
|
29
|
+
control: "boolean",
|
|
30
|
+
description: "Disabled Button",
|
|
31
|
+
defaultValue: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
} as Meta<typeof Button>;
|
|
35
|
+
|
|
36
|
+
// Define stories directly as objects with render function
|
|
37
|
+
export const Primary = {
|
|
38
|
+
render: (args: ButtonProps) => <Button {...args} />,
|
|
39
|
+
args: {
|
|
40
|
+
color: "primary",
|
|
41
|
+
variant: "contained",
|
|
42
|
+
children: "Primary Button",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const Secondary = {
|
|
47
|
+
render: (args: ButtonProps) => <Button {...args} />,
|
|
48
|
+
args: {
|
|
49
|
+
color: "secondary",
|
|
50
|
+
variant: "contained",
|
|
51
|
+
children: "Secondary Button",
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const Disabled = {
|
|
56
|
+
render: (args: ButtonProps) => <Button {...args} />,
|
|
57
|
+
args: {
|
|
58
|
+
disabled: true,
|
|
59
|
+
variant: "contained",
|
|
60
|
+
children: "Disabled Button",
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Typography } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
const Label = ({ label, required, name }: any) => {
|
|
4
|
+
if (typeof label !== "string") return label;
|
|
5
|
+
return (
|
|
6
|
+
<Typography htmlFor={name} component="label" variant="label1">
|
|
7
|
+
{label} {required && <span>{" *"}</span>}
|
|
8
|
+
</Typography>
|
|
9
|
+
);
|
|
10
|
+
};
|
|
11
|
+
export default Label;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// Import React and other necessary elements
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
|
|
4
|
+
// Make sure your TextField import is correct
|
|
5
|
+
import { TextFieldProps } from "@mui/material";
|
|
6
|
+
import SingleSelect from "./SingleSelect";
|
|
7
|
+
|
|
8
|
+
// Define the default export with Meta type including the component type
|
|
9
|
+
export default {
|
|
10
|
+
title: "Input/SingleSelect",
|
|
11
|
+
component: SingleSelect,
|
|
12
|
+
tags: ["autodocs"],
|
|
13
|
+
argTypes: {},
|
|
14
|
+
} as Meta<typeof SingleSelect>;
|
|
15
|
+
|
|
16
|
+
// Define stories directly as objects with render function
|
|
17
|
+
export const Primary = {
|
|
18
|
+
render: (args: TextFieldProps) => <SingleSelect {...args} />,
|
|
19
|
+
args: {},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const Disabled = {
|
|
23
|
+
render: (args: TextFieldProps) => <SingleSelect {...args} />,
|
|
24
|
+
args: {},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const WithValue = {
|
|
28
|
+
render: (args: TextFieldProps) => <SingleSelect {...args} />,
|
|
29
|
+
args: {},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const InputWithPlaceholder = {
|
|
33
|
+
render: (args: TextFieldProps) => <SingleSelect {...args} />,
|
|
34
|
+
args: {},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const ErrorInput = {
|
|
38
|
+
render: (args: TextFieldProps) => <SingleSelect {...args} />,
|
|
39
|
+
args: {},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const SuccessInput = {
|
|
43
|
+
render: (args: TextFieldProps) => <SingleSelect {...args} />,
|
|
44
|
+
args: {},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const WarningInput = {
|
|
48
|
+
render: (args: TextFieldProps) => <SingleSelect {...args} />,
|
|
49
|
+
args: {},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const PassowrdInput = {
|
|
53
|
+
render: (args: TextFieldProps) => <SingleSelect {...args} />,
|
|
54
|
+
args: {},
|
|
55
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// Import React and other necessary elements
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
|
|
4
|
+
// Make sure your TextField import is correct
|
|
5
|
+
|
|
6
|
+
import Switch, { SwitchProps } from "./Switch";
|
|
7
|
+
|
|
8
|
+
// Define the default export with Meta type including the component type
|
|
9
|
+
export default {
|
|
10
|
+
title: "Input/Switch",
|
|
11
|
+
component: Switch,
|
|
12
|
+
tags: ["autodocs"],
|
|
13
|
+
argTypes: {
|
|
14
|
+
variant: {
|
|
15
|
+
control: "select",
|
|
16
|
+
options: ["contained", "outlined", "text", "string"],
|
|
17
|
+
description: "The Switch Variant to use",
|
|
18
|
+
},
|
|
19
|
+
children: {
|
|
20
|
+
control: "text",
|
|
21
|
+
description: "text in Switch",
|
|
22
|
+
},
|
|
23
|
+
color: {
|
|
24
|
+
control: "select",
|
|
25
|
+
options: ["primary", "secondary"],
|
|
26
|
+
description: "The Switch Variant to use",
|
|
27
|
+
},
|
|
28
|
+
disabled: {
|
|
29
|
+
control: "boolean",
|
|
30
|
+
description: "Disabled Switch",
|
|
31
|
+
defaultValue: false,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
} as Meta<typeof Switch>;
|
|
35
|
+
|
|
36
|
+
// Define stories directly as objects with render function
|
|
37
|
+
export const Primary = {
|
|
38
|
+
render: (args: SwitchProps) => <Switch {...args} />,
|
|
39
|
+
args: {
|
|
40
|
+
color: "primary",
|
|
41
|
+
variant: "contained",
|
|
42
|
+
children: "Primary Switch",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const Secondary = {
|
|
47
|
+
render: (args: SwitchProps) => <Switch {...args} />,
|
|
48
|
+
args: {
|
|
49
|
+
color: "secondary",
|
|
50
|
+
variant: "contained",
|
|
51
|
+
children: "Secondary Switch",
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const Disabled = {
|
|
56
|
+
render: (args: SwitchProps) => <Switch {...args} />,
|
|
57
|
+
args: {
|
|
58
|
+
disabled: true,
|
|
59
|
+
variant: "contained",
|
|
60
|
+
children: "Disabled Switch",
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Import React and other necessary elements
|
|
2
|
+
import { Meta } from "@storybook/react";
|
|
3
|
+
|
|
4
|
+
// Make sure your TextField import is correct
|
|
5
|
+
import TextField, { TextFieldProps } from "./TextField";
|
|
6
|
+
|
|
7
|
+
// Define the default export with Meta type including the component type
|
|
8
|
+
export default {
|
|
9
|
+
title: "Input/TextField",
|
|
10
|
+
component: TextField,
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
argTypes: {
|
|
13
|
+
name: {
|
|
14
|
+
control: "text",
|
|
15
|
+
description: "The name of the input field, used in form submissions.",
|
|
16
|
+
},
|
|
17
|
+
label: {
|
|
18
|
+
control: "text",
|
|
19
|
+
description: "The label text disp layed above the input field.",
|
|
20
|
+
},
|
|
21
|
+
value: {
|
|
22
|
+
control: "text",
|
|
23
|
+
description: "The input value of the TextField.",
|
|
24
|
+
},
|
|
25
|
+
required: {
|
|
26
|
+
control: "boolean",
|
|
27
|
+
description: "Specifies if the field is required for form submission.",
|
|
28
|
+
},
|
|
29
|
+
placeholder: {
|
|
30
|
+
control: "text",
|
|
31
|
+
description: "The placeholder value of the TextField.",
|
|
32
|
+
},
|
|
33
|
+
disabled: {
|
|
34
|
+
control: "boolean",
|
|
35
|
+
description: "Controls whether the TextField is disabled or not.",
|
|
36
|
+
},
|
|
37
|
+
helperText: {
|
|
38
|
+
control: "text",
|
|
39
|
+
description:
|
|
40
|
+
"Helper text that appears below the text field to provide additional guidance.",
|
|
41
|
+
},
|
|
42
|
+
error: {
|
|
43
|
+
control: "boolean",
|
|
44
|
+
description: "Shows how the error message is shown",
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
} as Meta<typeof TextField>;
|
|
48
|
+
|
|
49
|
+
// Define stories directly as objects with render function
|
|
50
|
+
export const Primary = {
|
|
51
|
+
render: (args: TextFieldProps) => <TextField {...args} />,
|
|
52
|
+
args: {
|
|
53
|
+
label: "First Name",
|
|
54
|
+
name: "firstName",
|
|
55
|
+
value: "",
|
|
56
|
+
required: true,
|
|
57
|
+
helperText: "",
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const Disabled = {
|
|
62
|
+
render: (args: TextFieldProps) => <TextField {...args} />,
|
|
63
|
+
args: {
|
|
64
|
+
label: "Disabled Input",
|
|
65
|
+
name: "disabledInput",
|
|
66
|
+
value: "Disabled",
|
|
67
|
+
required: false,
|
|
68
|
+
disabled: true,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const WithValue = {
|
|
73
|
+
render: (args: TextFieldProps) => <TextField {...args} />,
|
|
74
|
+
args: {
|
|
75
|
+
label: "Last Name",
|
|
76
|
+
name: "lastName",
|
|
77
|
+
value: "Doe",
|
|
78
|
+
required: false,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const InputWithPlaceholder = {
|
|
83
|
+
render: (args: TextFieldProps) => <TextField {...args} />,
|
|
84
|
+
args: {
|
|
85
|
+
label: "Mobile",
|
|
86
|
+
value: "",
|
|
87
|
+
placeholder: "10 digit phone number",
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const ErrorInput = {
|
|
92
|
+
render: (args: TextFieldProps) => <TextField {...args} />,
|
|
93
|
+
args: {
|
|
94
|
+
label: "First Name",
|
|
95
|
+
required: true,
|
|
96
|
+
value: "",
|
|
97
|
+
error: true,
|
|
98
|
+
helperText: "Name can't be empty",
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const SuccessInput = {
|
|
103
|
+
render: (args: TextFieldProps) => <TextField {...args} />,
|
|
104
|
+
args: {
|
|
105
|
+
label: "Pan Card",
|
|
106
|
+
required: true,
|
|
107
|
+
value: "KAHPS9888B",
|
|
108
|
+
color: "success",
|
|
109
|
+
helperText: "Pan Card Successfully Verified",
|
|
110
|
+
focused: true,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const WarningInput = {
|
|
115
|
+
render: (args: TextFieldProps) => <TextField {...args} />,
|
|
116
|
+
args: {
|
|
117
|
+
label: "Pan Card",
|
|
118
|
+
required: true,
|
|
119
|
+
value: "KAHPS9888B",
|
|
120
|
+
color: "warning",
|
|
121
|
+
helperText: `Pan Card doesn't match with the provided name`,
|
|
122
|
+
focused: true,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export const PassowrdInput = {
|
|
127
|
+
render: (args: TextFieldProps) => <TextField {...args} />,
|
|
128
|
+
args: {
|
|
129
|
+
label: "Password",
|
|
130
|
+
type: "password",
|
|
131
|
+
required: true,
|
|
132
|
+
value: "KAHPS9888B",
|
|
133
|
+
helperText: "Password should be alpha-numeric with special character",
|
|
134
|
+
},
|
|
135
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TextField as MuiTextField,
|
|
3
|
+
TextFieldProps as MuiTextFieldProps,
|
|
4
|
+
Stack,
|
|
5
|
+
StackProps,
|
|
6
|
+
} from "@mui/material";
|
|
7
|
+
import Label from "../Label/Label";
|
|
8
|
+
|
|
9
|
+
export type TextFieldProps = {
|
|
10
|
+
containerProps?: StackProps;
|
|
11
|
+
} & MuiTextFieldProps;
|
|
12
|
+
|
|
13
|
+
export default function TextField({
|
|
14
|
+
name,
|
|
15
|
+
label,
|
|
16
|
+
value,
|
|
17
|
+
onChange,
|
|
18
|
+
required = false,
|
|
19
|
+
containerProps,
|
|
20
|
+
...rest
|
|
21
|
+
}: TextFieldProps) {
|
|
22
|
+
return (
|
|
23
|
+
<Stack margin="15px 20px" {...containerProps}>
|
|
24
|
+
<Label label={label} required={required} name={name} />
|
|
25
|
+
<MuiTextField
|
|
26
|
+
id={name}
|
|
27
|
+
value={value}
|
|
28
|
+
label={label}
|
|
29
|
+
name={name}
|
|
30
|
+
onChange={onChange}
|
|
31
|
+
{...rest}
|
|
32
|
+
/>
|
|
33
|
+
</Stack>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Stack,
|
|
3
|
+
Switch,
|
|
4
|
+
SxProps,
|
|
5
|
+
ToggleButton,
|
|
6
|
+
ToggleButtonGroup,
|
|
7
|
+
} from "@mui/material";
|
|
8
|
+
import { ReactNode, useState } from "react";
|
|
9
|
+
import { darkTheme, lightTheme } from "../../../themes";
|
|
10
|
+
import MuiThemeProvider from "../../../themes/MuiThemeProvider";
|
|
11
|
+
import Typography from "../../Typography/Typography";
|
|
12
|
+
import { DefaultBackground } from "./DefaultBackground";
|
|
13
|
+
import { PaperBackground } from "./PaperBackground";
|
|
14
|
+
|
|
15
|
+
export enum ComponentBackgroundTypes {
|
|
16
|
+
DEFAULT = "default",
|
|
17
|
+
PAPER = "paper",
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type ComponentBackgroundProps = {
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
sx?: SxProps;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const BackgroundComponent = ({
|
|
26
|
+
children,
|
|
27
|
+
backgroundType,
|
|
28
|
+
sx,
|
|
29
|
+
}: {
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
backgroundType: ComponentBackgroundTypes;
|
|
32
|
+
sx?: SxProps;
|
|
33
|
+
}) => {
|
|
34
|
+
switch (backgroundType) {
|
|
35
|
+
case ComponentBackgroundTypes.DEFAULT:
|
|
36
|
+
return <DefaultBackground sx={sx}>{children}</DefaultBackground>;
|
|
37
|
+
case ComponentBackgroundTypes.PAPER:
|
|
38
|
+
return <PaperBackground sx={sx}>{children}</PaperBackground>;
|
|
39
|
+
default:
|
|
40
|
+
return <DefaultBackground sx={sx}>{children}</DefaultBackground>;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const ComponentBackground = ({ children, sx }: ComponentBackgroundProps) => {
|
|
45
|
+
const [darkMode, setDarkMode] = useState(false);
|
|
46
|
+
const [backgroundType, setBackgroundType] =
|
|
47
|
+
useState<ComponentBackgroundTypes>(ComponentBackgroundTypes.DEFAULT);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<MuiThemeProvider theme={darkMode ? darkTheme : lightTheme}>
|
|
51
|
+
<BackgroundComponent backgroundType={backgroundType} sx={sx}>
|
|
52
|
+
{children}
|
|
53
|
+
<Stack gap={2} direction="row" marginTop="50px">
|
|
54
|
+
<Switch
|
|
55
|
+
onChange={(e) => {
|
|
56
|
+
setDarkMode(e.target.checked);
|
|
57
|
+
}}
|
|
58
|
+
/>
|
|
59
|
+
<Typography variant="label1">Dark Mode</Typography>
|
|
60
|
+
<ToggleButtonGroup
|
|
61
|
+
color="primary"
|
|
62
|
+
value={backgroundType}
|
|
63
|
+
exclusive
|
|
64
|
+
onChange={(e, v) => {
|
|
65
|
+
setBackgroundType(v);
|
|
66
|
+
}}
|
|
67
|
+
aria-label="Platform"
|
|
68
|
+
>
|
|
69
|
+
<ToggleButton value={ComponentBackgroundTypes.DEFAULT}>
|
|
70
|
+
DEFAULT
|
|
71
|
+
</ToggleButton>
|
|
72
|
+
<ToggleButton value={ComponentBackgroundTypes.PAPER}>
|
|
73
|
+
PAPER
|
|
74
|
+
</ToggleButton>
|
|
75
|
+
</ToggleButtonGroup>
|
|
76
|
+
</Stack>
|
|
77
|
+
</BackgroundComponent>
|
|
78
|
+
</MuiThemeProvider>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default ComponentBackground;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Box, styled } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
export const DefaultBackground = styled(Box)(({ theme }) => ({
|
|
4
|
+
minHeight: "150px",
|
|
5
|
+
backgroundColor: theme.palette.background.default,
|
|
6
|
+
minWidth: "600px",
|
|
7
|
+
display: "flex",
|
|
8
|
+
flexDirection: "column",
|
|
9
|
+
justifyContent: "center",
|
|
10
|
+
alignItems: "center",
|
|
11
|
+
padding: "50px",
|
|
12
|
+
}));
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Box, styled } from "@mui/material";
|
|
2
|
+
|
|
3
|
+
export const PaperBackground = styled(Box)(({ theme }) => ({
|
|
4
|
+
minHeight: "150px",
|
|
5
|
+
backgroundColor: theme.palette.background.paper,
|
|
6
|
+
minWidth: "600px",
|
|
7
|
+
display: "flex",
|
|
8
|
+
flexDirection: "column",
|
|
9
|
+
justifyContent: "center",
|
|
10
|
+
alignItems: "center",
|
|
11
|
+
padding: "50px",
|
|
12
|
+
}));
|