@lunit/design-system 2.0.2 → 2.2.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/README.md +107 -7
- 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/DataTable/index.js.map +1 -1
- package/dist/cjs/components/DatePicker/index.js.map +1 -1
- package/dist/cjs/components/Dialog/index.js +1 -1
- package/dist/cjs/components/Dialog/index.js.map +1 -1
- package/dist/cjs/components/Dropdown/index.js +1 -1
- package/dist/cjs/components/Dropdown/index.js.map +1 -1
- package/dist/cjs/components/FormLabel/index.js +1 -1
- package/dist/cjs/components/FormLabel/index.js.map +1 -1
- package/dist/cjs/components/Radio/index.js +1 -1
- package/dist/cjs/components/Radio/index.js.map +1 -1
- package/dist/cjs/components/RadioGroup/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/Toggle/index.js +1 -1
- package/dist/cjs/components/Toggle/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/components/Tooltip/index.js.map +1 -1
- package/dist/cjs/components/Typography/index.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/components/Chip/Chip.styled.js +9 -16
- package/dist/components/Chip/Chip.styled.js.map +1 -1
- package/dist/components/Dialog/Dialog.js +0 -6
- package/dist/components/Dialog/Dialog.js.map +1 -1
- package/dist/components/Dropdown/Dropdown.js +37 -4
- package/dist/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/components/Dropdown/Dropdown.styled.js +161 -0
- package/dist/components/Dropdown/Dropdown.styled.js.map +1 -0
- package/dist/components/Dropdown/Dropdown.types.js +2 -0
- package/dist/components/Dropdown/Dropdown.types.js.map +1 -0
- package/dist/components/Dropdown/DropdownItem.js +36 -0
- package/dist/components/Dropdown/DropdownItem.js.map +1 -0
- package/dist/components/Dropdown/index.js +1 -0
- package/dist/components/Dropdown/index.js.map +1 -1
- package/dist/components/TextField/TextField.js +1 -1
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/TextField/TextField.style.js +27 -3
- package/dist/components/TextField/TextField.style.js.map +1 -1
- package/dist/foundation/Typography/index.js +5 -0
- package/dist/foundation/Typography/index.js.map +1 -1
- package/dist/foundation/Typography/tokens.js +44 -0
- package/dist/foundation/Typography/tokens.js.map +1 -1
- package/dist/foundation/colors/base/blue.js +12 -10
- package/dist/foundation/colors/base/blue.js.map +1 -1
- package/dist/foundation/colors/base/green.js +11 -9
- package/dist/foundation/colors/base/green.js.map +1 -1
- package/dist/foundation/colors/base/grey.js +30 -15
- package/dist/foundation/colors/base/grey.js.map +1 -1
- package/dist/foundation/colors/base/lunitTeal.js +2 -0
- package/dist/foundation/colors/base/lunitTeal.js.map +1 -1
- package/dist/foundation/colors/base/magenta.js +3 -1
- package/dist/foundation/colors/base/magenta.js.map +1 -1
- package/dist/foundation/colors/base/orange.js +11 -9
- package/dist/foundation/colors/base/orange.js.map +1 -1
- package/dist/foundation/colors/base/purple.js +3 -1
- package/dist/foundation/colors/base/purple.js.map +1 -1
- package/dist/foundation/colors/base/red.js +5 -3
- package/dist/foundation/colors/base/red.js.map +1 -1
- package/dist/foundation/colors/base/yellow.js +12 -10
- package/dist/foundation/colors/base/yellow.js.map +1 -1
- package/dist/foundation/colors/index.js +3 -0
- package/dist/foundation/colors/index.js.map +1 -1
- package/dist/foundation/colors/token/component.js +26 -22
- package/dist/foundation/colors/token/component.js.map +1 -1
- package/dist/foundation/colors/token/core.js +21 -0
- 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/Button/Button.styled.d.ts +35 -50
- package/dist/types/components/Chip/Chip.styled.d.ts +4 -76
- package/dist/types/components/Chip/Chip.types.d.ts +1 -1
- package/dist/types/components/Dialog/Dialog.d.ts +0 -3
- package/dist/types/components/Dropdown/Dropdown.d.ts +3 -1
- package/dist/types/components/Dropdown/Dropdown.styled.d.ts +7 -0
- package/dist/types/components/Dropdown/Dropdown.types.d.ts +11 -0
- package/dist/types/components/Dropdown/DropdownItem.d.ts +13 -0
- package/dist/types/components/Dropdown/index.d.ts +2 -0
- package/dist/types/components/TextField/TextField.types.d.ts +1 -1
- package/dist/types/components/TextField/TextFieldIcon.d.ts +1 -1
- package/dist/types/components/ToggleButton/ToggleButton.styled.d.ts +1 -32
- package/dist/types/components/Typography/Typography.d.ts +1 -1
- package/dist/types/foundation/Typography/index.d.ts +21 -1
- package/dist/types/foundation/Typography/tokens.d.ts +15 -0
- package/dist/types/foundation/colors/base/blue.d.ts +2 -0
- package/dist/types/foundation/colors/base/green.d.ts +2 -0
- package/dist/types/foundation/colors/base/grey.d.ts +15 -0
- package/dist/types/foundation/colors/base/lunitTeal.d.ts +2 -0
- package/dist/types/foundation/colors/base/magenta.d.ts +2 -0
- package/dist/types/foundation/colors/base/orange.d.ts +2 -0
- package/dist/types/foundation/colors/base/purple.d.ts +2 -0
- package/dist/types/foundation/colors/base/red.d.ts +2 -0
- package/dist/types/foundation/colors/base/yellow.d.ts +2 -0
- package/dist/types/foundation/colors/index.d.ts +3 -0
- package/dist/types/foundation/colors/types.d.ts +3 -0
- package/dist/types/foundation/index.d.ts +3 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +20 -22
- package/src/components/Chip/Chip.styled.ts +9 -16
- package/src/components/Chip/Chip.types.ts +2 -0
- package/src/components/Dialog/Dialog.tsx +0 -8
- package/src/components/Dropdown/Dropdown.styled.tsx +170 -0
- package/src/components/Dropdown/Dropdown.tsx +59 -8
- package/src/components/Dropdown/Dropdown.types.ts +17 -0
- package/src/components/Dropdown/DropdownItem.tsx +107 -0
- package/src/components/Dropdown/index.ts +6 -0
- package/src/components/TextField/TextField.style.ts +28 -3
- package/src/components/TextField/TextField.tsx +1 -7
- package/src/components/TextField/TextField.types.ts +2 -0
- package/src/components/TextField/TextFieldIcon.tsx +1 -1
- package/src/foundation/Typography/index.ts +10 -0
- package/src/foundation/Typography/tokens.ts +45 -0
- package/src/foundation/colors/base/blue.ts +12 -10
- package/src/foundation/colors/base/green.ts +11 -9
- package/src/foundation/colors/base/grey.ts +30 -15
- package/src/foundation/colors/base/lunitTeal.ts +2 -0
- package/src/foundation/colors/base/magenta.ts +3 -1
- package/src/foundation/colors/base/orange.ts +11 -9
- package/src/foundation/colors/base/purple.ts +3 -1
- package/src/foundation/colors/base/red.ts +5 -3
- package/src/foundation/colors/base/yellow.ts +12 -10
- package/src/foundation/colors/index.ts +3 -0
- package/src/foundation/colors/token/component.ts +26 -22
- package/src/foundation/colors/token/core.ts +21 -0
- package/src/foundation/colors/types.ts +3 -0
- package/src/index.ts +6 -1
- package/src/stories/GettingStarted.mdx +10 -16
- package/src/stories/components/Alert/Alert.stories.tsx +3 -3
- package/src/stories/components/Button/BasicButton.stories.tsx +2 -2
- package/src/stories/components/Button/ButtonDocs.mdx +1 -1
- package/src/stories/components/Button/Color.stories.tsx +2 -2
- package/src/stories/components/Button/IconButton.stories.tsx +2 -2
- package/src/stories/components/Button/Kind.stories.tsx +2 -2
- package/src/stories/components/CheckBox/BasicCheckbox.stories.tsx +2 -2
- package/src/stories/components/CheckBox/CheckboxDocs.mdx +1 -1
- package/src/stories/components/Chip/Chip.stories.tsx +20 -2
- package/src/stories/components/Chip/ChipDocs.mdx +21 -1
- package/src/stories/components/DataTable/DataTable.stories.tsx +1 -1
- package/src/stories/components/DatePicker/DatePicker.stories.tsx +1 -1
- package/src/stories/components/Dialog/Dialog.stories.tsx +19 -8
- package/src/stories/components/Dialog/DialogDocs.mdx +3 -11
- package/src/stories/components/Dropdown/Dropdown.stories.tsx +299 -10
- package/src/stories/components/Dropdown/DropdownExamples.stories.tsx +221 -0
- package/src/stories/components/Dropdown/DropdownItem.stories.tsx +360 -0
- package/src/stories/components/SelectControl/RadioGroup.stories.tsx +1 -1
- package/src/stories/components/SelectControl/RadioStatus.stories.tsx +1 -1
- package/src/stories/components/SelectControl/Toggle.stories.tsx +2 -2
- package/src/stories/components/TextField/BasicTextField.stories.tsx +37 -16
- package/src/stories/components/TextField/TextFieldDocs.mdx +13 -1
- package/src/stories/components/TextField/TextFieldMulti.stories.tsx +8 -11
- package/src/stories/components/TextField/TextFieldSingle.stories.tsx +8 -11
- package/src/stories/components/TextField/TextFieldSize.stories.tsx +7 -8
- package/src/stories/components/Toast/Toast.stories.tsx +8 -3
- package/src/stories/components/ToggleButton/Basic.stories.tsx +152 -113
- package/src/stories/components/ToggleButton/ToggleButtonDocs.mdx +1 -1
- package/src/stories/components/ToggleButton/ToggleButtonKind.stories.tsx +5 -5
- package/src/stories/components/ToggleButton/WithIcon.stories.tsx +2 -2
- package/src/stories/components/Tooltip/Tooltip.stories.tsx +1 -1
- package/src/stories/foundation/Elevation/Elevation.stories.tsx +1 -20
- package/src/stories/foundation/Typography/Typography.mdx +1 -1
- package/src/stories/foundation/Typography/Typography.stories.tsx +14 -1
- package/src/stories/foundation/Typography/const.ts +6 -1
- package/src/stories/foundation/colors/Colors.stories.tsx +2 -2
- package/src/stories/foundation/colors/Docs.mdx +1 -1
- package/src/stories/foundation/colors/Mui.stories.tsx +1 -1
- package/src/stories/foundation/colors/Token.inComponent.stories.tsx +1 -1
- package/src/stories/foundation/colors/TokenPaletteTable.stories.tsx +1 -1
- package/src/stories/foundation/colors/TokenPaletteTable.tsx +19 -1
- package/tsconfig.json +0 -1
- package/dist/cjs/components/Modal/index.js +0 -2
- package/dist/cjs/components/Modal/index.js.map +0 -1
- package/dist/components/Modal/Modal.js +0 -7
- package/dist/components/Modal/Modal.js.map +0 -1
- package/dist/components/Modal/index.js +0 -2
- package/dist/components/Modal/index.js.map +0 -1
- package/dist/types/components/Modal/Modal.d.ts +0 -2
- package/dist/types/components/Modal/index.d.ts +0 -1
- package/src/stories/components/ToggleButton/Group.stories.tsx +0 -221
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Canvas, Stories, Controls, Meta, Story } from "@storybook/blocks";
|
|
1
|
+
import { Canvas, Stories, Controls, Meta, Story } from "@storybook/addon-docs/blocks";
|
|
2
2
|
import Box from "@mui/material/Box";
|
|
3
3
|
|
|
4
4
|
import TextField from "@/components/TextField";
|
|
@@ -78,6 +78,18 @@ Default disabled is `false`.
|
|
|
78
78
|
<TextField multiline disabled />
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
+
### ReadOnly
|
|
82
|
+
|
|
83
|
+
The read-only textField can be applied with inputProps's the readOnly property.<br />
|
|
84
|
+
You can save the text value you want to show in defaultValue property.
|
|
85
|
+
|
|
86
|
+
<Canvas of={TextFieldStories.ReadOnly} sourceState="none" />
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
<TextField inputProps={{ readOnly: true }} defaultValue="Conquer Cancer through AI." />
|
|
90
|
+
<TextField multiline inputProps={{ readOnly: true }} defaultValue="Conquer Cancer through AI. We develop AI that detects early-stage cancer and optimizes cancer treatment."/>
|
|
91
|
+
```
|
|
92
|
+
|
|
81
93
|
### Error
|
|
82
94
|
|
|
83
95
|
The error prop toggles the error state.<br />
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import TextField from "@/components/TextField/TextField";
|
|
12
12
|
|
|
13
|
-
import type { StoryFn, Meta } from "@storybook/react";
|
|
13
|
+
import type { StoryFn, Meta } from "@storybook/react-webpack5";
|
|
14
14
|
|
|
15
15
|
export default {
|
|
16
16
|
title: "Components/TextField",
|
|
@@ -24,24 +24,21 @@ export default {
|
|
|
24
24
|
},
|
|
25
25
|
argTypes: {
|
|
26
26
|
disabled: {
|
|
27
|
-
control: {
|
|
28
|
-
type: "radio",
|
|
29
|
-
},
|
|
27
|
+
control: { type: "radio" },
|
|
30
28
|
options: [true, false],
|
|
31
29
|
description: "If true, the text field will be disabled.",
|
|
32
30
|
table: {
|
|
33
|
-
defaultValue: { summary: false },
|
|
34
|
-
type: { summary:
|
|
31
|
+
defaultValue: { summary: "false" },
|
|
32
|
+
type: { summary: "boolean" },
|
|
35
33
|
},
|
|
36
34
|
},
|
|
37
35
|
size: {
|
|
38
|
-
control: {
|
|
39
|
-
|
|
40
|
-
},
|
|
36
|
+
control: { type: "radio" },
|
|
37
|
+
options: ["small", "medium", "large"],
|
|
41
38
|
description: "The size of the text field.",
|
|
42
39
|
table: {
|
|
43
40
|
defaultValue: { summary: "small" },
|
|
44
|
-
type: { summary:
|
|
41
|
+
type: { summary: "string" },
|
|
45
42
|
},
|
|
46
43
|
},
|
|
47
44
|
rows: {
|
|
@@ -50,7 +47,7 @@ export default {
|
|
|
50
47
|
\n the rows default value is undefined.`,
|
|
51
48
|
table: {
|
|
52
49
|
defaultValue: { summary: "undefined" },
|
|
53
|
-
type: { summary:
|
|
50
|
+
type: { summary: "number" },
|
|
54
51
|
},
|
|
55
52
|
},
|
|
56
53
|
placeholder: {
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
TableHead,
|
|
8
8
|
TableRow,
|
|
9
9
|
} from "@mui/material";
|
|
10
|
-
import { action } from "
|
|
10
|
+
import { action } from "storybook/actions";
|
|
11
11
|
import { Bell } from "@lunit/design-system-icons";
|
|
12
12
|
|
|
13
13
|
import TextField from "@/components/TextField/TextField";
|
|
14
14
|
|
|
15
|
-
import type { StoryFn, Meta } from "@storybook/react";
|
|
15
|
+
import type { StoryFn, Meta } from "@storybook/react-webpack5";
|
|
16
16
|
|
|
17
17
|
export default {
|
|
18
18
|
title: "Components/TextField",
|
|
@@ -26,24 +26,21 @@ export default {
|
|
|
26
26
|
},
|
|
27
27
|
argTypes: {
|
|
28
28
|
disabled: {
|
|
29
|
-
control: {
|
|
30
|
-
type: "radio",
|
|
31
|
-
},
|
|
29
|
+
control: { type: "radio" },
|
|
32
30
|
options: [true, false],
|
|
33
31
|
description: "If true, the text field will be disabled.",
|
|
34
32
|
table: {
|
|
35
|
-
defaultValue: { summary: false },
|
|
36
|
-
type: { summary:
|
|
33
|
+
defaultValue: { summary: "false" },
|
|
34
|
+
type: { summary: "boolean" },
|
|
37
35
|
},
|
|
38
36
|
},
|
|
39
37
|
size: {
|
|
40
|
-
control: {
|
|
41
|
-
|
|
42
|
-
},
|
|
38
|
+
control: { type: "radio" },
|
|
39
|
+
options: ["small", "medium", "large"],
|
|
43
40
|
description: "The size of the text field.",
|
|
44
41
|
table: {
|
|
45
42
|
defaultValue: { summary: "small" },
|
|
46
|
-
type: { summary:
|
|
43
|
+
type: { summary: "string" },
|
|
47
44
|
},
|
|
48
45
|
},
|
|
49
46
|
placeholder: {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import TextField from "@/components/TextField/TextField";
|
|
12
12
|
|
|
13
|
-
import type { StoryFn, Meta } from "@storybook/react";
|
|
13
|
+
import type { StoryFn, Meta } from "@storybook/react-webpack5";
|
|
14
14
|
|
|
15
15
|
export default {
|
|
16
16
|
title: "Components/TextField",
|
|
@@ -23,22 +23,21 @@ export default {
|
|
|
23
23
|
},
|
|
24
24
|
argTypes: {
|
|
25
25
|
disabled: {
|
|
26
|
-
control: {
|
|
27
|
-
type: "radio",
|
|
28
|
-
},
|
|
26
|
+
control: { type: "radio" },
|
|
29
27
|
options: [true, false],
|
|
30
28
|
description: "If true, the text field will be disabled.",
|
|
31
29
|
table: {
|
|
32
|
-
defaultValue: { summary: false },
|
|
33
|
-
type: { summary:
|
|
30
|
+
defaultValue: { summary: "false" },
|
|
31
|
+
type: { summary: "boolean" },
|
|
34
32
|
},
|
|
35
33
|
},
|
|
36
34
|
size: {
|
|
37
|
-
control:
|
|
35
|
+
control: { type: "radio" },
|
|
36
|
+
options: ["small", "medium", "large"],
|
|
38
37
|
description: "The size of the text field.",
|
|
39
38
|
table: {
|
|
40
39
|
defaultValue: { summary: "small" },
|
|
41
|
-
type: { summary:
|
|
40
|
+
type: { summary: "string" },
|
|
42
41
|
},
|
|
43
42
|
},
|
|
44
43
|
placeholder: {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { StoryFn, Meta } from "@storybook/react";
|
|
2
|
+
import { StoryFn, Meta } from "@storybook/react-webpack5";
|
|
3
3
|
import { Box } from "@mui/material";
|
|
4
4
|
|
|
5
5
|
import Toast from "@/components/Toast";
|
|
6
|
-
import { action } from "
|
|
6
|
+
import { action } from "storybook/actions";
|
|
7
7
|
import Button from "@/components/Button";
|
|
8
8
|
|
|
9
9
|
export default {
|
|
10
10
|
title: "Components/Toast",
|
|
11
11
|
component: Toast,
|
|
12
|
+
args: {
|
|
13
|
+
onClose: action("onClose"),
|
|
14
|
+
},
|
|
12
15
|
argTypes: {
|
|
13
16
|
severity: {
|
|
14
17
|
control: "radio",
|
|
@@ -30,7 +33,9 @@ export default {
|
|
|
30
33
|
control: {
|
|
31
34
|
type: "select",
|
|
32
35
|
},
|
|
33
|
-
|
|
36
|
+
table: {
|
|
37
|
+
defaultValue: { summary: "function" },
|
|
38
|
+
},
|
|
34
39
|
options: ["function", undefined],
|
|
35
40
|
mapping: {
|
|
36
41
|
function: action("onClose"),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { action } from "
|
|
2
|
+
import { action } from "storybook/actions";
|
|
3
3
|
import {
|
|
4
4
|
Table,
|
|
5
5
|
TableHead,
|
|
@@ -10,9 +10,8 @@ import {
|
|
|
10
10
|
} from "@mui/material";
|
|
11
11
|
import Bell from "@lunit/design-system-icons/Bell";
|
|
12
12
|
import ToggleButton from "@/components/ToggleButton";
|
|
13
|
-
import ToggleButtonGroup from "@/components/ToggleButtonGroup";
|
|
14
13
|
|
|
15
|
-
import type { StoryFn, Meta } from "@storybook/react";
|
|
14
|
+
import type { StoryFn, Meta } from "@storybook/react-webpack5";
|
|
16
15
|
import type { ButtonProps } from "@/components/Button/Button.types";
|
|
17
16
|
|
|
18
17
|
type Size = Pick<ButtonProps, "size">;
|
|
@@ -170,31 +169,17 @@ export const BasicToggleButton = {
|
|
|
170
169
|
};
|
|
171
170
|
|
|
172
171
|
const SizeTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
173
|
-
const [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
large: "",
|
|
177
|
-
});
|
|
172
|
+
const [selectedButtons, setSelectedButtons] = React.useState<{
|
|
173
|
+
[key: string]: boolean;
|
|
174
|
+
}>({});
|
|
178
175
|
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
});
|
|
185
|
-
}
|
|
176
|
+
const handleToggle = (buttonId: string) => {
|
|
177
|
+
setSelectedButtons((prev) => ({
|
|
178
|
+
...prev,
|
|
179
|
+
[buttonId]: !prev[buttonId],
|
|
180
|
+
}));
|
|
186
181
|
};
|
|
187
182
|
|
|
188
|
-
const group = sizeList.map((size) => {
|
|
189
|
-
if (size) {
|
|
190
|
-
return {
|
|
191
|
-
size: size,
|
|
192
|
-
handler: (_: React.MouseEvent<HTMLElement>, value: string | null) =>
|
|
193
|
-
handleChange(value, size),
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
|
|
198
183
|
return (
|
|
199
184
|
<Table sx={{ width: 900 }}>
|
|
200
185
|
<TableHead>
|
|
@@ -223,47 +208,40 @@ const SizeTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
|
223
208
|
</TableHead>
|
|
224
209
|
<TableBody>
|
|
225
210
|
<TableRow>
|
|
226
|
-
{
|
|
227
|
-
if (
|
|
228
|
-
const { size, handler } = item;
|
|
211
|
+
{sizeList.map((size) => {
|
|
212
|
+
if (size) {
|
|
229
213
|
return (
|
|
230
214
|
<TableCell
|
|
231
215
|
key={size}
|
|
232
216
|
sx={{ "& button": { marginRight: "10px" } }}
|
|
233
217
|
>
|
|
234
|
-
<
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
218
|
+
<ToggleButton
|
|
219
|
+
{...args}
|
|
220
|
+
icon={<Bell />}
|
|
221
|
+
size={size}
|
|
222
|
+
value={`${size}-1`}
|
|
223
|
+
selected={selectedButtons[`${size}-1`]}
|
|
224
|
+
onChange={() => handleToggle(`${size}-1`)}
|
|
225
|
+
/>
|
|
226
|
+
<ToggleButton
|
|
227
|
+
{...args}
|
|
228
|
+
size={size}
|
|
229
|
+
value={`${size}-2`}
|
|
230
|
+
selected={selectedButtons[`${size}-2`]}
|
|
231
|
+
onChange={() => handleToggle(`${size}-2`)}
|
|
232
|
+
>
|
|
233
|
+
{args.children}
|
|
234
|
+
</ToggleButton>
|
|
235
|
+
<ToggleButton
|
|
236
|
+
{...args}
|
|
237
|
+
icon={<Bell />}
|
|
238
|
+
size={size}
|
|
239
|
+
value={`${size}-3`}
|
|
240
|
+
selected={selectedButtons[`${size}-3`]}
|
|
241
|
+
onChange={() => handleToggle(`${size}-3`)}
|
|
244
242
|
>
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
icon={<Bell />}
|
|
248
|
-
size={size}
|
|
249
|
-
value={String(size) + 1}
|
|
250
|
-
/>
|
|
251
|
-
<ToggleButton
|
|
252
|
-
{...args}
|
|
253
|
-
size={size}
|
|
254
|
-
value={String(size) + 2}
|
|
255
|
-
>
|
|
256
|
-
{args.children}
|
|
257
|
-
</ToggleButton>
|
|
258
|
-
<ToggleButton
|
|
259
|
-
{...args}
|
|
260
|
-
icon={<Bell />}
|
|
261
|
-
size={size}
|
|
262
|
-
value={String(size) + 3}
|
|
263
|
-
>
|
|
264
|
-
{args.children}
|
|
265
|
-
</ToggleButton>
|
|
266
|
-
</ToggleButtonGroup>
|
|
243
|
+
{args.children}
|
|
244
|
+
</ToggleButton>
|
|
267
245
|
</TableCell>
|
|
268
246
|
);
|
|
269
247
|
}
|
|
@@ -285,19 +263,15 @@ export const Size = {
|
|
|
285
263
|
};
|
|
286
264
|
|
|
287
265
|
const SizeDocsTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
288
|
-
const [
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
large: "",
|
|
292
|
-
});
|
|
293
|
-
|
|
294
|
-
const handleChange = (value: string | null, size: SizeValues) => {
|
|
295
|
-
if (!size) return;
|
|
266
|
+
const [selectedButtons, setSelectedButtons] = React.useState<{
|
|
267
|
+
[key: string]: boolean;
|
|
268
|
+
}>({});
|
|
296
269
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
270
|
+
const handleToggle = (buttonId: string) => {
|
|
271
|
+
setSelectedButtons((prev) => ({
|
|
272
|
+
...prev,
|
|
273
|
+
[buttonId]: !prev[buttonId],
|
|
274
|
+
}));
|
|
301
275
|
};
|
|
302
276
|
|
|
303
277
|
return (
|
|
@@ -311,78 +285,117 @@ const SizeDocsTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
|
311
285
|
},
|
|
312
286
|
}}
|
|
313
287
|
>
|
|
314
|
-
<
|
|
288
|
+
<Box
|
|
315
289
|
sx={{
|
|
316
290
|
display: "flex",
|
|
317
291
|
alignItems: "center",
|
|
318
292
|
}}
|
|
319
|
-
value={values.small}
|
|
320
|
-
onChange={(_, value) => handleChange(value, "small")}
|
|
321
293
|
>
|
|
322
|
-
<ToggleButton
|
|
294
|
+
<ToggleButton
|
|
295
|
+
{...args}
|
|
296
|
+
value="contained-small"
|
|
297
|
+
size="small"
|
|
298
|
+
selected={selectedButtons["contained-small"]}
|
|
299
|
+
onChange={() => handleToggle("contained-small")}
|
|
300
|
+
>
|
|
323
301
|
Small
|
|
324
302
|
</ToggleButton>
|
|
325
|
-
<ToggleButton
|
|
303
|
+
<ToggleButton
|
|
304
|
+
{...args}
|
|
305
|
+
value="contained-medium"
|
|
306
|
+
size="medium"
|
|
307
|
+
selected={selectedButtons["contained-medium"]}
|
|
308
|
+
onChange={() => handleToggle("contained-medium")}
|
|
309
|
+
>
|
|
326
310
|
Medium
|
|
327
311
|
</ToggleButton>
|
|
328
|
-
<ToggleButton
|
|
312
|
+
<ToggleButton
|
|
313
|
+
{...args}
|
|
314
|
+
value="contained-large"
|
|
315
|
+
size="large"
|
|
316
|
+
selected={selectedButtons["contained-large"]}
|
|
317
|
+
onChange={() => handleToggle("contained-large")}
|
|
318
|
+
>
|
|
329
319
|
Large
|
|
330
320
|
</ToggleButton>
|
|
331
|
-
</
|
|
332
|
-
<
|
|
321
|
+
</Box>
|
|
322
|
+
<Box
|
|
333
323
|
sx={{
|
|
334
324
|
display: "flex",
|
|
335
325
|
alignItems: "center",
|
|
336
326
|
}}
|
|
337
|
-
value={values.medium}
|
|
338
|
-
onChange={(_, value) => handleChange(value, "medium")}
|
|
339
327
|
>
|
|
340
328
|
<ToggleButton
|
|
341
329
|
{...args}
|
|
342
|
-
value="small"
|
|
330
|
+
value="outlined-small"
|
|
343
331
|
kind="outlined"
|
|
344
332
|
color="primary"
|
|
345
333
|
size="small"
|
|
334
|
+
selected={selectedButtons["outlined-small"]}
|
|
335
|
+
onChange={() => handleToggle("outlined-small")}
|
|
346
336
|
>
|
|
347
337
|
Small
|
|
348
338
|
</ToggleButton>
|
|
349
339
|
<ToggleButton
|
|
350
340
|
{...args}
|
|
351
|
-
value="medium"
|
|
341
|
+
value="outlined-medium"
|
|
352
342
|
kind="outlined"
|
|
353
343
|
color="primary"
|
|
354
344
|
size="medium"
|
|
345
|
+
selected={selectedButtons["outlined-medium"]}
|
|
346
|
+
onChange={() => handleToggle("outlined-medium")}
|
|
355
347
|
>
|
|
356
348
|
Medium
|
|
357
349
|
</ToggleButton>
|
|
358
350
|
<ToggleButton
|
|
359
351
|
{...args}
|
|
360
|
-
value="large"
|
|
352
|
+
value="outlined-large"
|
|
361
353
|
kind="outlined"
|
|
362
354
|
color="primary"
|
|
363
355
|
size="large"
|
|
356
|
+
selected={selectedButtons["outlined-large"]}
|
|
357
|
+
onChange={() => handleToggle("outlined-large")}
|
|
364
358
|
>
|
|
365
359
|
Large
|
|
366
360
|
</ToggleButton>
|
|
367
|
-
</
|
|
368
|
-
<
|
|
361
|
+
</Box>
|
|
362
|
+
<Box
|
|
369
363
|
sx={{
|
|
370
364
|
display: "flex",
|
|
371
365
|
alignItems: "center",
|
|
372
366
|
}}
|
|
373
|
-
value={values.large}
|
|
374
|
-
onChange={(_, value) => handleChange(value, "large")}
|
|
375
367
|
>
|
|
376
|
-
<ToggleButton
|
|
368
|
+
<ToggleButton
|
|
369
|
+
{...args}
|
|
370
|
+
value="ghost-small"
|
|
371
|
+
kind="ghost"
|
|
372
|
+
size="small"
|
|
373
|
+
selected={selectedButtons["ghost-small"]}
|
|
374
|
+
onChange={() => handleToggle("ghost-small")}
|
|
375
|
+
>
|
|
377
376
|
Small
|
|
378
377
|
</ToggleButton>
|
|
379
|
-
<ToggleButton
|
|
378
|
+
<ToggleButton
|
|
379
|
+
{...args}
|
|
380
|
+
value="ghost-medium"
|
|
381
|
+
kind="ghost"
|
|
382
|
+
size="medium"
|
|
383
|
+
selected={selectedButtons["ghost-medium"]}
|
|
384
|
+
onChange={() => handleToggle("ghost-medium")}
|
|
385
|
+
>
|
|
380
386
|
Medium
|
|
381
387
|
</ToggleButton>
|
|
382
|
-
<ToggleButton
|
|
388
|
+
<ToggleButton
|
|
389
|
+
{...args}
|
|
390
|
+
value="ghost-large"
|
|
391
|
+
kind="ghost"
|
|
392
|
+
size="large"
|
|
393
|
+
selected={selectedButtons["ghost-large"]}
|
|
394
|
+
onChange={() => handleToggle("ghost-large")}
|
|
395
|
+
>
|
|
383
396
|
Large
|
|
384
397
|
</ToggleButton>
|
|
385
|
-
</
|
|
398
|
+
</Box>
|
|
386
399
|
</Box>
|
|
387
400
|
);
|
|
388
401
|
};
|
|
@@ -400,71 +413,97 @@ export const SizeDocs = {
|
|
|
400
413
|
};
|
|
401
414
|
|
|
402
415
|
const ColorTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
403
|
-
const [
|
|
404
|
-
|
|
405
|
-
|
|
416
|
+
const [selectedButtons, setSelectedButtons] = React.useState<{
|
|
417
|
+
[key: string]: boolean;
|
|
418
|
+
}>({});
|
|
419
|
+
|
|
420
|
+
const handleToggle = (buttonId: string) => {
|
|
421
|
+
setSelectedButtons((prev) => ({
|
|
422
|
+
...prev,
|
|
423
|
+
[buttonId]: !prev[buttonId],
|
|
424
|
+
}));
|
|
425
|
+
};
|
|
406
426
|
|
|
407
427
|
return (
|
|
408
428
|
<Box sx={{ display: "flex", flexDirection: "column" }}>
|
|
409
|
-
<
|
|
429
|
+
<Box
|
|
410
430
|
sx={{
|
|
411
431
|
"& button": {
|
|
412
432
|
marginRight: 2,
|
|
413
433
|
},
|
|
414
434
|
}}
|
|
415
|
-
value={contained}
|
|
416
|
-
onChange={(_, value) => setContained(value)}
|
|
417
435
|
>
|
|
418
|
-
<ToggleButton
|
|
436
|
+
<ToggleButton
|
|
437
|
+
{...args}
|
|
438
|
+
value="contained-primary"
|
|
439
|
+
kind="contained"
|
|
440
|
+
color="primary"
|
|
441
|
+
selected={selectedButtons["contained-primary"]}
|
|
442
|
+
onChange={() => handleToggle("contained-primary")}
|
|
443
|
+
>
|
|
419
444
|
Primary
|
|
420
445
|
</ToggleButton>
|
|
421
446
|
<ToggleButton
|
|
422
447
|
{...args}
|
|
423
|
-
value="
|
|
448
|
+
value="contained-secondary"
|
|
424
449
|
kind="contained"
|
|
425
450
|
color="secondary"
|
|
426
451
|
selectedColor="secondary"
|
|
452
|
+
selected={selectedButtons["contained-secondary"]}
|
|
453
|
+
onChange={() => handleToggle("contained-secondary")}
|
|
427
454
|
>
|
|
428
455
|
Secondary
|
|
429
456
|
</ToggleButton>
|
|
430
|
-
</
|
|
431
|
-
<
|
|
457
|
+
</Box>
|
|
458
|
+
<Box
|
|
432
459
|
sx={{
|
|
433
460
|
marginTop: 4,
|
|
434
461
|
"& button": {
|
|
435
462
|
marginRight: 2,
|
|
436
463
|
},
|
|
437
464
|
}}
|
|
438
|
-
value={outlined}
|
|
439
|
-
onChange={(_, value) => setOutlined(value)}
|
|
440
465
|
>
|
|
441
|
-
<ToggleButton
|
|
466
|
+
<ToggleButton
|
|
467
|
+
{...args}
|
|
468
|
+
value="outlined-primary"
|
|
469
|
+
kind="outlined"
|
|
470
|
+
color="primary"
|
|
471
|
+
selected={selectedButtons["outlined-primary"]}
|
|
472
|
+
onChange={() => handleToggle("outlined-primary")}
|
|
473
|
+
>
|
|
442
474
|
Primary
|
|
443
475
|
</ToggleButton>
|
|
444
|
-
</
|
|
445
|
-
<
|
|
476
|
+
</Box>
|
|
477
|
+
<Box
|
|
446
478
|
sx={{
|
|
447
479
|
marginTop: 4,
|
|
448
480
|
"& button": {
|
|
449
481
|
marginRight: 2,
|
|
450
482
|
},
|
|
451
483
|
}}
|
|
452
|
-
value={ghost}
|
|
453
|
-
onChange={(_, value) => setGhost(value)}
|
|
454
484
|
>
|
|
455
|
-
<ToggleButton
|
|
485
|
+
<ToggleButton
|
|
486
|
+
{...args}
|
|
487
|
+
value="ghost-primary"
|
|
488
|
+
kind="ghost"
|
|
489
|
+
color="primary"
|
|
490
|
+
selected={selectedButtons["ghost-primary"]}
|
|
491
|
+
onChange={() => handleToggle("ghost-primary")}
|
|
492
|
+
>
|
|
456
493
|
Primary
|
|
457
494
|
</ToggleButton>
|
|
458
495
|
<ToggleButton
|
|
459
496
|
{...args}
|
|
460
|
-
value="
|
|
497
|
+
value="ghost-secondary"
|
|
461
498
|
kind="ghost"
|
|
462
499
|
color="secondary"
|
|
463
500
|
selectedColor="secondary"
|
|
501
|
+
selected={selectedButtons["ghost-secondary"]}
|
|
502
|
+
onChange={() => handleToggle("ghost-secondary")}
|
|
464
503
|
>
|
|
465
504
|
Secondary
|
|
466
505
|
</ToggleButton>
|
|
467
|
-
</
|
|
506
|
+
</Box>
|
|
468
507
|
</Box>
|
|
469
508
|
);
|
|
470
509
|
};
|
|
@@ -7,11 +7,11 @@ import {
|
|
|
7
7
|
TableBody,
|
|
8
8
|
TableCell,
|
|
9
9
|
} from "@mui/material";
|
|
10
|
-
import { action } from "
|
|
10
|
+
import { action } from "storybook/actions";
|
|
11
11
|
|
|
12
12
|
import ToggleButton from "@/components/ToggleButton";
|
|
13
13
|
|
|
14
|
-
import type { StoryFn, Meta } from "@storybook/react";
|
|
14
|
+
import type { StoryFn, Meta } from "@storybook/react-webpack5";
|
|
15
15
|
|
|
16
16
|
export default {
|
|
17
17
|
title: "Components/ToggleButton",
|
|
@@ -317,7 +317,7 @@ const ContainedTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
|
317
317
|
|
|
318
318
|
const handleChange = (
|
|
319
319
|
color: keyof typeof values,
|
|
320
|
-
value: keyof (typeof values)[keyof typeof values]
|
|
320
|
+
value: keyof (typeof values)[keyof typeof values],
|
|
321
321
|
) => {
|
|
322
322
|
setValues({
|
|
323
323
|
...values,
|
|
@@ -483,7 +483,7 @@ const GhostTemplate: StoryFn<typeof ToggleButton> = (args) => {
|
|
|
483
483
|
|
|
484
484
|
const handleChange = (
|
|
485
485
|
color: keyof typeof values,
|
|
486
|
-
value: keyof (typeof values)[keyof typeof values]
|
|
486
|
+
value: keyof (typeof values)[keyof typeof values],
|
|
487
487
|
) => {
|
|
488
488
|
setValues({
|
|
489
489
|
...values,
|
|
@@ -659,7 +659,7 @@ const OutlinedTemplate: StoryFn<typeof ToggleButton> = ({
|
|
|
659
659
|
|
|
660
660
|
const handleChange = (
|
|
661
661
|
color: keyof typeof values,
|
|
662
|
-
value: keyof (typeof values)[keyof typeof values]
|
|
662
|
+
value: keyof (typeof values)[keyof typeof values],
|
|
663
663
|
) => {
|
|
664
664
|
setValues({
|
|
665
665
|
...values,
|
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
TableCell,
|
|
8
8
|
Box,
|
|
9
9
|
} from "@mui/material";
|
|
10
|
-
import { action } from "
|
|
10
|
+
import { action } from "storybook/actions";
|
|
11
11
|
import Bell from "@lunit/design-system-icons/Bell";
|
|
12
12
|
|
|
13
13
|
import ToggleButton from "@/components/ToggleButton";
|
|
14
14
|
|
|
15
|
-
import type { StoryFn, Meta } from "@storybook/react";
|
|
15
|
+
import type { StoryFn, Meta } from "@storybook/react-webpack5";
|
|
16
16
|
|
|
17
17
|
export default {
|
|
18
18
|
title: "Components/ToggleButton",
|