@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,5 +1,5 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import { StoryFn, Meta } from "@storybook/react";
|
|
2
|
+
import { StoryFn, Meta } from "@storybook/react-webpack5";
|
|
3
3
|
import {
|
|
4
4
|
Alert,
|
|
5
5
|
Box,
|
|
@@ -13,8 +13,6 @@ import {
|
|
|
13
13
|
TextField,
|
|
14
14
|
Tooltip,
|
|
15
15
|
} from "@mui/material";
|
|
16
|
-
import { DatePicker, LocalizationProvider } from "@mui/x-date-pickers";
|
|
17
|
-
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
|
18
16
|
import { Dayjs } from "dayjs";
|
|
19
17
|
import { Container, Title } from "./styled";
|
|
20
18
|
|
|
@@ -96,23 +94,6 @@ const Elevation = ({ surface, isBase = false }: ElevationProps) => {
|
|
|
96
94
|
</Select>
|
|
97
95
|
</Container>
|
|
98
96
|
|
|
99
|
-
<Title>Date Picker</Title>
|
|
100
|
-
<Container>
|
|
101
|
-
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
|
102
|
-
<DatePicker
|
|
103
|
-
label="Basic example"
|
|
104
|
-
value={value}
|
|
105
|
-
onChange={(newValue) => {
|
|
106
|
-
setValue(newValue);
|
|
107
|
-
}}
|
|
108
|
-
renderInput={(params) => <TextField {...params} />}
|
|
109
|
-
PaperProps={{
|
|
110
|
-
className: surface,
|
|
111
|
-
}}
|
|
112
|
-
/>
|
|
113
|
-
</LocalizationProvider>
|
|
114
|
-
</Container>
|
|
115
|
-
|
|
116
97
|
<Title>Alert</Title>
|
|
117
98
|
<Container>
|
|
118
99
|
<Alert sx={{ flex: 1 }}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import { StoryFn } from "@storybook/react";
|
|
3
|
+
import { StoryFn } from "@storybook/react-webpack5";
|
|
4
4
|
import { Box } from "@mui/material";
|
|
5
5
|
import { styled } from "@mui/material/styles";
|
|
6
6
|
|
|
@@ -29,6 +29,19 @@ export const AllVariants = () => (
|
|
|
29
29
|
}
|
|
30
30
|
variants={variants.body}
|
|
31
31
|
/>
|
|
32
|
+
<TypographyGroup
|
|
33
|
+
heading="Small Body Variation"
|
|
34
|
+
dummy={
|
|
35
|
+
<>
|
|
36
|
+
AI will be the new standard of care. 123456789
|
|
37
|
+
<br />
|
|
38
|
+
By Lunit. With AI, we aim to make data-driven medicine
|
|
39
|
+
<br />
|
|
40
|
+
the new standard of care.
|
|
41
|
+
</>
|
|
42
|
+
}
|
|
43
|
+
variants={variants.smallBody}
|
|
44
|
+
/>
|
|
32
45
|
<TypographyGroup
|
|
33
46
|
heading="etc"
|
|
34
47
|
dummy="NEWS & UPDATE 71456"
|
|
@@ -13,13 +13,18 @@ const body = [
|
|
|
13
13
|
"body2_14_regular",
|
|
14
14
|
"body3_12_semibold",
|
|
15
15
|
"body3_12_regular",
|
|
16
|
+
"body_m2",
|
|
17
|
+
"body_reg6",
|
|
18
|
+
"body_reg8",
|
|
16
19
|
] as const;
|
|
20
|
+
const smallBody = ["small_body_sb1", "small_body_m2"] as const;
|
|
17
21
|
const etc = ["button1", "button2", "caption", "overline"] as const;
|
|
18
22
|
|
|
19
23
|
export const variants = {
|
|
20
24
|
headline,
|
|
21
25
|
body,
|
|
26
|
+
smallBody,
|
|
22
27
|
etc,
|
|
23
28
|
};
|
|
24
29
|
|
|
25
|
-
export const variantArray = [...headline, ...body, ...etc];
|
|
30
|
+
export const variantArray = [...headline, ...body, ...smallBody, ...etc];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { StoryFn, Meta } from "@storybook/react";
|
|
2
|
+
import { StoryFn, Meta } from "@storybook/react-webpack5";
|
|
3
3
|
import { Typography, useTheme } from "@mui/material";
|
|
4
4
|
import { Color, ColorContainer, Container, PaletteContainer } from "./styled";
|
|
5
5
|
import map from "lodash/map";
|
|
@@ -44,7 +44,7 @@ const BaseColors = () => {
|
|
|
44
44
|
))}
|
|
45
45
|
</PaletteContainer>
|
|
46
46
|
</div>
|
|
47
|
-
)
|
|
47
|
+
),
|
|
48
48
|
)}
|
|
49
49
|
</Container>
|
|
50
50
|
);
|
|
@@ -78,6 +78,16 @@ const TokenPaletteTable = ({ kind }: TokenPaletteTableProps) => {
|
|
|
78
78
|
);
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
const deprecatedTokenList = [
|
|
82
|
+
"btn_secondary_border",
|
|
83
|
+
"btn_selected_secondary_bg",
|
|
84
|
+
"datatable_border_01",
|
|
85
|
+
"datatable_border_02",
|
|
86
|
+
"hover",
|
|
87
|
+
"focused",
|
|
88
|
+
"selected",
|
|
89
|
+
];
|
|
90
|
+
|
|
81
91
|
return (
|
|
82
92
|
<TableContainer>
|
|
83
93
|
<Table stickyHeader>
|
|
@@ -100,7 +110,15 @@ const TokenPaletteTable = ({ kind }: TokenPaletteTableProps) => {
|
|
|
100
110
|
<TableRow key={paletteKey}>
|
|
101
111
|
<TableCell sx={{ height: "72px" }}>
|
|
102
112
|
<StyledTypography>
|
|
103
|
-
{kind}.{paletteKey}
|
|
113
|
+
{kind}.{paletteKey}{" "}
|
|
114
|
+
{deprecatedTokenList.includes(paletteKey) && (
|
|
115
|
+
<Box
|
|
116
|
+
component="span"
|
|
117
|
+
sx={{ color: "red", fontWeight: "bold" }}
|
|
118
|
+
>
|
|
119
|
+
(Deprecated)
|
|
120
|
+
</Box>
|
|
121
|
+
)}
|
|
104
122
|
</StyledTypography>
|
|
105
123
|
</TableCell>
|
|
106
124
|
<TokenPaletteCell
|
package/tsconfig.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(()=>{"use strict";var e={d:(r,t)=>{for(var o in t)e.o(t,o)&&!e.o(r,o)&&Object.defineProperty(r,o,{enumerable:!0,get:t[o]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{default:()=>l});const t=require("react/jsx-runtime"),o=require("@mui/material"),l=()=>(0,t.jsx)(o.Box,{children:"Modal"});module.exports=r})();
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"components/Modal/index.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAwB,CAACC,EAASC,KACjC,IAAI,IAAIC,KAAOD,EACXF,EAAoBI,EAAEF,EAAYC,KAASH,EAAoBI,EAAEH,EAASE,IAC5EE,OAAOC,eAAeL,EAASE,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDH,EAAwB,CAACS,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFV,EAAyBC,IACH,oBAAXa,QAA0BA,OAAOC,aAC1CV,OAAOC,eAAeL,EAASa,OAAOC,YAAa,CAAEC,MAAO,WAE7DX,OAAOC,eAAeL,EAAS,aAAc,CAAEe,OAAO,GAAO,G,mCCL9D,MAAM,EAA+BC,QAAQ,qBCAvC,EAA+BA,QAAQ,iBCO7C,EAJc,KACL,SAAC,EAAAC,IAAG,oB","sources":["webpack://@lunit/design-system/webpack/bootstrap","webpack://@lunit/design-system/webpack/runtime/define property getters","webpack://@lunit/design-system/webpack/runtime/hasOwnProperty shorthand","webpack://@lunit/design-system/webpack/runtime/make namespace object","webpack://@lunit/design-system/external commonjs \"react/jsx-runtime\"","webpack://@lunit/design-system/external commonjs \"@mui/material\"","webpack://@lunit/design-system/./src/components/Modal/Modal.tsx"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"react/jsx-runtime\");","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"@mui/material\");","import React from \"react\";\nimport { Box } from \"@mui/material\";\n\nconst Modal = () => {\n return <Box>Modal</Box>;\n};\n\nexport default Modal;\n"],"names":["__webpack_require__","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","Box"],"sourceRoot":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../../src/components/Modal/Modal.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,MAAM,KAAK,GAAG,GAAG,EAAE;IACjB,OAAO,KAAC,GAAG,wBAAY,CAAC;AAC1B,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/Modal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./Modal";
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { action } from "@storybook/addon-actions";
|
|
3
|
-
|
|
4
|
-
import ToggleButton from "@/components/ToggleButton";
|
|
5
|
-
import ToggleButtonGroup from "@/components/ToggleButtonGroup";
|
|
6
|
-
|
|
7
|
-
import type { StoryFn, Meta } from "@storybook/react";
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
title: "Components/ToggleButton",
|
|
11
|
-
component: ToggleButton,
|
|
12
|
-
args: {
|
|
13
|
-
children: "Text",
|
|
14
|
-
kind: "contained",
|
|
15
|
-
color: "primary",
|
|
16
|
-
selectedColor: "primary",
|
|
17
|
-
size: "small",
|
|
18
|
-
disabled: false,
|
|
19
|
-
},
|
|
20
|
-
argTypes: {
|
|
21
|
-
icon: {
|
|
22
|
-
control: false,
|
|
23
|
-
description: `Use this prop when you want to add icon.
|
|
24
|
-
\n It is added to the left of the text criteria`,
|
|
25
|
-
table: {
|
|
26
|
-
defaultValue: { summary: "undefined" },
|
|
27
|
-
type: { summary: "React.ReactNode" },
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
value: {
|
|
31
|
-
control: false,
|
|
32
|
-
table: { type: { summary: "any" } },
|
|
33
|
-
},
|
|
34
|
-
selected: {
|
|
35
|
-
control: false,
|
|
36
|
-
table: {
|
|
37
|
-
defaultValue: { summary: "false" },
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
selectedColor: {
|
|
41
|
-
control: {
|
|
42
|
-
type: "radio",
|
|
43
|
-
},
|
|
44
|
-
options: ["primary", "secondary"],
|
|
45
|
-
description:
|
|
46
|
-
"The color of the button when it is in an select state. It has nothing to do with active button",
|
|
47
|
-
table: {
|
|
48
|
-
defaultValue: { summary: "primary" },
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
color: {
|
|
52
|
-
control: {
|
|
53
|
-
type: "radio",
|
|
54
|
-
},
|
|
55
|
-
options: ["primary", "secondary"],
|
|
56
|
-
description: "Button has three Kinds Contained, Ghost",
|
|
57
|
-
table: {
|
|
58
|
-
defaultValue: { summary: "primary" },
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
kind: {
|
|
62
|
-
control: {
|
|
63
|
-
type: "radio",
|
|
64
|
-
},
|
|
65
|
-
options: ["contained", "outlined", "ghost"],
|
|
66
|
-
table: {
|
|
67
|
-
defaultValue: { summary: "contained" },
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
children: {
|
|
71
|
-
type: "string",
|
|
72
|
-
},
|
|
73
|
-
disabled: {
|
|
74
|
-
control: {
|
|
75
|
-
type: "boolean",
|
|
76
|
-
},
|
|
77
|
-
table: {
|
|
78
|
-
defaultValue: { summary: "false" },
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
size: {
|
|
82
|
-
control: {
|
|
83
|
-
type: "radio",
|
|
84
|
-
},
|
|
85
|
-
options: ["small", "medium", "large"],
|
|
86
|
-
table: {
|
|
87
|
-
defaultValue: { summary: "small" },
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
onChange: {
|
|
91
|
-
type: "function",
|
|
92
|
-
control: false,
|
|
93
|
-
options: ["function", undefined],
|
|
94
|
-
mapping: {
|
|
95
|
-
function: action("onChange"),
|
|
96
|
-
undefined: undefined,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
onClick: {
|
|
100
|
-
type: "function",
|
|
101
|
-
control: {
|
|
102
|
-
type: "radio",
|
|
103
|
-
},
|
|
104
|
-
options: ["function", undefined],
|
|
105
|
-
mapping: {
|
|
106
|
-
function: action("onClick"),
|
|
107
|
-
undefined: undefined,
|
|
108
|
-
},
|
|
109
|
-
description:
|
|
110
|
-
"It is a callback function that is called when the button is clicked.",
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
parameters: {
|
|
114
|
-
controls: {
|
|
115
|
-
include: [
|
|
116
|
-
"value",
|
|
117
|
-
"kind",
|
|
118
|
-
"selectedColor",
|
|
119
|
-
"onClick",
|
|
120
|
-
"children",
|
|
121
|
-
"disabled",
|
|
122
|
-
"size",
|
|
123
|
-
"selected",
|
|
124
|
-
"color",
|
|
125
|
-
"onChange",
|
|
126
|
-
"icon",
|
|
127
|
-
],
|
|
128
|
-
},
|
|
129
|
-
docs: {
|
|
130
|
-
description: {
|
|
131
|
-
component: `A Toggle Button can be used to group related options. please
|
|
132
|
-
see [Material-UI Toggle Button](https://mui.com/material-ui/react-toggle-button/).`,
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
} as Meta<typeof ToggleButton>;
|
|
137
|
-
|
|
138
|
-
const GroupTemplate: StoryFn<typeof ToggleButton> = (arg) => {
|
|
139
|
-
const [alignment, setAlignment] = React.useState<string | null>("left");
|
|
140
|
-
|
|
141
|
-
const handleAlignment = (
|
|
142
|
-
event: React.MouseEvent<HTMLElement>,
|
|
143
|
-
newAlignment: string | null
|
|
144
|
-
) => {
|
|
145
|
-
setAlignment(newAlignment);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
return (
|
|
149
|
-
<ToggleButtonGroup
|
|
150
|
-
value={alignment}
|
|
151
|
-
exclusive
|
|
152
|
-
onChange={handleAlignment}
|
|
153
|
-
aria-label="text alignment"
|
|
154
|
-
sx={{
|
|
155
|
-
"& button": {
|
|
156
|
-
marginRight: "7px",
|
|
157
|
-
},
|
|
158
|
-
}}
|
|
159
|
-
>
|
|
160
|
-
<ToggleButton {...arg} value="left">
|
|
161
|
-
left
|
|
162
|
-
</ToggleButton>
|
|
163
|
-
<ToggleButton {...arg} value="center">
|
|
164
|
-
center
|
|
165
|
-
</ToggleButton>
|
|
166
|
-
<ToggleButton {...arg} value="right">
|
|
167
|
-
right
|
|
168
|
-
</ToggleButton>
|
|
169
|
-
<ToggleButton {...arg} value="justify" disabled>
|
|
170
|
-
justify
|
|
171
|
-
</ToggleButton>
|
|
172
|
-
</ToggleButtonGroup>
|
|
173
|
-
);
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
export const Group = {
|
|
177
|
-
render: GroupTemplate,
|
|
178
|
-
name: "Group",
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
const GroupMultipleTemplate: StoryFn<typeof ToggleButton> = (arg) => {
|
|
182
|
-
const [alignments, setAlignments] = React.useState(() => ["left", "center"]);
|
|
183
|
-
|
|
184
|
-
const handleAlignments = (
|
|
185
|
-
event: React.MouseEvent<HTMLElement>,
|
|
186
|
-
newAlignment: string[]
|
|
187
|
-
) => {
|
|
188
|
-
setAlignments(newAlignment);
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
return (
|
|
192
|
-
<ToggleButtonGroup
|
|
193
|
-
value={alignments}
|
|
194
|
-
onChange={handleAlignments}
|
|
195
|
-
aria-label="text alignment"
|
|
196
|
-
sx={{
|
|
197
|
-
"& button": {
|
|
198
|
-
marginRight: "7px",
|
|
199
|
-
},
|
|
200
|
-
}}
|
|
201
|
-
>
|
|
202
|
-
<ToggleButton {...arg} value="left">
|
|
203
|
-
left
|
|
204
|
-
</ToggleButton>
|
|
205
|
-
<ToggleButton {...arg} value="center">
|
|
206
|
-
center
|
|
207
|
-
</ToggleButton>
|
|
208
|
-
<ToggleButton {...arg} value="right">
|
|
209
|
-
right
|
|
210
|
-
</ToggleButton>
|
|
211
|
-
<ToggleButton {...arg} value="justify" disabled>
|
|
212
|
-
justify
|
|
213
|
-
</ToggleButton>
|
|
214
|
-
</ToggleButtonGroup>
|
|
215
|
-
);
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
export const GroupMultiple = {
|
|
219
|
-
render: GroupMultipleTemplate,
|
|
220
|
-
name: "Group: Multiple selection",
|
|
221
|
-
};
|