@lunit/design-system 1.0.0-b.4 → 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/Chip/index.js +1 -1
- package/dist/cjs/components/Chip/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/TextField/index.js +1 -1
- package/dist/cjs/components/TextField/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.js +21 -3
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.styled.js +3 -6
- 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/Chip/Chip.js +6 -5
- package/dist/components/Chip/Chip.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/TextField/TextField.js +4 -4
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/ToggleButton/ToggleButton.styled.js +2 -3
- 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 +12 -0
- package/dist/foundation/Typography/index.js.map +1 -1
- package/dist/foundation/Typography/tokens.js +1 -17
- package/dist/foundation/Typography/tokens.js.map +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 +9 -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/foundation/index.js +1 -1
- package/dist/foundation/index.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 -12
- package/dist/types/components/Button/Button.types.d.ts +8 -5
- package/dist/types/components/Chip/Chip.styled.d.ts +12 -12
- package/dist/types/components/Chip/Chip.types.d.ts +7 -2
- 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/TextField/TextField.types.d.ts +8 -3
- 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 +13 -1
- 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 +9 -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 +9 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/Button/Button.styled.ts +3 -6
- package/src/components/Button/Button.tsx +117 -42
- package/src/components/Button/Button.types.ts +8 -4
- package/src/components/Checkbox/Checkbox.tsx +39 -22
- package/src/components/Chip/Chip.tsx +15 -4
- package/src/components/Chip/Chip.types.ts +9 -2
- 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/TextField/TextField.tsx +10 -10
- package/src/components/TextField/TextField.types.ts +11 -4
- package/src/components/ToggleButton/ToggleButton.styled.ts +2 -3
- package/src/foundation/Elevation/index.ts +1 -1
- package/src/foundation/Typography/index.ts +12 -0
- package/src/foundation/Typography/tokens.ts +1 -17
- package/src/foundation/colors/base/grey.ts +3 -1
- package/src/foundation/colors/index.ts +9 -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/foundation/index.ts +1 -1
- package/src/index.ts +1 -1
- package/src/stories/GettingStarted.mdx +88 -0
- package/src/stories/components/Button/BasicButton.stories.tsx +91 -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 +42 -25
- package/src/stories/components/Button/Kind.stories.tsx +75 -77
- 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 +80 -5
- 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
|
@@ -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
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Meta } from "@storybook/react";
|
|
3
3
|
import { action } from "@storybook/addon-actions";
|
|
4
|
+
import { Box } from "@mui/system";
|
|
5
|
+
|
|
4
6
|
import Chip from "@/components/Chip";
|
|
5
7
|
import {
|
|
6
8
|
Logo16,
|
|
@@ -17,6 +19,17 @@ export default {
|
|
|
17
19
|
argTypes: {
|
|
18
20
|
kind: {
|
|
19
21
|
description: `Default status of Contained or Outlined Chip is readOnly. You can pass onClick, onDelete or thumbnail to Contained Chip only.`,
|
|
22
|
+
control: {
|
|
23
|
+
type: "select",
|
|
24
|
+
},
|
|
25
|
+
options: ["contained", "outlined"],
|
|
26
|
+
},
|
|
27
|
+
variant: {
|
|
28
|
+
description: `The variant is alias of kind. It is Filled or Outlined.`,
|
|
29
|
+
control: {
|
|
30
|
+
type: "select",
|
|
31
|
+
},
|
|
32
|
+
options: [undefined, "filled", "outlined"],
|
|
20
33
|
},
|
|
21
34
|
onClick: {
|
|
22
35
|
description: `Contained chip can have onClick event. When Chip is clickable, onDelete is disabled.`,
|
|
@@ -80,6 +93,7 @@ export default {
|
|
|
80
93
|
},
|
|
81
94
|
args: {
|
|
82
95
|
kind: "contained",
|
|
96
|
+
variant: "filled",
|
|
83
97
|
label: "label@lunit.io",
|
|
84
98
|
},
|
|
85
99
|
parameters: {
|
|
@@ -94,6 +108,8 @@ export default {
|
|
|
94
108
|
},
|
|
95
109
|
} as Meta<typeof Chip>;
|
|
96
110
|
|
|
111
|
+
export const Basic = {};
|
|
112
|
+
|
|
97
113
|
export const Outlined = {
|
|
98
114
|
parameters: {
|
|
99
115
|
docs: {
|
|
@@ -116,9 +132,10 @@ export const Outlined = {
|
|
|
116
132
|
args: {
|
|
117
133
|
color: "primary",
|
|
118
134
|
kind: "outlined",
|
|
135
|
+
variant: "outlined",
|
|
119
136
|
},
|
|
120
137
|
|
|
121
|
-
name: "Kind: Outlined",
|
|
138
|
+
name: "Kind(Variant): Outlined",
|
|
122
139
|
};
|
|
123
140
|
|
|
124
141
|
export const Contained = {
|
|
@@ -138,9 +155,45 @@ export const Contained = {
|
|
|
138
155
|
args: {
|
|
139
156
|
color: "primary",
|
|
140
157
|
kind: "contained",
|
|
158
|
+
variant: "filled",
|
|
141
159
|
},
|
|
142
160
|
|
|
143
|
-
name: "Kind: Contained / Read Only",
|
|
161
|
+
name: "Kind(Variant): Contained / Read Only",
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const Kind = {
|
|
165
|
+
chromatic: { disableSnapshot: true },
|
|
166
|
+
render: () => (
|
|
167
|
+
<Box sx={{ display: "flex", flexDirection: "row", gap: 4 }}>
|
|
168
|
+
<Chip kind="outlined" label="label@lunit.io" />
|
|
169
|
+
<Chip kind="contained" label="label@lunit.io" />
|
|
170
|
+
</Box>
|
|
171
|
+
),
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const Color = {
|
|
175
|
+
chromatic: { disableSnapshot: true },
|
|
176
|
+
render: () => (
|
|
177
|
+
<Box sx={{ display: "flex", flexDirection: "row", gap: 4 }}>
|
|
178
|
+
<Chip color="primary" label="label@lunit.io" />
|
|
179
|
+
<Chip color="secondary" label="label@lunit.io" />
|
|
180
|
+
<Chip color="warning" label="label@lunit.io" />
|
|
181
|
+
<Chip color="error" label="label@lunit.io" />
|
|
182
|
+
<Chip color="success" label="label@lunit.io" />
|
|
183
|
+
</Box>
|
|
184
|
+
),
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const Thumbnail = {
|
|
188
|
+
chromatic: { disableSnapshot: true },
|
|
189
|
+
render: () => (
|
|
190
|
+
<Box sx={{ display: "flex", flexDirection: "row", gap: 4 }}>
|
|
191
|
+
<Chip thumbnail={<Logo16 />} label="label@lunit.io" />
|
|
192
|
+
<Chip thumbnail={<Avatar16 />} label="label@lunit.io" />
|
|
193
|
+
<Chip thumbnail={<Success16 />} label="label@lunit.io" />
|
|
194
|
+
<Chip thumbnail="W as initial" label="label@lunit.io" />
|
|
195
|
+
</Box>
|
|
196
|
+
),
|
|
144
197
|
};
|
|
145
198
|
|
|
146
199
|
export const ContainedWithClick = {
|
|
@@ -161,7 +214,7 @@ export const ContainedWithClick = {
|
|
|
161
214
|
},
|
|
162
215
|
},
|
|
163
216
|
|
|
164
|
-
name: "Kind: Contained / Enable",
|
|
217
|
+
name: "Kind(Variant): Contained / Enable",
|
|
165
218
|
};
|
|
166
219
|
|
|
167
220
|
export const ContainedWithDelete = {
|
|
@@ -182,7 +235,7 @@ export const ContainedWithDelete = {
|
|
|
182
235
|
},
|
|
183
236
|
},
|
|
184
237
|
|
|
185
|
-
name: "Kind: Contained / Deletable",
|
|
238
|
+
name: "Kind(Variant): Contained / Deletable",
|
|
186
239
|
};
|
|
187
240
|
|
|
188
241
|
export const ContainedWithThumbnail = {
|
|
@@ -204,5 +257,27 @@ export const ContainedWithThumbnail = {
|
|
|
204
257
|
},
|
|
205
258
|
},
|
|
206
259
|
|
|
207
|
-
name: "Kind: Contained with Thumbnail",
|
|
260
|
+
name: "Kind(Variant): Contained with Thumbnail",
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
export const ContainedWithDeleteAndThumbnail = {
|
|
264
|
+
args: {
|
|
265
|
+
...Contained.args,
|
|
266
|
+
thumbnail: "Initial",
|
|
267
|
+
onClick: undefined,
|
|
268
|
+
onDelete: action("onDelete"),
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
parameters: {
|
|
272
|
+
docs: {
|
|
273
|
+
description: {
|
|
274
|
+
story: `Contained chip can have thumbnail and delete button.`,
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
controls: {
|
|
278
|
+
exclude: ["onClick"],
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
|
|
282
|
+
name: "Kind(Variant): Contained with Thumbnail and Deletable",
|
|
208
283
|
};
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { Canvas, Stories, Controls, Meta, Story } from "@storybook/blocks";
|
|
2
|
+
import { Error } from "@lunit/design-system-icons";
|
|
3
|
+
|
|
4
|
+
import Chip from "@/components/Chip";
|
|
5
|
+
import * as ChipStories from "./Chip.stories";
|
|
6
|
+
|
|
7
|
+
<Meta name="Chip Docs" of={ChipStories} />
|
|
8
|
+
|
|
9
|
+
# Chip
|
|
10
|
+
|
|
11
|
+
Chips are compact elements that represent an input, attribute, or action.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Basic Chip
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Chip } from "@lunit/design-system";
|
|
19
|
+
// or
|
|
20
|
+
import Chip from "@lunit/design-system/Chip";
|
|
21
|
+
|
|
22
|
+
<Chip />;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Demo
|
|
26
|
+
|
|
27
|
+
<Canvas of={ChipStories.Basic} />
|
|
28
|
+
|
|
29
|
+
<Controls />
|
|
30
|
+
|
|
31
|
+
### Label
|
|
32
|
+
|
|
33
|
+
The label is the text that will be displayed in the Chip.
|
|
34
|
+
If the label is not provided, the Chip will be rendered as a circle.
|
|
35
|
+
|
|
36
|
+
<Canvas of={ChipStories.Contained} meta={ChipStories.Contained.meta} />
|
|
37
|
+
```tsx
|
|
38
|
+
<Chip label="label@lunit.io" />
|
|
39
|
+
````
|
|
40
|
+
|
|
41
|
+
### Kind(variant)
|
|
42
|
+
|
|
43
|
+
The Chip has 2 kinds of variants: outlined and contained. <br />
|
|
44
|
+
(In the Lunit Design System, the variant and kind are used interchangeably. The variant is a fallback prop of the kind.) <br />
|
|
45
|
+
You can change the kind of the Chip by using the kind or variant prop, and the outcome will be the same.
|
|
46
|
+
The `contained` kind corresponds to the `filled` and `contained` variants of the MUI system. <br />
|
|
47
|
+
The default kind(variant) is contained. <br />
|
|
48
|
+
|
|
49
|
+
<Canvas of={ChipStories.Kind} meta={ChipStories.Contained.meta} />
|
|
50
|
+
```tsx
|
|
51
|
+
<Chip variant="contained" label="label@lunit.io" />
|
|
52
|
+
<Chip variant="outlined" label="label@lunit.io" />
|
|
53
|
+
// or (kind is a fallback prop of the variant)
|
|
54
|
+
<Chip kind="contained" label="label@lunit.io" />
|
|
55
|
+
<Chip kind="outlined" label="label@lunit.io" />
|
|
56
|
+
````
|
|
57
|
+
|
|
58
|
+
### Color
|
|
59
|
+
|
|
60
|
+
The Chip has 5 kinds of colors: `primary`, `secondary`, `warning`, `error`, and `success`. <br />
|
|
61
|
+
By using the color prop, you can change the color of the Chip. <br />
|
|
62
|
+
The default color is `primary`.
|
|
63
|
+
|
|
64
|
+
<Canvas of={ChipStories.Color} meta={ChipStories.Contained.meta} />
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
<Chip color="primary" label="label@lunit.io" />
|
|
68
|
+
<Chip color="secondary" label="label@lunit.io" />
|
|
69
|
+
<Chip color="warning" label="label@lunit.io" />
|
|
70
|
+
<Chip color="error" label="label@lunit.io" />
|
|
71
|
+
<Chip color="success" label="label@lunit.io" />
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Clickable
|
|
75
|
+
|
|
76
|
+
Chips with the `onClick` are clickable. <br />
|
|
77
|
+
You cannot pass the `onClick` prop to the Chip when its variant is `outlined`. <br />
|
|
78
|
+
|
|
79
|
+
<Canvas of={ChipStories.ContainedWithClick} />
|
|
80
|
+
```tsx
|
|
81
|
+
<Chip label="label@lunit.io" onClick={() => console.log("onClick")} />
|
|
82
|
+
|
|
83
|
+
````
|
|
84
|
+
|
|
85
|
+
### Deletable
|
|
86
|
+
|
|
87
|
+
Chips with the `onDelete` are deletable. <br />
|
|
88
|
+
You cannot pass the `onDelete` prop to the Chip when its variant is `outlined`. <br />
|
|
89
|
+
The hover/pressed effects are only applied to the delete icon. <br />
|
|
90
|
+
|
|
91
|
+
<Canvas of={ChipStories.ContainedWithDelete} />
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
<Chip label="label@lunit.io" onDelete={() => console.log("onDelete")} />
|
|
95
|
+
|
|
96
|
+
````
|
|
97
|
+
|
|
98
|
+
### Thumbnail(logo, avatar, icon, first letter)
|
|
99
|
+
|
|
100
|
+
Chips with the thumbnail prop can display a logo, avatar, icon, or the first letter of a string.<br />
|
|
101
|
+
The thumbnail replaces all the left side icons of MUI, so you cannot use the icon or avatar prop of the MUI system. <br />
|
|
102
|
+
The thumbnail prop cannot be used when the kind (variant) is outlined.
|
|
103
|
+
|
|
104
|
+
<Canvas of={ChipStories.Thumbnail} />
|
|
105
|
+
```tsx
|
|
106
|
+
<Chip thumbnail={<Logo16 />} label="label@lunit.io" />
|
|
107
|
+
<Chip thumbnail={<Avatar16 />} label="label@lunit.io" />
|
|
108
|
+
<Chip thumbnail={<Success16 />} label="label@lunit.io" />
|
|
109
|
+
<Chip thumbnail="W as initial" label="label@lunit.io" />
|
|
110
|
+
|
|
111
|
+
````
|
|
112
|
+
|
|
113
|
+
### Thumbnail and Deletable
|
|
114
|
+
|
|
115
|
+
The Chip can have a thumbnail and be deletable. <br />
|
|
116
|
+
The hover/pressed effects are only applied to the delete icon. <br />
|
|
117
|
+
|
|
118
|
+
<Canvas of={ChipStories.ContainedWithDeleteAndThumbnail} />
|
|
119
|
+
```tsx
|
|
120
|
+
<Chip label="label@lunit.io" onDelete={() => console.log("onDelete")} thumbnail="W as initial" />
|
|
121
|
+
````
|
|
122
|
+
|
|
123
|
+
## Reference
|
|
124
|
+
|
|
125
|
+
- [Material-UI Chip](https://mui.com/material-ui/react-chip/)
|
|
126
|
+
- [Material-UI Chip API](https://mui.com/material-ui/api/chip/)
|
|
127
|
+
- [Lunit Design System Chip Figma](https://www.figma.com/file/oh2WsSLBuX30Yp589gyliB/Design-System_1.0.7_Latest?type=design&node-id=1887-7970&mode=design)
|
|
128
|
+
|
|
129
|
+
## Support
|
|
130
|
+
|
|
131
|
+
- Github: [Create a new issue](https://github.com/lunit-io/design-system/issues/new)
|
|
132
|
+
- Slack: #tf_design_system
|