@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,81 +1,84 @@
|
|
|
1
|
-
type CSSPropertyColor = React.CSSProperties["color"];
|
|
2
|
-
|
|
3
1
|
export interface ColorToken {
|
|
4
2
|
core: {
|
|
5
|
-
bg_01:
|
|
6
|
-
bg_02:
|
|
7
|
-
bg_03:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
3
|
+
bg_01: string;
|
|
4
|
+
bg_02: string;
|
|
5
|
+
bg_03: string;
|
|
6
|
+
layer_01: string;
|
|
7
|
+
text_primary: string;
|
|
8
|
+
text_normal: string;
|
|
9
|
+
text_medium: string;
|
|
10
|
+
text_light: string;
|
|
11
|
+
text_error: string;
|
|
12
|
+
text_success: string;
|
|
13
|
+
text_warning: string;
|
|
14
|
+
text_info: string;
|
|
15
|
+
link_primary: string;
|
|
16
|
+
link_hover: string;
|
|
17
|
+
link_visited: string;
|
|
18
|
+
icon_error_02: string;
|
|
19
|
+
icon_success_02: string;
|
|
20
|
+
icon_warning_02: string;
|
|
21
|
+
icon_info_02: string;
|
|
22
|
+
hover: string;
|
|
23
|
+
focused: string;
|
|
24
|
+
selected: string;
|
|
25
|
+
shadow_01: string;
|
|
26
|
+
shadow_02: string;
|
|
27
|
+
shadow_03: string;
|
|
28
|
+
shadow_04: string;
|
|
29
|
+
border_light: string;
|
|
30
|
+
border_medium: string;
|
|
30
31
|
};
|
|
31
32
|
component: {
|
|
32
|
-
btn_primary_bg:
|
|
33
|
-
btn_secondary_bg:
|
|
34
|
-
btn_error_bg:
|
|
35
|
-
btn_primary_border:
|
|
36
|
-
btn_secondary_border:
|
|
37
|
-
btn_primary_text_1:
|
|
38
|
-
btn_primary_text_2:
|
|
39
|
-
btn_secondary_text:
|
|
40
|
-
btn_error_text:
|
|
41
|
-
btn_selected_primary_bg:
|
|
42
|
-
btn_selected_primary_text:
|
|
43
|
-
btn_selected_secondary_bg:
|
|
44
|
-
btn_selected_secondary_text:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
33
|
+
btn_primary_bg: string;
|
|
34
|
+
btn_secondary_bg: string;
|
|
35
|
+
btn_error_bg: string;
|
|
36
|
+
btn_primary_border: string;
|
|
37
|
+
btn_secondary_border: string;
|
|
38
|
+
btn_primary_text_1: string;
|
|
39
|
+
btn_primary_text_2: string;
|
|
40
|
+
btn_secondary_text: string;
|
|
41
|
+
btn_error_text: string;
|
|
42
|
+
btn_selected_primary_bg: string;
|
|
43
|
+
btn_selected_primary_text: string;
|
|
44
|
+
btn_selected_secondary_bg: string;
|
|
45
|
+
btn_selected_secondary_text: string;
|
|
46
|
+
btn_selected_tertiary_bg: string;
|
|
47
|
+
btn_selected_tertiary_text: string;
|
|
48
|
+
selectcontrol_on: string;
|
|
49
|
+
selectcontrol_off: string;
|
|
50
|
+
selectcontrol_handler: string;
|
|
51
|
+
selectcontrol_handler_shadow: string;
|
|
52
|
+
textfield_bg: string;
|
|
53
|
+
textfield_border_error: string;
|
|
54
|
+
dropdown_divider_border: string;
|
|
55
|
+
datatable_border_01: string;
|
|
56
|
+
datatable_border_02: string;
|
|
57
|
+
datatable_zebra: string;
|
|
58
|
+
scrollbars_bg: string;
|
|
59
|
+
scrollbars_hover: string;
|
|
60
|
+
scrollbars_pressed: string;
|
|
61
|
+
modal_overlay: string;
|
|
62
|
+
tooltip_bg: string;
|
|
63
|
+
tooltip_text_normal: string;
|
|
64
|
+
tooltip_text_medium: string;
|
|
65
|
+
alert_error_bg: string;
|
|
66
|
+
alert_error_border: string;
|
|
67
|
+
alert_success_bg: string;
|
|
68
|
+
alert_success_border: string;
|
|
69
|
+
alert_info_bg: string;
|
|
70
|
+
alert_info_border: string;
|
|
71
|
+
alert_warning_bg: string;
|
|
72
|
+
alert_warning_border: string;
|
|
73
|
+
chip_primary_bg: string;
|
|
74
|
+
chip_primary_text: string;
|
|
75
|
+
chip_secondary_bg: string;
|
|
76
|
+
chip_secondary_text: string;
|
|
77
|
+
chip_error_bg: string;
|
|
78
|
+
chip_error_text: string;
|
|
79
|
+
chip_warning_bg: string;
|
|
80
|
+
chip_warning_text: string;
|
|
81
|
+
chip_success_bg: string;
|
|
82
|
+
chip_success_text: string;
|
|
80
83
|
};
|
|
81
84
|
}
|
package/src/foundation/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { createElevationCssBaseline, elevationOptions } from "./Elevation";
|
|
|
9
9
|
|
|
10
10
|
export const foundationCssBaseline: Components<Theme>["MuiCssBaseline"] = {
|
|
11
11
|
styleOverrides: deepmerge(
|
|
12
|
-
deepmerge(
|
|
12
|
+
deepmerge(createColorCssBaseline(), createTypographyCssBaseline()),
|
|
13
13
|
createElevationCssBaseline()
|
|
14
14
|
),
|
|
15
15
|
};
|
package/src/index.ts
CHANGED
|
@@ -5,11 +5,11 @@ export { default as Alert } from "./components/Alert";
|
|
|
5
5
|
export { default as Button } from "./components/Button";
|
|
6
6
|
export { default as Chip } from "./components/Chip";
|
|
7
7
|
export { default as Checkbox } from "./components/Checkbox";
|
|
8
|
+
export { default as Dialog } from "./components/Dialog";
|
|
8
9
|
export { default as DataTable } from "./components/DataTable";
|
|
9
10
|
export { default as DatePicker } from "./components/DatePicker";
|
|
10
11
|
export { default as Dropdown } from "./components/Dropdown";
|
|
11
12
|
export { default as FormLabel } from "./components/FormLabel";
|
|
12
|
-
export { default as Modal } from "./components/Modal";
|
|
13
13
|
export { default as Radio } from "./components/Radio";
|
|
14
14
|
export { default as RadioGroup } from "./components/RadioGroup";
|
|
15
15
|
export { default as TextField } from "./components/TextField";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { Meta } from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Getting Started/Overview" />
|
|
4
|
+
|
|
5
|
+
# Lunit Design System Library
|
|
6
|
+
|
|
7
|
+
Lunit Design System Library is a collection of reusable components and styles that are used to build Lunit's products. It is built on top of [Material UI](https://mui.com/material-ui/getting-started/), a popular React UI framework.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @lunit/design-system
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Material UI is peer dependency of Lunit Design System Library. You need to install Material UI first.
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"@mui/material": "^5.0.0",
|
|
20
|
+
"@types/react": "^17.0.0 || ^18.0.0",
|
|
21
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
22
|
+
"react-dom": "^17.0.0 || ^18.0.0"
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
### Theme
|
|
29
|
+
|
|
30
|
+
This library is based on Material UI's themes feature, so it imports themes and puts them into the provider. We also recommend using the `CssBaseline` component.
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import {
|
|
34
|
+
createTheme,
|
|
35
|
+
ThemeProvider,
|
|
36
|
+
} from '@mui/material/styles';
|
|
37
|
+
import CssBaseline from '@mui/material/CssBaseline';
|
|
38
|
+
import { themeOptions } from '@lunit/design-system';
|
|
39
|
+
|
|
40
|
+
const theme = createTheme(themeOptions);
|
|
41
|
+
|
|
42
|
+
const App = () => {
|
|
43
|
+
return (
|
|
44
|
+
<ThemeProvider theme={theme}>
|
|
45
|
+
<CssBaseline />
|
|
46
|
+
<YourApp />
|
|
47
|
+
</ThemeProvider>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you want to customize the theme, use the `deepmerge` utility.
|
|
53
|
+
|
|
54
|
+
[https://mui.com/material-ui/customization/theming/#createtheme-options-args-theme](https://mui.com/material-ui/customization/theming/#createtheme-options-args-theme)
|
|
55
|
+
|
|
56
|
+
### Fonts
|
|
57
|
+
|
|
58
|
+
This library uses the `Pretendard` font-family by default. The [Pretendard font](https://github.com/orioncactus/pretendard) does not come with this library, so you will need to provide it yourself via Webfonts. You can change the font by setting the `fontFamily` property in the theme.
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
const theme = createTheme(
|
|
62
|
+
deepmerge(themeOptions, {
|
|
63
|
+
typography: {
|
|
64
|
+
fontFamily: [
|
|
65
|
+
'Pretendard Variable',
|
|
66
|
+
'sans-serif',
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Foundation
|
|
74
|
+
|
|
75
|
+
This library provides a set of foundational styles that are used in Lunit's products. Please refer Colors, Typography, and Elevation in the sidebar.
|
|
76
|
+
|
|
77
|
+
## Components
|
|
78
|
+
|
|
79
|
+
This library provides a variety of components that are used in Lunit's products. Please refer Components in the sidebar.
|
|
80
|
+
|
|
81
|
+
## Reference
|
|
82
|
+
|
|
83
|
+
- [Lunit Design System Figma](https://www.figma.com/file/oh2WsSLBuX30Yp589gyliB/Design-System_1.0.7_Latest?node-id=0%3A1&mode=dev)
|
|
84
|
+
|
|
85
|
+
## Support
|
|
86
|
+
|
|
87
|
+
- Github: [Create a new issue](https://github.com/lunit-io/design-system/issues/new)
|
|
88
|
+
- Slack: #tf_design_system
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { action } from "@storybook/addon-actions";
|
|
3
|
-
import {
|
|
4
|
-
Table,
|
|
5
|
-
TableHead,
|
|
6
|
-
TableRow,
|
|
7
|
-
TableBody,
|
|
8
|
-
TableCell,
|
|
9
|
-
} from "@mui/material";
|
|
10
|
-
import Bell from "@lunit/design-system-icons/Bell";
|
|
3
|
+
import { Box } from "@mui/material";
|
|
11
4
|
|
|
12
5
|
import Button from "@/components/Button";
|
|
13
6
|
|
|
14
7
|
import type { StoryObj, StoryFn, Meta } from "@storybook/react";
|
|
15
8
|
|
|
16
|
-
type SizeValues = "small" | "medium" | "large";
|
|
17
|
-
const sizeList: SizeValues[] = ["small", "medium", "large"];
|
|
18
|
-
|
|
19
9
|
export default {
|
|
20
10
|
title: "Components/Button",
|
|
21
11
|
component: Button,
|
|
@@ -38,6 +28,7 @@ export default {
|
|
|
38
28
|
},
|
|
39
29
|
},
|
|
40
30
|
children: {
|
|
31
|
+
description: "The content of the component.",
|
|
41
32
|
type: "string",
|
|
42
33
|
},
|
|
43
34
|
kind: {
|
|
@@ -50,10 +41,22 @@ export default {
|
|
|
50
41
|
defaultValue: { summary: "contained" },
|
|
51
42
|
},
|
|
52
43
|
},
|
|
44
|
+
variant: {
|
|
45
|
+
control: {
|
|
46
|
+
type: "radio",
|
|
47
|
+
},
|
|
48
|
+
options: ["contained", "outlined", "text", "ghost"],
|
|
49
|
+
description: "The variant is alias of kind.",
|
|
50
|
+
table: {
|
|
51
|
+
defaultValue: { summary: "contained" },
|
|
52
|
+
},
|
|
53
|
+
},
|
|
53
54
|
color: {
|
|
54
55
|
control: {
|
|
55
56
|
type: "radio",
|
|
56
57
|
},
|
|
58
|
+
description: `The color of the component. It supports both default and custom theme colors,
|
|
59
|
+
\nwhich can be added as shown in the palette customization guide.`,
|
|
57
60
|
options: ["primary", "secondary", "error"],
|
|
58
61
|
table: {
|
|
59
62
|
defaultValue: { summary: "primary" },
|
|
@@ -63,6 +66,7 @@ export default {
|
|
|
63
66
|
control: {
|
|
64
67
|
type: "boolean",
|
|
65
68
|
},
|
|
69
|
+
description: "If true, the button will be disabled.",
|
|
66
70
|
table: {
|
|
67
71
|
defaultValue: { summary: "false" },
|
|
68
72
|
},
|
|
@@ -71,6 +75,7 @@ export default {
|
|
|
71
75
|
control: {
|
|
72
76
|
type: "radio",
|
|
73
77
|
},
|
|
78
|
+
description: "The size of the button.",
|
|
74
79
|
options: ["small", "medium", "large"],
|
|
75
80
|
table: {
|
|
76
81
|
defaultValue: { summary: "small" },
|
|
@@ -98,6 +103,7 @@ export default {
|
|
|
98
103
|
"disabled",
|
|
99
104
|
"size",
|
|
100
105
|
"kind",
|
|
106
|
+
"variant",
|
|
101
107
|
"color",
|
|
102
108
|
"icon",
|
|
103
109
|
],
|
|
@@ -115,52 +121,85 @@ export const BasicButton: StoryObj<typeof Button> = {
|
|
|
115
121
|
render: (args) => <Button {...args}>{args.children}</Button>,
|
|
116
122
|
};
|
|
117
123
|
|
|
124
|
+
const DisabledButtonTemplate: StoryFn<typeof Button> = (args) => {
|
|
125
|
+
const { children, kind, variant, ...restArgs } = args;
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<Box sx={{ display: "flex", gap: 2 }}>
|
|
129
|
+
<Button {...restArgs} disabled kind="contained">
|
|
130
|
+
{children}
|
|
131
|
+
</Button>
|
|
132
|
+
<Button
|
|
133
|
+
{...restArgs}
|
|
134
|
+
disabled
|
|
135
|
+
color={args.color === "error" ? "primary" : args.color}
|
|
136
|
+
kind="outlined"
|
|
137
|
+
>
|
|
138
|
+
{children}
|
|
139
|
+
</Button>
|
|
140
|
+
<Button {...restArgs} disabled kind="ghost">
|
|
141
|
+
{children}
|
|
142
|
+
</Button>
|
|
143
|
+
</Box>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export const Disabled: StoryObj<typeof Button> = {
|
|
148
|
+
render: DisabledButtonTemplate,
|
|
149
|
+
parameters: {
|
|
150
|
+
controls: {
|
|
151
|
+
include: ["onClick", "children", "size", "color"],
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
118
156
|
const SizeButtonTemplate: StoryFn<typeof Button> = (args) => {
|
|
157
|
+
const { children, kind, variant, color, ...restArgs } = args;
|
|
158
|
+
|
|
119
159
|
return (
|
|
120
|
-
<
|
|
121
|
-
<
|
|
122
|
-
<
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
</Button>
|
|
156
|
-
</TableCell>
|
|
157
|
-
))}
|
|
158
|
-
</TableRow>
|
|
159
|
-
</TableBody>
|
|
160
|
-
</Table>
|
|
160
|
+
<Box sx={{ display: "flex", flexDirection: "column", gap: 4 }}>
|
|
161
|
+
<Box>
|
|
162
|
+
<Button sx={{ mr: 2 }} {...restArgs} variant="contained" size="small">
|
|
163
|
+
Small
|
|
164
|
+
</Button>
|
|
165
|
+
<Button sx={{ mr: 2 }} {...restArgs} variant="contained" size="medium">
|
|
166
|
+
Medium
|
|
167
|
+
</Button>
|
|
168
|
+
<Button {...restArgs} variant="contained" size="large">
|
|
169
|
+
Large
|
|
170
|
+
</Button>
|
|
171
|
+
</Box>
|
|
172
|
+
<Box>
|
|
173
|
+
<Button sx={{ mr: 2 }} {...restArgs} variant="outlined" size="small">
|
|
174
|
+
Small
|
|
175
|
+
</Button>
|
|
176
|
+
<Button sx={{ mr: 2 }} {...restArgs} variant="outlined" size="medium">
|
|
177
|
+
Medium
|
|
178
|
+
</Button>
|
|
179
|
+
<Button {...restArgs} variant="outlined" size="large">
|
|
180
|
+
Large
|
|
181
|
+
</Button>
|
|
182
|
+
</Box>
|
|
183
|
+
<Box>
|
|
184
|
+
<Button sx={{ mr: 2 }} {...restArgs} variant="text" size="small">
|
|
185
|
+
Small
|
|
186
|
+
</Button>
|
|
187
|
+
<Button sx={{ mr: 2 }} {...restArgs} variant="text" size="medium">
|
|
188
|
+
Medium
|
|
189
|
+
</Button>
|
|
190
|
+
<Button {...restArgs} variant="text" size="large">
|
|
191
|
+
Large
|
|
192
|
+
</Button>
|
|
193
|
+
</Box>
|
|
194
|
+
</Box>
|
|
161
195
|
);
|
|
162
196
|
};
|
|
163
197
|
|
|
164
198
|
export const Size = {
|
|
165
199
|
render: SizeButtonTemplate,
|
|
200
|
+
parameters: {
|
|
201
|
+
controls: {
|
|
202
|
+
include: ["onClick", "disabled", "icon"],
|
|
203
|
+
},
|
|
204
|
+
},
|
|
166
205
|
};
|
|
@@ -0,0 +1,187 @@
|
|
|
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 Button from "@/components/Button";
|
|
6
|
+
import * as ButtonStories from "./BasicButton.stories";
|
|
7
|
+
import * as ButtonKindStories from "./Kind.stories";
|
|
8
|
+
import * as ButtonColorStories from "./Color.stories";
|
|
9
|
+
import * as ButtonIconStories from "./IconButton.stories";
|
|
10
|
+
|
|
11
|
+
<Meta name="Button Docs" of={ButtonStories} />
|
|
12
|
+
|
|
13
|
+
# Button
|
|
14
|
+
|
|
15
|
+
Buttons allow users to take actions, and make choices, with a single tap.
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
### Basic Button
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { Button } from "@lunit/design-system";
|
|
23
|
+
// or
|
|
24
|
+
import Button from "@lunit/design-system/Button";
|
|
25
|
+
|
|
26
|
+
<Button>Button</Button>;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Demo
|
|
30
|
+
|
|
31
|
+
<Canvas of={ButtonStories.BasicButton} sourceState="none" />
|
|
32
|
+
|
|
33
|
+
<Controls />
|
|
34
|
+
|
|
35
|
+
### Variant (kind)
|
|
36
|
+
|
|
37
|
+
The Button have three variants: `contained`, `outlined`, and `ghost`.<br />
|
|
38
|
+
In our design system Figma, we use `variant` and `kind` together, They are the **same concept**, and they work the **same way**.<br />
|
|
39
|
+
Using the `variant` or `kind` prop, you can change the variant of the Button.<br />
|
|
40
|
+
Default variant(kind) is `contained`.
|
|
41
|
+
|
|
42
|
+
<Canvas
|
|
43
|
+
of={ButtonKindStories.Kind}
|
|
44
|
+
meta={ButtonKindStories}
|
|
45
|
+
sourceState="none"
|
|
46
|
+
/>
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
<Button variant="contained">Text</Button>
|
|
50
|
+
<Button variant="outlined">Text</Button>
|
|
51
|
+
<Button variant="ghost">Text</Button>
|
|
52
|
+
|
|
53
|
+
// or (kind is the same as variant)
|
|
54
|
+
|
|
55
|
+
<Button kind="contained">Text</Button>
|
|
56
|
+
<Button kind="outlined">Text</Button>
|
|
57
|
+
<Button kind="ghost">Text</Button>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Color
|
|
61
|
+
|
|
62
|
+
The Button have three colors: `primary`, `secondary` and `error`.<br />
|
|
63
|
+
Using the `color` prop, you can change the color of the Button.<br />
|
|
64
|
+
Outline vairant does not have error color state.<br />
|
|
65
|
+
Default color is `primary`.
|
|
66
|
+
|
|
67
|
+
<Canvas
|
|
68
|
+
of={ButtonColorStories.Color}
|
|
69
|
+
meta={ButtonColorStories}
|
|
70
|
+
sourceState="none"
|
|
71
|
+
/>
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
// Contained
|
|
75
|
+
<Button variant="contained" color="primary">Text</Button>
|
|
76
|
+
<Button variant="contained" color="secondary">Text</Button>
|
|
77
|
+
<Button variant="contained" color="error">Text</Button>
|
|
78
|
+
|
|
79
|
+
// Outlined
|
|
80
|
+
<Button variant="outlined" color="primary">Text</Button>
|
|
81
|
+
<Button variant="outlined" color="secondary">Text</Button>
|
|
82
|
+
|
|
83
|
+
// Ghost
|
|
84
|
+
<Button variant="ghost" color="primary">Text</Button>
|
|
85
|
+
<Button variant="ghost" color="secondary">Text</Button>
|
|
86
|
+
<Button variant="ghost" color="error">Text</Button>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Size
|
|
90
|
+
|
|
91
|
+
The Button have three sizes: `small`, `medium` and `large`.<br />
|
|
92
|
+
Using the `size` prop, you can change the size of the Button.<br />
|
|
93
|
+
Default size is `small`.
|
|
94
|
+
|
|
95
|
+
<Canvas of={ButtonStories.Size} sourceState="none" />
|
|
96
|
+
|
|
97
|
+
```tsx
|
|
98
|
+
// Contained
|
|
99
|
+
<Button variant="contained" size="small">Small</Button>
|
|
100
|
+
<Button variant="contained" size="medium">Medium</Button>
|
|
101
|
+
<Button variant="contained" size="large">Large</Button>
|
|
102
|
+
|
|
103
|
+
// Outlined
|
|
104
|
+
<Button variant="outlined" size="small">Small</Button>
|
|
105
|
+
<Button variant="outlined" size="medium">Medium</Button>
|
|
106
|
+
<Button variant="outlined" size="large">Large</Button>
|
|
107
|
+
|
|
108
|
+
// Ghost
|
|
109
|
+
<Button variant="ghost" size="small">Small</Button>
|
|
110
|
+
<Button variant="ghost" size="medium">Medium</Button>
|
|
111
|
+
<Button variant="ghost" size="large">Large</Button>
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### With Icon and Text
|
|
116
|
+
|
|
117
|
+
If you want to use an icon and text together, you can use the `icon` prop and `children` prop.
|
|
118
|
+
|
|
119
|
+
<Canvas
|
|
120
|
+
of={ButtonIconStories.IconWithTextButton}
|
|
121
|
+
meta={ButtonIconStories}
|
|
122
|
+
sourceState="none"
|
|
123
|
+
/>
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
<Button variant="contained" icon={<Bell />}>Contained</Button>
|
|
127
|
+
<Button variant="outlined" icon={<Bell />}>Outlined</Button>
|
|
128
|
+
<Button variant="ghost" icon={<Bell />}>Ghost</Button>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### With Icon only
|
|
132
|
+
|
|
133
|
+
If you want to use only an icon, you can use the `icon` prop.
|
|
134
|
+
|
|
135
|
+
<Canvas
|
|
136
|
+
of={ButtonIconStories.IconOnlyButton}
|
|
137
|
+
meta={ButtonIconStories}
|
|
138
|
+
sourceState="none"
|
|
139
|
+
/>
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
<Button variant="contained" icon={<Bell />} />
|
|
143
|
+
<Button variant="outlined" icon={<Bell />} />
|
|
144
|
+
<Button variant="ghost" icon={<Bell />} />
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Disabled
|
|
148
|
+
|
|
149
|
+
If you want to disable the button, you can use the `disabled` prop.<br />
|
|
150
|
+
Default disabled is `false`.
|
|
151
|
+
|
|
152
|
+
<Canvas
|
|
153
|
+
of={ButtonStories.Disabled}
|
|
154
|
+
meta={ButtonIconStories}
|
|
155
|
+
sourceState="none"
|
|
156
|
+
/>
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<Button variant="contained" disabled>Text</Button>
|
|
160
|
+
<Button variant="outlined" disabled>Text</Button>
|
|
161
|
+
<Button variant="ghost" disabled>Text</Button>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### OnClick
|
|
165
|
+
|
|
166
|
+
If you want to add an event to the button, you can use the `onClick` prop.
|
|
167
|
+
|
|
168
|
+
<Canvas
|
|
169
|
+
of={ButtonKindStories.Kind}
|
|
170
|
+
meta={ButtonKindStories}
|
|
171
|
+
sourceState="none"
|
|
172
|
+
/>
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
<Button onClick={() => console.log("onClick")}>Text</Button>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Reference
|
|
179
|
+
|
|
180
|
+
- [Material-UI Button](https://mui.com/material-ui/react-button/)
|
|
181
|
+
- [Material-UI Button API](https://mui.com/api/button/)
|
|
182
|
+
- [Lunit Design System Button Figma](https://www.figma.com/file/BSdRUpEPp7XiJ9YnEqpf6F/1.0.0_Components?type=design&node-id=284-3&mode=design&t=dM6Vnv02YvTzQ8vH-0)
|
|
183
|
+
|
|
184
|
+
## Support
|
|
185
|
+
|
|
186
|
+
- Github: [Create a new issue](https://github.com/lunit-io/design-system/issues/new)
|
|
187
|
+
- Slack: #tf_design_system
|