@lunit/design-system 1.0.0 → 2.0.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/dist/cjs/components/Alert/index.js +1 -1
- package/dist/cjs/components/Alert/index.js.map +1 -1
- package/dist/cjs/components/Button/index.js +1 -1
- package/dist/cjs/components/Button/index.js.map +1 -1
- package/dist/cjs/components/Checkbox/index.js +1 -1
- package/dist/cjs/components/Checkbox/index.js.map +1 -1
- package/dist/cjs/components/Dialog/index.js +2 -0
- package/dist/cjs/components/Dialog/index.js.map +1 -0
- package/dist/cjs/components/Radio/index.js +1 -1
- package/dist/cjs/components/Radio/index.js.map +1 -1
- package/dist/cjs/components/ToggleButton/index.js +1 -1
- package/dist/cjs/components/ToggleButton/index.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/components/Button/Button.styled.js +1 -1
- package/dist/components/Button/Button.styled.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.js +9 -19
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Dialog/Dialog.js +61 -0
- package/dist/components/Dialog/Dialog.js.map +1 -0
- package/dist/components/Dialog/Dialog.styled.js +137 -0
- package/dist/components/Dialog/Dialog.styled.js.map +1 -0
- package/dist/components/Dialog/components/DialogAction.js +18 -0
- package/dist/components/Dialog/components/DialogAction.js.map +1 -0
- package/dist/components/Dialog/index.js +2 -0
- package/dist/components/Dialog/index.js.map +1 -0
- package/dist/components/Radio/Radio.js +7 -21
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/ToggleButton/ToggleButton.styled.js +1 -1
- package/dist/components/ToggleButton/ToggleButton.styled.js.map +1 -1
- package/dist/foundation/Elevation/index.js +1 -1
- package/dist/foundation/Elevation/index.js.map +1 -1
- package/dist/foundation/Typography/index.js +0 -6
- package/dist/foundation/Typography/index.js.map +1 -1
- package/dist/foundation/Typography/tokens.js +1 -1
- package/dist/foundation/colors/base/grey.js +3 -1
- package/dist/foundation/colors/base/grey.js.map +1 -1
- package/dist/foundation/colors/index.js +5 -6
- package/dist/foundation/colors/index.js.map +1 -1
- package/dist/foundation/colors/token/component.js +31 -115
- package/dist/foundation/colors/token/component.js.map +1 -1
- package/dist/foundation/colors/token/core.js +43 -75
- package/dist/foundation/colors/token/core.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/components/Alert/Alert.utils.d.ts +3 -3
- package/dist/types/components/Button/Button.styled.d.ts +9 -9
- package/dist/types/components/Chip/Chip.styled.d.ts +12 -12
- package/dist/types/components/Dialog/Dialog.d.ts +50 -0
- package/dist/types/components/Dialog/Dialog.styled.d.ts +12 -0
- package/dist/types/components/Dialog/components/DialogAction.d.ts +8 -0
- package/dist/types/components/Dialog/index.d.ts +2 -0
- package/dist/types/components/Toast/Toast.utils.d.ts +1 -1
- package/dist/types/components/ToggleButton/ToggleButton.styled.d.ts +2 -2
- package/dist/types/foundation/Elevation/index.d.ts +1 -1
- package/dist/types/foundation/Typography/index.d.ts +1 -7
- package/dist/types/foundation/Typography/tokens.d.ts +1 -1
- package/dist/types/foundation/colors/base/grey.d.ts +2 -0
- package/dist/types/foundation/colors/index.d.ts +5 -6
- package/dist/types/foundation/colors/token/types.d.ts +0 -2
- package/dist/types/foundation/colors/types.d.ts +78 -76
- package/dist/types/foundation/index.d.ts +5 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Button/Button.styled.ts +1 -1
- package/src/components/Checkbox/Checkbox.tsx +39 -22
- package/src/components/Dialog/Dialog.styled.ts +165 -0
- package/src/components/Dialog/Dialog.tsx +195 -0
- package/src/components/Dialog/components/DialogAction.tsx +36 -0
- package/src/components/Dialog/index.ts +14 -0
- package/src/components/Radio/Radio.tsx +37 -25
- package/src/components/ToggleButton/ToggleButton.styled.ts +1 -1
- package/src/foundation/Elevation/index.ts +1 -1
- package/src/foundation/Typography/index.ts +0 -6
- package/src/foundation/Typography/tokens.ts +1 -1
- package/src/foundation/colors/base/grey.ts +3 -1
- package/src/foundation/colors/index.ts +5 -6
- package/src/foundation/colors/token/component.ts +24 -108
- package/src/foundation/colors/token/core.ts +39 -71
- package/src/foundation/colors/token/types.ts +0 -2
- package/src/foundation/colors/types.ts +78 -75
- package/src/index.ts +1 -1
- package/src/stories/GettingStarted.mdx +88 -0
- package/src/stories/components/Button/BasicButton.stories.tsx +80 -52
- package/src/stories/components/Button/ButtonDocs.mdx +187 -0
- package/src/stories/components/Button/Color.stories.tsx +132 -0
- package/src/stories/components/Button/IconButton.stories.tsx +41 -35
- package/src/stories/components/Button/Kind.stories.tsx +13 -52
- package/src/stories/components/{SelectControl/Checkbox.stories.tsx → CheckBox/BasicCheckbox.stories.tsx} +84 -105
- package/src/stories/components/CheckBox/CheckboxDocs.mdx +85 -0
- package/src/stories/components/Chip/Chip.stories.tsx +65 -0
- package/src/stories/components/Chip/ChipDocs.mdx +132 -0
- package/src/stories/components/Dialog/Dialog.stories.tsx +320 -0
- package/src/stories/components/TextField/BasicTextField.stories.tsx +214 -0
- package/src/stories/components/TextField/TextFieldDocs.mdx +140 -0
- package/src/stories/components/TextField/TextFieldSize.stories.tsx +26 -3
- package/src/stories/components/ToggleButton/Basic.stories.tsx +312 -0
- package/src/stories/components/ToggleButton/ToggleButtonDocs.mdx +180 -0
- package/src/stories/components/ToggleButton/ToggleButtonKind.stories.tsx +65 -0
- package/src/stories/components/ToggleButton/WithIcon.stories.tsx +138 -0
- package/src/stories/foundation/Typography/Typography.mdx +31 -46
- package/src/stories/foundation/Typography/Typography.stories.tsx +30 -1
- package/src/stories/foundation/colors/ColorSystem.tsx +86 -0
- package/src/stories/foundation/colors/Docs.mdx +225 -0
- package/src/stories/foundation/colors/TokenPaletteTable.tsx +1 -5
- package/src/components/Modal/Modal.tsx +0 -8
- package/src/components/Modal/index.ts +0 -1
- package/src/stories/components/Modal/Modal.stories.tsx +0 -15
- package/src/stories/foundation/Typography/TypographyExamples.stories.tsx +0 -44
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box } from "@mui/material";
|
|
3
|
+
import { action } from "@storybook/addon-actions";
|
|
4
|
+
|
|
5
|
+
import Button from "@/components/Button";
|
|
6
|
+
|
|
7
|
+
import type { StoryFn, Meta } from "@storybook/react";
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
title: "Components/Button",
|
|
11
|
+
component: Button,
|
|
12
|
+
args: {
|
|
13
|
+
children: "Text",
|
|
14
|
+
disabled: false,
|
|
15
|
+
size: "small",
|
|
16
|
+
onClick: action("onClick"),
|
|
17
|
+
},
|
|
18
|
+
argTypes: {
|
|
19
|
+
children: {
|
|
20
|
+
type: "string",
|
|
21
|
+
},
|
|
22
|
+
disabled: {
|
|
23
|
+
control: {
|
|
24
|
+
type: "boolean",
|
|
25
|
+
},
|
|
26
|
+
table: {
|
|
27
|
+
defaultValue: { summary: "false" },
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
size: {
|
|
31
|
+
control: {
|
|
32
|
+
type: "radio",
|
|
33
|
+
},
|
|
34
|
+
options: ["small", "medium", "large"],
|
|
35
|
+
table: {
|
|
36
|
+
defaultValue: { summary: "small" },
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
onClick: {
|
|
40
|
+
type: "function",
|
|
41
|
+
control: {
|
|
42
|
+
type: "radio",
|
|
43
|
+
},
|
|
44
|
+
options: ["function", undefined],
|
|
45
|
+
mapping: {
|
|
46
|
+
function: action("onClick"),
|
|
47
|
+
undefined: undefined,
|
|
48
|
+
},
|
|
49
|
+
description:
|
|
50
|
+
"It is a callback function that is called when the button is clicked.",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
parameters: {
|
|
54
|
+
controls: {
|
|
55
|
+
include: ["onClick", "children", "size", "disabled", "kind", "variant"],
|
|
56
|
+
},
|
|
57
|
+
pseudo: {
|
|
58
|
+
hover: [
|
|
59
|
+
"#hover1",
|
|
60
|
+
"#hover2",
|
|
61
|
+
"#hover3",
|
|
62
|
+
"#hover4",
|
|
63
|
+
"#hover5",
|
|
64
|
+
"#hover6",
|
|
65
|
+
"#hover7",
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
docs: {
|
|
69
|
+
description: {
|
|
70
|
+
component: `It is a kind Button docs. For more details, please
|
|
71
|
+
see [Material-UI Button](https://mui.com/material-ui/react-button/).`,
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
} as Meta<typeof Button>;
|
|
76
|
+
|
|
77
|
+
const ColorButtonTemplate: StoryFn<typeof Button> = (args) => {
|
|
78
|
+
const { children, kind, variant, ...restArgs } = args;
|
|
79
|
+
return (
|
|
80
|
+
<Box sx={{ display: "flex", flexDirection: "column", gap: 4 }}>
|
|
81
|
+
<Box>
|
|
82
|
+
<Button
|
|
83
|
+
sx={{ mr: 2 }}
|
|
84
|
+
{...restArgs}
|
|
85
|
+
variant="contained"
|
|
86
|
+
color="primary"
|
|
87
|
+
>
|
|
88
|
+
{children}
|
|
89
|
+
</Button>
|
|
90
|
+
<Button
|
|
91
|
+
sx={{ mr: 2 }}
|
|
92
|
+
{...restArgs}
|
|
93
|
+
variant="contained"
|
|
94
|
+
color="secondary"
|
|
95
|
+
>
|
|
96
|
+
{children}
|
|
97
|
+
</Button>
|
|
98
|
+
<Button {...restArgs} variant="contained" color="error">
|
|
99
|
+
{children}
|
|
100
|
+
</Button>
|
|
101
|
+
</Box>
|
|
102
|
+
<Box>
|
|
103
|
+
<Button sx={{ mr: 2 }} {...restArgs} variant="outlined" color="primary">
|
|
104
|
+
{children}
|
|
105
|
+
</Button>
|
|
106
|
+
<Button
|
|
107
|
+
sx={{ mr: 2 }}
|
|
108
|
+
{...restArgs}
|
|
109
|
+
variant="outlined"
|
|
110
|
+
color="secondary"
|
|
111
|
+
>
|
|
112
|
+
{children}
|
|
113
|
+
</Button>
|
|
114
|
+
</Box>
|
|
115
|
+
<Box>
|
|
116
|
+
<Button sx={{ mr: 2 }} {...restArgs} variant="text" color="primary">
|
|
117
|
+
{children}
|
|
118
|
+
</Button>
|
|
119
|
+
<Button sx={{ mr: 2 }} {...restArgs} variant="text" color="secondary">
|
|
120
|
+
{children}
|
|
121
|
+
</Button>
|
|
122
|
+
<Button {...restArgs} variant="text" color="error">
|
|
123
|
+
{children}
|
|
124
|
+
</Button>
|
|
125
|
+
</Box>
|
|
126
|
+
</Box>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const Color = {
|
|
131
|
+
render: ColorButtonTemplate,
|
|
132
|
+
};
|
|
@@ -5,12 +5,12 @@ import { action } from "@storybook/addon-actions";
|
|
|
5
5
|
import Button from "@/components/Button";
|
|
6
6
|
|
|
7
7
|
import type { StoryFn, Meta } from "@storybook/react";
|
|
8
|
+
import { Box } from "@mui/material";
|
|
8
9
|
|
|
9
10
|
export default {
|
|
10
11
|
title: "Components/Button",
|
|
11
12
|
component: Button,
|
|
12
13
|
args: {
|
|
13
|
-
kind: "contained",
|
|
14
14
|
color: "primary",
|
|
15
15
|
disabled: false,
|
|
16
16
|
size: "small",
|
|
@@ -26,26 +26,6 @@ export default {
|
|
|
26
26
|
type: { summary: "React.ReactNode" },
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
|
-
kind: {
|
|
30
|
-
control: {
|
|
31
|
-
type: "radio",
|
|
32
|
-
},
|
|
33
|
-
options: ["contained", "outlined", "ghost"],
|
|
34
|
-
description: "Button has three Kinds Contained, Outlined, Ghost",
|
|
35
|
-
table: {
|
|
36
|
-
defaultValue: { summary: "contained" },
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
variant: {
|
|
40
|
-
control: {
|
|
41
|
-
type: "radio",
|
|
42
|
-
},
|
|
43
|
-
options: ["contained", "outlined", "text", "ghost"],
|
|
44
|
-
description: "The variant is alias of kind.",
|
|
45
|
-
table: {
|
|
46
|
-
defaultValue: { summary: "contained" },
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
29
|
color: {
|
|
50
30
|
control: {
|
|
51
31
|
type: "radio",
|
|
@@ -89,7 +69,6 @@ export default {
|
|
|
89
69
|
parameters: {
|
|
90
70
|
controls: {
|
|
91
71
|
include: [
|
|
92
|
-
"children",
|
|
93
72
|
"icon",
|
|
94
73
|
"onClick",
|
|
95
74
|
"disabled",
|
|
@@ -108,15 +87,48 @@ export default {
|
|
|
108
87
|
},
|
|
109
88
|
} as Meta<typeof Button>;
|
|
110
89
|
|
|
111
|
-
const IconButtonTemplate: StoryFn<typeof Button> = (args) =>
|
|
112
|
-
|
|
113
|
-
{args.children}
|
|
114
|
-
</Button>
|
|
115
|
-
);
|
|
90
|
+
const IconButtonTemplate: StoryFn<typeof Button> = (args) => {
|
|
91
|
+
const { variant, kind, ...restArgs } = args;
|
|
116
92
|
|
|
117
|
-
|
|
118
|
-
|
|
93
|
+
return (
|
|
94
|
+
<Box sx={{ display: "flex", gap: 2 }}>
|
|
95
|
+
<Button icon={<Bell />} {...restArgs} kind="contained">
|
|
96
|
+
Contained
|
|
97
|
+
</Button>
|
|
98
|
+
<Button
|
|
99
|
+
icon={<Bell />}
|
|
100
|
+
{...restArgs}
|
|
101
|
+
color={args.color === "error" ? "primary" : args.color}
|
|
102
|
+
kind="outlined"
|
|
103
|
+
>
|
|
104
|
+
Outlined
|
|
105
|
+
</Button>
|
|
106
|
+
<Button icon={<Bell />} {...restArgs} kind="ghost">
|
|
107
|
+
Ghost
|
|
108
|
+
</Button>
|
|
109
|
+
</Box>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const IconOnlyButtonTemplate: StoryFn<typeof Button> = (args) => {
|
|
114
|
+
const { variant, kind, ...restArgs } = args;
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<Box sx={{ display: "flex", gap: 2 }}>
|
|
118
|
+
<Button icon={<Bell />} {...restArgs} kind="contained" />
|
|
119
|
+
<Button
|
|
120
|
+
icon={<Bell />}
|
|
121
|
+
{...restArgs}
|
|
122
|
+
color={args.color === "error" ? "primary" : args.color}
|
|
123
|
+
kind="outlined"
|
|
124
|
+
/>
|
|
125
|
+
<Button icon={<Bell />} {...restArgs} kind="ghost" />
|
|
126
|
+
</Box>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
119
129
|
|
|
130
|
+
export const IconOnlyButton = {
|
|
131
|
+
render: IconOnlyButtonTemplate,
|
|
120
132
|
argTypes: {
|
|
121
133
|
children: {
|
|
122
134
|
control: false,
|
|
@@ -126,17 +138,11 @@ export const IconOnlyButton = {
|
|
|
126
138
|
},
|
|
127
139
|
},
|
|
128
140
|
},
|
|
129
|
-
|
|
130
141
|
name: "Icon only",
|
|
131
142
|
};
|
|
132
143
|
|
|
133
144
|
export const IconWithTextButton = {
|
|
134
145
|
render: IconButtonTemplate,
|
|
135
|
-
|
|
136
|
-
args: {
|
|
137
|
-
children: "Text",
|
|
138
|
-
},
|
|
139
|
-
|
|
140
146
|
argTypes: {
|
|
141
147
|
children: {
|
|
142
148
|
type: "string",
|
|
@@ -20,7 +20,10 @@ export default {
|
|
|
20
20
|
children: "Text",
|
|
21
21
|
disabled: false,
|
|
22
22
|
size: "small",
|
|
23
|
-
onClick:
|
|
23
|
+
onClick: () => {
|
|
24
|
+
action("onClick")();
|
|
25
|
+
console.log("onClick");
|
|
26
|
+
},
|
|
24
27
|
},
|
|
25
28
|
argTypes: {
|
|
26
29
|
children: {
|
|
@@ -116,57 +119,15 @@ const ButtonTemplate: StoryFn<typeof Button> = ({
|
|
|
116
119
|
}) => {
|
|
117
120
|
return (
|
|
118
121
|
<>
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
>
|
|
129
|
-
Kind
|
|
130
|
-
</TableCell>
|
|
131
|
-
</TableRow>
|
|
132
|
-
<TableRow>
|
|
133
|
-
<TableCell
|
|
134
|
-
sx={{
|
|
135
|
-
width: "33.33333%",
|
|
136
|
-
typography: "body2_14_medium",
|
|
137
|
-
color: "inherit",
|
|
138
|
-
}}
|
|
139
|
-
>
|
|
140
|
-
Contained(default)
|
|
141
|
-
</TableCell>
|
|
142
|
-
<TableCell sx={{ typography: "body2_14_medium", color: "inherit" }}>
|
|
143
|
-
Outlined
|
|
144
|
-
</TableCell>
|
|
145
|
-
<TableCell sx={{ typography: "body2_14_medium", color: "inherit" }}>
|
|
146
|
-
Ghost
|
|
147
|
-
</TableCell>
|
|
148
|
-
</TableRow>
|
|
149
|
-
</TableHead>
|
|
150
|
-
<TableBody>
|
|
151
|
-
<TableRow>
|
|
152
|
-
<TableCell>
|
|
153
|
-
<Button color={color} {...restProps}>
|
|
154
|
-
{children}
|
|
155
|
-
</Button>
|
|
156
|
-
</TableCell>
|
|
157
|
-
<TableCell>
|
|
158
|
-
<Button kind="outlined" color="primary" {...restProps}>
|
|
159
|
-
{children}
|
|
160
|
-
</Button>
|
|
161
|
-
</TableCell>
|
|
162
|
-
<TableCell>
|
|
163
|
-
<Button kind="ghost" color={color} {...restProps}>
|
|
164
|
-
{children}
|
|
165
|
-
</Button>
|
|
166
|
-
</TableCell>
|
|
167
|
-
</TableRow>
|
|
168
|
-
</TableBody>
|
|
169
|
-
</Table>
|
|
122
|
+
<Button color={color} {...restProps} sx={{ mr: 2 }}>
|
|
123
|
+
{children}
|
|
124
|
+
</Button>
|
|
125
|
+
<Button kind="outlined" color="primary" {...restProps} sx={{ mr: 2 }}>
|
|
126
|
+
{children}
|
|
127
|
+
</Button>
|
|
128
|
+
<Button kind="ghost" color={color} {...restProps}>
|
|
129
|
+
{children}
|
|
130
|
+
</Button>
|
|
170
131
|
</>
|
|
171
132
|
);
|
|
172
133
|
};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
Table,
|
|
5
|
-
TableHead,
|
|
6
|
-
TableRow,
|
|
7
|
-
TableBody,
|
|
8
|
-
TableCell,
|
|
9
|
-
} from "@mui/material";
|
|
2
|
+
import { Box, FormControlLabel } from "@mui/material";
|
|
3
|
+
import { action } from "@storybook/addon-actions";
|
|
10
4
|
import Checkbox from "@/components/Checkbox";
|
|
11
5
|
import FormLabel from "@/components/FormLabel";
|
|
12
6
|
import { Meta, StoryFn } from "@storybook/react";
|
|
@@ -14,6 +8,11 @@ import { Meta, StoryFn } from "@storybook/react";
|
|
|
14
8
|
export default {
|
|
15
9
|
title: "Components/Checkbox",
|
|
16
10
|
component: Checkbox,
|
|
11
|
+
args: {
|
|
12
|
+
checked: false,
|
|
13
|
+
disabled: false,
|
|
14
|
+
indeterminate: false,
|
|
15
|
+
},
|
|
17
16
|
argTypes: {
|
|
18
17
|
disabled: {
|
|
19
18
|
control: "boolean",
|
|
@@ -26,6 +25,16 @@ export default {
|
|
|
26
25
|
description: "If true, the component appears indeterminate.",
|
|
27
26
|
},
|
|
28
27
|
onChange: {
|
|
28
|
+
type: "function",
|
|
29
|
+
control: {
|
|
30
|
+
type: "radio",
|
|
31
|
+
},
|
|
32
|
+
options: ["function", undefined],
|
|
33
|
+
mapping: {
|
|
34
|
+
function: action("onChange"),
|
|
35
|
+
undefined: undefined,
|
|
36
|
+
},
|
|
37
|
+
defaultValue: "function",
|
|
29
38
|
table: { type: { summary: "func" } },
|
|
30
39
|
description:
|
|
31
40
|
"Callback fired when the state is changed. Signature: `function(event: React.ChangeEvent<HTMLInputElement>) => void`",
|
|
@@ -42,12 +51,6 @@ export default {
|
|
|
42
51
|
},
|
|
43
52
|
description: "If true, the component is checked.",
|
|
44
53
|
},
|
|
45
|
-
value: {
|
|
46
|
-
control: "text",
|
|
47
|
-
table: { type: { summary: "any" } },
|
|
48
|
-
description:
|
|
49
|
-
"The value of the component. The DOM API casts this to a string.",
|
|
50
|
-
},
|
|
51
54
|
defaultChecked: {
|
|
52
55
|
control: "boolean",
|
|
53
56
|
table: { type: { summary: "bool" }, defaultValue: { summary: "false" } },
|
|
@@ -55,11 +58,6 @@ export default {
|
|
|
55
58
|
"The default checked state. Use when the component is not controlled.",
|
|
56
59
|
},
|
|
57
60
|
},
|
|
58
|
-
args: {
|
|
59
|
-
checked: false,
|
|
60
|
-
disabled: false,
|
|
61
|
-
indeterminate: false,
|
|
62
|
-
},
|
|
63
61
|
parameters: {
|
|
64
62
|
controls: {
|
|
65
63
|
expanded: true,
|
|
@@ -67,7 +65,6 @@ export default {
|
|
|
67
65
|
"disabled",
|
|
68
66
|
"indeterminate",
|
|
69
67
|
"onChange",
|
|
70
|
-
"value",
|
|
71
68
|
"required",
|
|
72
69
|
"checked",
|
|
73
70
|
"defaultChecked",
|
|
@@ -93,7 +90,10 @@ const BasicCheckboxTemplate: StoryFn<typeof Checkbox> = (args) => {
|
|
|
93
90
|
<Checkbox
|
|
94
91
|
{...args}
|
|
95
92
|
checked={checked}
|
|
96
|
-
onChange={() =>
|
|
93
|
+
onChange={(event) => {
|
|
94
|
+
args.onChange && args.onChange(event, checked);
|
|
95
|
+
setChecked((prev) => !prev);
|
|
96
|
+
}}
|
|
97
97
|
/>
|
|
98
98
|
);
|
|
99
99
|
};
|
|
@@ -103,28 +103,49 @@ export const BasicCheckbox = {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
const LabelTemplate: StoryFn<typeof Checkbox> = (args) => {
|
|
106
|
-
const [
|
|
106
|
+
const [checked1, setChecked1] = useState(true);
|
|
107
|
+
const [checked2, setChecked2] = useState(false);
|
|
108
|
+
|
|
107
109
|
useEffect(() => {
|
|
108
|
-
|
|
110
|
+
setChecked1(Boolean(args.checked));
|
|
111
|
+
setChecked2(Boolean(args.checked));
|
|
109
112
|
}, [args.checked]);
|
|
110
113
|
|
|
114
|
+
const handleChange1 = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
115
|
+
args.onChange && args.onChange(event, checked1);
|
|
116
|
+
setChecked1((prev) => !prev);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const handleChange2 = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
120
|
+
args.onChange && args.onChange(event, checked2);
|
|
121
|
+
setChecked2((prev) => !prev);
|
|
122
|
+
};
|
|
123
|
+
|
|
111
124
|
return (
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
125
|
+
<Box sx={{ display: "flex", gap: 4 }}>
|
|
126
|
+
<FormControlLabel
|
|
127
|
+
control={
|
|
128
|
+
<Checkbox {...args} checked={checked1} onChange={handleChange1} />
|
|
129
|
+
}
|
|
130
|
+
label="Label"
|
|
131
|
+
/>
|
|
132
|
+
<FormControlLabel
|
|
133
|
+
control={
|
|
134
|
+
<Checkbox
|
|
135
|
+
{...args}
|
|
136
|
+
disabled
|
|
137
|
+
checked={checked2}
|
|
138
|
+
onChange={handleChange2}
|
|
139
|
+
/>
|
|
140
|
+
}
|
|
141
|
+
label="Disabled Label"
|
|
142
|
+
/>
|
|
143
|
+
</Box>
|
|
122
144
|
);
|
|
123
145
|
};
|
|
124
146
|
|
|
125
147
|
export const Label = {
|
|
126
148
|
render: LabelTemplate,
|
|
127
|
-
|
|
128
149
|
parameters: {
|
|
129
150
|
docs: {
|
|
130
151
|
description: {
|
|
@@ -134,68 +155,9 @@ export const Label = {
|
|
|
134
155
|
},
|
|
135
156
|
};
|
|
136
157
|
|
|
137
|
-
const StatusTemplate: StoryFn<typeof Checkbox> = (args) => (
|
|
138
|
-
<Table sx={{ width: 650 }}>
|
|
139
|
-
<TableHead>
|
|
140
|
-
<TableRow>
|
|
141
|
-
<TableCell></TableCell>
|
|
142
|
-
<TableCell>Enabled</TableCell>
|
|
143
|
-
<TableCell>Focuse</TableCell>
|
|
144
|
-
<TableCell>Disabled</TableCell>
|
|
145
|
-
</TableRow>
|
|
146
|
-
</TableHead>
|
|
147
|
-
<TableBody>
|
|
148
|
-
<TableRow>
|
|
149
|
-
<TableCell>On</TableCell>
|
|
150
|
-
<TableCell>
|
|
151
|
-
<Checkbox {...args} checked />
|
|
152
|
-
</TableCell>
|
|
153
|
-
<TableCell>
|
|
154
|
-
<Checkbox {...args} checked className="Mui-focusVisible" />
|
|
155
|
-
</TableCell>
|
|
156
|
-
<TableCell>
|
|
157
|
-
<Checkbox {...args} checked disabled />
|
|
158
|
-
</TableCell>
|
|
159
|
-
</TableRow>
|
|
160
|
-
<TableRow>
|
|
161
|
-
<TableCell>Off</TableCell>
|
|
162
|
-
<TableCell>
|
|
163
|
-
<Checkbox {...args} />
|
|
164
|
-
</TableCell>
|
|
165
|
-
<TableCell>
|
|
166
|
-
<Checkbox {...args} className="Mui-focusVisible" />
|
|
167
|
-
</TableCell>
|
|
168
|
-
<TableCell>
|
|
169
|
-
<Checkbox {...args} disabled />
|
|
170
|
-
</TableCell>
|
|
171
|
-
</TableRow>
|
|
172
|
-
<TableRow>
|
|
173
|
-
<TableCell>Indeterminate</TableCell>
|
|
174
|
-
<TableCell>
|
|
175
|
-
<Checkbox {...args} checked indeterminate />
|
|
176
|
-
</TableCell>
|
|
177
|
-
<TableCell>
|
|
178
|
-
<Checkbox
|
|
179
|
-
{...args}
|
|
180
|
-
checked
|
|
181
|
-
indeterminate
|
|
182
|
-
className="Mui-focusVisible"
|
|
183
|
-
/>
|
|
184
|
-
</TableCell>
|
|
185
|
-
<TableCell>
|
|
186
|
-
<Checkbox {...args} checked indeterminate disabled />
|
|
187
|
-
</TableCell>
|
|
188
|
-
</TableRow>
|
|
189
|
-
</TableBody>
|
|
190
|
-
</Table>
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
export const Status = {
|
|
194
|
-
render: StatusTemplate,
|
|
195
|
-
};
|
|
196
|
-
|
|
197
158
|
const IndeterminateTemplate: StoryFn<typeof Checkbox> = (args) => {
|
|
198
159
|
const [checked, setChecked] = React.useState([true, false]);
|
|
160
|
+
const { disabled } = args;
|
|
199
161
|
|
|
200
162
|
const handleChange1 = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
201
163
|
setChecked([event.target.checked, event.target.checked]);
|
|
@@ -223,7 +185,7 @@ const IndeterminateTemplate: StoryFn<typeof Checkbox> = (args) => {
|
|
|
223
185
|
);
|
|
224
186
|
|
|
225
187
|
return (
|
|
226
|
-
<
|
|
188
|
+
<Box>
|
|
227
189
|
<FormLabel
|
|
228
190
|
label="Parent"
|
|
229
191
|
control={
|
|
@@ -231,26 +193,43 @@ const IndeterminateTemplate: StoryFn<typeof Checkbox> = (args) => {
|
|
|
231
193
|
checked={checked[0] && checked[1]}
|
|
232
194
|
indeterminate={checked[0] !== checked[1]}
|
|
233
195
|
onChange={handleChange1}
|
|
196
|
+
disabled={disabled}
|
|
234
197
|
/>
|
|
235
198
|
}
|
|
236
199
|
/>
|
|
237
200
|
{children}
|
|
238
|
-
</
|
|
201
|
+
</Box>
|
|
239
202
|
);
|
|
240
203
|
};
|
|
241
204
|
|
|
242
205
|
export const Indeterminate = {
|
|
243
206
|
render: IndeterminateTemplate,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
checked: {
|
|
250
|
-
control: false,
|
|
207
|
+
parameters: {
|
|
208
|
+
docs: {
|
|
209
|
+
description: {
|
|
210
|
+
story: "You can use the `FormControlLabel` component to provide label.",
|
|
211
|
+
},
|
|
251
212
|
},
|
|
252
|
-
|
|
253
|
-
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const DisabledTemplate: StoryFn<typeof Checkbox> = (args) => {
|
|
217
|
+
return (
|
|
218
|
+
<Box sx={{ display: "flex", gap: 4 }}>
|
|
219
|
+
<Checkbox {...args} disabled checked />
|
|
220
|
+
<Checkbox {...args} indeterminate disabled />
|
|
221
|
+
<Checkbox {...args} disabled />
|
|
222
|
+
</Box>
|
|
223
|
+
);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export const Disabled = {
|
|
227
|
+
render: DisabledTemplate,
|
|
228
|
+
parameters: {
|
|
229
|
+
docs: {
|
|
230
|
+
description: {
|
|
231
|
+
story: "You can use the `FormControlLabel` component to provide label.",
|
|
232
|
+
},
|
|
254
233
|
},
|
|
255
234
|
},
|
|
256
235
|
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Canvas, Stories, Controls, Meta, Story } from "@storybook/blocks";
|
|
2
|
+
import Box from "@mui/material/Box";
|
|
3
|
+
import Bell from "@lunit/design-system-icons/Bell";
|
|
4
|
+
|
|
5
|
+
import * as BasicCheckbox from "./BasicCheckbox.stories";
|
|
6
|
+
|
|
7
|
+
<Meta name="Checkbox Docs" of={BasicCheckbox} />
|
|
8
|
+
|
|
9
|
+
# Checkbox
|
|
10
|
+
|
|
11
|
+
Checkboxes allow the user to select one or more items from a set.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Basic Checkbox
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Checkbox } from "@lunit/design-system";
|
|
19
|
+
// or
|
|
20
|
+
import Checkbox from "@lunit/design-system/Checkbox";
|
|
21
|
+
|
|
22
|
+
<Checkbox />;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Demo
|
|
26
|
+
|
|
27
|
+
<Canvas of={BasicCheckbox.BasicCheckbox} sourceState="none" />
|
|
28
|
+
|
|
29
|
+
<Controls />
|
|
30
|
+
|
|
31
|
+
### Label
|
|
32
|
+
|
|
33
|
+
You can provide a label to the Checkbox thanks to the FormControlLabel component.
|
|
34
|
+
|
|
35
|
+
<Canvas of={BasicCheckbox.Label} sourceState="none" />
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
<FormGroup>
|
|
39
|
+
<FormControlLabel control={<Checkbox />} label="Label" />
|
|
40
|
+
<FormControlLabel disabled control={<Checkbox />} label="Disabled Label" />
|
|
41
|
+
</FormGroup>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Indeterminate
|
|
45
|
+
|
|
46
|
+
A Checkbox input can only have two states in a form: checked or unchecked. It either submits its value or doesn't. Visually, there are three states a checkbox can be in: checked, unchecked, or indeterminate.
|
|
47
|
+
|
|
48
|
+
<Canvas of={BasicCheckbox.Indeterminate} sourceState="none" />
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
<FormLabel
|
|
52
|
+
label="Parent"
|
|
53
|
+
control={
|
|
54
|
+
<Checkbox
|
|
55
|
+
checked={checked[0] && checked[1]}
|
|
56
|
+
indeterminate={checked[0] !== checked[1]}
|
|
57
|
+
onChange={handleChange1}
|
|
58
|
+
/>
|
|
59
|
+
}
|
|
60
|
+
/>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Disabled
|
|
64
|
+
|
|
65
|
+
If you want to disable the button, you can use the disabled prop.
|
|
66
|
+
Default disabled is false.
|
|
67
|
+
|
|
68
|
+
<Canvas of={BasicCheckbox.Disabled} sourceState="none" />
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
<Checkbox checked disabed />
|
|
72
|
+
<Checkbox indeterminate disabed />
|
|
73
|
+
<Checkbox disabed />
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Reference
|
|
77
|
+
|
|
78
|
+
- [Material-UI Checkbox](https://mui.com/material-ui/react-checkbox/)
|
|
79
|
+
- [Material-UI Checkbox API](https://mui.com/material-ui/api/checkbox/)
|
|
80
|
+
- [Lunit Design System Button Figma](https://www.figma.com/file/BSdRUpEPp7XiJ9YnEqpf6F/1.0.0_Components?type=design&node-id=1923-6820&mode=design&t=0BjGJV6Ef9WjfuCD-0)
|
|
81
|
+
|
|
82
|
+
## Support
|
|
83
|
+
|
|
84
|
+
- Github: [Create a new issue](https://github.com/lunit-io/design-system/issues/new)
|
|
85
|
+
- Slack: #tf_design_system
|