@lunit/design-system 1.0.0-b.3 → 1.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/Chip/index.js +1 -1
- package/dist/cjs/components/Chip/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/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/components/Button/Button.js +30 -6
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.styled.js +1 -10
- package/dist/components/Button/Button.styled.js.map +1 -1
- package/dist/components/Chip/Chip.js +6 -5
- package/dist/components/Chip/Chip.js.map +1 -1
- package/dist/components/TextField/TextField.js +4 -4
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/Toggle/Toggle.js +4 -4
- package/dist/components/Toggle/Toggle.js.map +1 -1
- package/dist/components/Toggle/Toggle.styled.js +2 -3
- package/dist/components/Toggle/Toggle.styled.js.map +1 -1
- package/dist/components/ToggleButton/ToggleButton.js +6 -5
- package/dist/components/ToggleButton/ToggleButton.js.map +1 -1
- package/dist/components/ToggleButton/ToggleButton.styled.js +9 -2
- package/dist/components/ToggleButton/ToggleButton.styled.js.map +1 -1
- package/dist/foundation/Typography/index.js +20 -2
- package/dist/foundation/Typography/index.js.map +1 -1
- package/dist/foundation/Typography/tokens.js +2 -2
- package/dist/foundation/colors/index.js +4 -0
- package/dist/foundation/colors/index.js.map +1 -1
- package/dist/foundation/colors/token/core.js +0 -2
- 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/types/components/Button/Button.styled.d.ts +0 -8
- package/dist/types/components/Button/Button.types.d.ts +8 -5
- package/dist/types/components/Chip/Chip.types.d.ts +7 -2
- package/dist/types/components/TextField/TextField.types.d.ts +8 -3
- package/dist/types/components/Toggle/Toggle.d.ts +1 -1
- package/dist/types/components/Toggle/Toggle.styled.d.ts +1 -1
- package/dist/types/components/Toggle/Toggle.types.d.ts +5 -5
- package/dist/types/components/ToggleButton/ToggleButton.d.ts +2 -2
- package/dist/types/components/ToggleButton/ToggleButton.styled.d.ts +4 -0
- package/dist/types/components/ToggleButton/ToggleButton.types.d.ts +4 -5
- package/dist/types/foundation/Typography/index.d.ts +21 -4
- package/dist/types/foundation/Typography/tokens.d.ts +2 -2
- package/dist/types/foundation/colors/index.d.ts +4 -0
- package/dist/types/foundation/index.d.ts +4 -0
- package/package.json +1 -1
- package/src/components/Button/Button.styled.ts +1 -10
- package/src/components/Button/Button.tsx +120 -37
- package/src/components/Button/Button.types.ts +8 -4
- package/src/components/Chip/Chip.tsx +15 -4
- package/src/components/Chip/Chip.types.ts +9 -2
- package/src/components/TextField/TextField.tsx +10 -10
- package/src/components/TextField/TextField.types.ts +11 -4
- package/src/components/Toggle/Toggle.styled.ts +4 -4
- package/src/components/Toggle/Toggle.tsx +28 -9
- package/src/components/Toggle/Toggle.types.ts +8 -8
- package/src/components/ToggleButton/ToggleButton.styled.ts +14 -7
- package/src/components/ToggleButton/ToggleButton.tsx +92 -79
- package/src/components/ToggleButton/ToggleButton.types.ts +5 -4
- package/src/foundation/Typography/index.ts +20 -2
- package/src/foundation/Typography/tokens.ts +2 -2
- package/src/foundation/colors/index.ts +4 -0
- package/src/foundation/colors/token/core.ts +0 -2
- package/src/foundation/index.ts +1 -1
- package/src/stories/components/Button/BasicButton.stories.tsx +11 -0
- package/src/stories/components/Button/IconButton.stories.tsx +11 -0
- package/src/stories/components/Button/Kind.stories.tsx +62 -25
- package/src/stories/components/Chip/Chip.stories.tsx +15 -5
- package/src/stories/components/SelectControl/Toggle.stories.tsx +10 -10
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { SxProps } from "@mui/material";
|
|
3
|
-
import type { OutlinedTextFieldProps } from "@mui/material/TextField";
|
|
3
|
+
import type { TextFieldProps as MuiTextFieldProps, OutlinedTextFieldProps } from "@mui/material/TextField";
|
|
4
4
|
export type TextFieldSize = "small" | "medium" | "large";
|
|
5
5
|
export interface BaseTextFieldProps extends Omit<OutlinedTextFieldProps, "size" | "value" | "helperText" | "variant"> {
|
|
6
6
|
/**
|
|
7
|
-
* The design system TextField
|
|
7
|
+
* The design system TextField has only on kind, which is "contained"
|
|
8
|
+
Below are all return same kind "contained"
|
|
9
|
+
<TextField variant="outlined" />
|
|
10
|
+
<TextField variant="contained" />
|
|
11
|
+
<TextField variant="filled" />
|
|
12
|
+
<TextField variant="standard" />
|
|
8
13
|
*/
|
|
9
|
-
variant?: "
|
|
14
|
+
variant?: MuiTextFieldProps["variant"];
|
|
10
15
|
value?: string;
|
|
11
16
|
helperText?: string;
|
|
12
17
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SwitchProps } from "@mui/material";
|
|
2
2
|
interface ToggleProps extends SwitchProps {
|
|
3
|
-
toggleSize: "
|
|
3
|
+
toggleSize: "small" | "large";
|
|
4
4
|
}
|
|
5
5
|
export declare const CommonToggle: import("@emotion/styled").StyledComponent<SwitchProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & ToggleProps, {}, {}>;
|
|
6
6
|
export declare const CommonIndeterminateToggle: import("@emotion/styled").StyledComponent<SwitchProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & ToggleProps, {}, {}>;
|
|
@@ -2,12 +2,12 @@ import type { SwitchProps } from "@mui/material";
|
|
|
2
2
|
export interface ToggleProps extends Omit<SwitchProps, "size"> {
|
|
3
3
|
/**
|
|
4
4
|
* The size of the component.
|
|
5
|
-
* @default
|
|
5
|
+
* @default small
|
|
6
6
|
*/
|
|
7
|
-
size?:
|
|
7
|
+
size?: "small" | "large";
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
* If `true`, the component has consistent 'checked' value and change shape.
|
|
10
|
+
* @default false
|
|
11
|
+
*/
|
|
12
12
|
indeterminate?: boolean;
|
|
13
13
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare const ToggleButton: (
|
|
1
|
+
import React from "react";
|
|
2
|
+
declare const ToggleButton: React.ForwardRefExoticComponent<(Omit<import("./ToggleButton.types").ContainedToggleButtonProps, "ref"> | Omit<import("./ToggleButton.types").GhostToggleButtonProps, "ref"> | Omit<import("./ToggleButton.types").OutlinedToggleButtonProps, "ref">) & React.RefAttributes<HTMLButtonElement>>;
|
|
3
3
|
export default ToggleButton;
|
|
@@ -36,4 +36,8 @@ export declare const CustomToggleButton: import("@emotion/styled").StyledCompone
|
|
|
36
36
|
ref?: ((instance: HTMLButtonElement | null) => void) | import("react").RefObject<HTMLButtonElement> | null | undefined;
|
|
37
37
|
}, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "tabIndex" | "color" | "onChange" | "onClick" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableFocusRipple" | "fullWidth" | "size" | "value" | "selected"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & CustomToggleButtonProps, {}, {}>;
|
|
38
38
|
export declare const IconAndChildrenWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
39
|
+
export declare const IconWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
|
|
40
|
+
hasIconOnly: boolean;
|
|
41
|
+
size: string;
|
|
42
|
+
}, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
39
43
|
export {};
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { ToggleButtonProps as MuiToggleButtonProps } from "@mui/material";
|
|
3
|
-
interface ToggleButtonBaseProps extends Omit<MuiToggleButtonProps, "variant"> {
|
|
3
|
+
export interface ToggleButtonBaseProps extends Omit<MuiToggleButtonProps, "variant"> {
|
|
4
4
|
selectedColor?: "primary" | "secondary";
|
|
5
5
|
icon?: React.ReactNode;
|
|
6
6
|
}
|
|
7
|
-
interface ContainedToggleButtonProps extends ToggleButtonBaseProps {
|
|
7
|
+
export interface ContainedToggleButtonProps extends ToggleButtonBaseProps {
|
|
8
8
|
kind?: "contained";
|
|
9
9
|
color?: "primary" | "secondary";
|
|
10
10
|
}
|
|
11
|
-
interface GhostToggleButtonProps extends ToggleButtonBaseProps {
|
|
11
|
+
export interface GhostToggleButtonProps extends ToggleButtonBaseProps {
|
|
12
12
|
kind?: "ghost";
|
|
13
13
|
color?: "primary" | "secondary";
|
|
14
14
|
}
|
|
15
|
-
interface OutlinedToggleButtonProps extends ToggleButtonBaseProps {
|
|
15
|
+
export interface OutlinedToggleButtonProps extends ToggleButtonBaseProps {
|
|
16
16
|
kind?: "outlined";
|
|
17
17
|
color?: "primary";
|
|
18
18
|
}
|
|
19
19
|
export type ToggleButtonProps = ContainedToggleButtonProps | GhostToggleButtonProps | OutlinedToggleButtonProps;
|
|
20
|
-
export {};
|
|
@@ -27,8 +27,7 @@ export declare const typographyDefaultProps: {
|
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
29
|
export declare const createTypographyCssBaseline: () => {
|
|
30
|
-
|
|
31
|
-
fontFamily: string;
|
|
30
|
+
"*, *:before, *:after": {
|
|
32
31
|
fontFeatureSettings: string;
|
|
33
32
|
};
|
|
34
33
|
":root": {
|
|
@@ -70,10 +69,10 @@ export declare const createTypographyCssBaseline: () => {
|
|
|
70
69
|
"--headline1-line-height": "68px";
|
|
71
70
|
"--headline2-font-weight": "var(--font-weight-bold)";
|
|
72
71
|
"--headline2-font-size": "38px";
|
|
73
|
-
"--headline2-line-height": "
|
|
72
|
+
"--headline2-line-height": "65px";
|
|
74
73
|
"--headline3-font-weight": "var(--font-weight-semibold)";
|
|
75
74
|
"--headline3-font-size": "24px";
|
|
76
|
-
"--headline3-line-height": "
|
|
75
|
+
"--headline3-line-height": "57px";
|
|
77
76
|
"--headline4-font-weight": "var(--font-weight-semibold)";
|
|
78
77
|
"--headline4-font-size": "20px";
|
|
79
78
|
"--headline4-line-height": "28px";
|
|
@@ -85,5 +84,23 @@ export declare const createTypographyCssBaseline: () => {
|
|
|
85
84
|
"--font-weight-medium": 500;
|
|
86
85
|
"--font-weight-regular": 400;
|
|
87
86
|
};
|
|
87
|
+
".light1": {
|
|
88
|
+
color: string;
|
|
89
|
+
};
|
|
90
|
+
".light2": {
|
|
91
|
+
color: string;
|
|
92
|
+
};
|
|
93
|
+
".dark1": {
|
|
94
|
+
color: string;
|
|
95
|
+
};
|
|
96
|
+
".dark2": {
|
|
97
|
+
color: string;
|
|
98
|
+
};
|
|
99
|
+
".dark3": {
|
|
100
|
+
color: string;
|
|
101
|
+
};
|
|
102
|
+
".dark4": {
|
|
103
|
+
color: string;
|
|
104
|
+
};
|
|
88
105
|
};
|
|
89
106
|
export default typographyOptions;
|
|
@@ -39,10 +39,10 @@ export declare const cssVariables: {
|
|
|
39
39
|
"--headline1-line-height": "68px";
|
|
40
40
|
"--headline2-font-weight": "var(--font-weight-bold)";
|
|
41
41
|
"--headline2-font-size": "38px";
|
|
42
|
-
"--headline2-line-height": "
|
|
42
|
+
"--headline2-line-height": "65px";
|
|
43
43
|
"--headline3-font-weight": "var(--font-weight-semibold)";
|
|
44
44
|
"--headline3-font-size": "24px";
|
|
45
|
-
"--headline3-line-height": "
|
|
45
|
+
"--headline3-line-height": "57px";
|
|
46
46
|
"--headline4-font-weight": "var(--font-weight-semibold)";
|
|
47
47
|
"--headline4-font-size": "20px";
|
|
48
48
|
"--headline4-line-height": "28px";
|
package/package.json
CHANGED
|
@@ -211,27 +211,18 @@ export const iconStyle = ({
|
|
|
211
211
|
hasIconOnly,
|
|
212
212
|
}: Pick<CustomButtonProps, "size" | "hasIconOnly">) => ({
|
|
213
213
|
"& .MuiButton-startIcon": {
|
|
214
|
-
width: "20px",
|
|
215
|
-
height: "20px",
|
|
216
214
|
margin: 0,
|
|
217
215
|
marginRight: hasIconOnly ? "0px" : size === "large" ? "8px" : "4px",
|
|
218
216
|
|
|
219
|
-
// This style was added for Mui Button Svg Icon handling
|
|
220
217
|
"*:nth-of-type(1)": {
|
|
221
218
|
fontSize: "20px",
|
|
222
219
|
},
|
|
223
220
|
},
|
|
224
|
-
svg: {
|
|
225
|
-
width: "20px",
|
|
226
|
-
height: "20px",
|
|
227
|
-
margin: 0,
|
|
228
|
-
marginRight: hasIconOnly ? "0px" : size === "large" ? "8px" : "4px",
|
|
229
|
-
},
|
|
230
221
|
});
|
|
231
222
|
|
|
232
223
|
export const CustomButton = styled(MuiButton, {
|
|
233
224
|
shouldForwardProp: (prop: string) => {
|
|
234
|
-
return !["kind", "hasIconOnly"].includes(prop);
|
|
225
|
+
return !["kind", "hasIconOnly", "variant"].includes(prop);
|
|
235
226
|
},
|
|
236
227
|
})<CustomButtonProps>(
|
|
237
228
|
({
|
|
@@ -1,52 +1,135 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { forwardRef } from "react";
|
|
2
2
|
|
|
3
3
|
import { CustomButton } from "./Button.styled";
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
ButtonType,
|
|
7
|
+
ButtonProps,
|
|
8
|
+
GhostButtonProps,
|
|
9
|
+
OutlinedButtonProps,
|
|
10
|
+
ContainedButtonProps,
|
|
11
|
+
} from "./Button.types";
|
|
6
12
|
|
|
7
|
-
const Button
|
|
13
|
+
const Button = forwardRef<HTMLButtonElement, ButtonProps>((props, ref) => {
|
|
14
|
+
const { kind, variant, icon, children, startIcon } = props;
|
|
15
|
+
const hasIconOnly = Boolean((startIcon || icon) && !children);
|
|
16
|
+
|
|
17
|
+
if (kind === "outlined" || variant === "outlined") {
|
|
18
|
+
return <OutlinedButton {...props} ref={ref} hasIconOnly={hasIconOnly} />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (kind === "ghost" || variant === "text" || variant === "ghost") {
|
|
22
|
+
return <GhostButton {...props} ref={ref} hasIconOnly={hasIconOnly} />;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<ContainedButton
|
|
27
|
+
{...props}
|
|
28
|
+
kind="contained"
|
|
29
|
+
variant="contained"
|
|
30
|
+
ref={ref}
|
|
31
|
+
hasIconOnly={hasIconOnly}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* There is an issue between React 18, Mui's OverridableComponent type and the
|
|
37
|
+
* type coercion to temporarily fix it.
|
|
38
|
+
* https://github.com/lunit-io/design-system/pull/143#issuecomment-1831127232
|
|
39
|
+
*/
|
|
40
|
+
}) as ButtonType;
|
|
41
|
+
|
|
42
|
+
const GhostButton = forwardRef<
|
|
43
|
+
HTMLButtonElement,
|
|
44
|
+
GhostButtonProps & { hasIconOnly: boolean }
|
|
45
|
+
>((props, ref) => {
|
|
46
|
+
const {
|
|
47
|
+
size = "small",
|
|
48
|
+
icon,
|
|
49
|
+
className,
|
|
50
|
+
children,
|
|
51
|
+
startIcon,
|
|
52
|
+
hasIconOnly,
|
|
53
|
+
variant,
|
|
54
|
+
...restProps
|
|
55
|
+
} = props;
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<CustomButton
|
|
59
|
+
{...restProps}
|
|
60
|
+
ref={ref}
|
|
61
|
+
className={`ghost ${className ? className : ""}`}
|
|
62
|
+
kind="ghost"
|
|
63
|
+
color={props.color ?? "primary"}
|
|
64
|
+
size={size}
|
|
65
|
+
startIcon={startIcon || icon}
|
|
66
|
+
hasIconOnly={hasIconOnly}
|
|
67
|
+
>
|
|
68
|
+
{!hasIconOnly && <>{children}</>}
|
|
69
|
+
</CustomButton>
|
|
70
|
+
);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const OutlinedButton = forwardRef<
|
|
74
|
+
HTMLButtonElement,
|
|
75
|
+
OutlinedButtonProps & { hasIconOnly: boolean }
|
|
76
|
+
>((props, ref) => {
|
|
77
|
+
const {
|
|
78
|
+
size = "small",
|
|
79
|
+
icon,
|
|
80
|
+
className,
|
|
81
|
+
children,
|
|
82
|
+
startIcon,
|
|
83
|
+
hasIconOnly,
|
|
84
|
+
variant,
|
|
85
|
+
...restProps
|
|
86
|
+
} = props;
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<CustomButton
|
|
90
|
+
{...restProps}
|
|
91
|
+
ref={ref}
|
|
92
|
+
className={`outlined ${className ? className : ""}`}
|
|
93
|
+
kind="outlined"
|
|
94
|
+
color={props.color ?? "primary"}
|
|
95
|
+
size={size}
|
|
96
|
+
startIcon={startIcon || icon}
|
|
97
|
+
hasIconOnly={hasIconOnly}
|
|
98
|
+
>
|
|
99
|
+
{!hasIconOnly && <>{children}</>}
|
|
100
|
+
</CustomButton>
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const ContainedButton = forwardRef<
|
|
105
|
+
HTMLButtonElement,
|
|
106
|
+
ContainedButtonProps & { hasIconOnly: boolean }
|
|
107
|
+
>((props, ref) => {
|
|
8
108
|
const {
|
|
9
109
|
size = "small",
|
|
10
|
-
color = "primary",
|
|
11
110
|
icon,
|
|
12
111
|
className,
|
|
13
112
|
children,
|
|
14
|
-
|
|
113
|
+
startIcon,
|
|
114
|
+
hasIconOnly,
|
|
115
|
+
variant,
|
|
116
|
+
...restProps
|
|
15
117
|
} = props;
|
|
16
|
-
const hasIconOnly = Boolean(icon && !children);
|
|
17
118
|
|
|
18
119
|
return (
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{!hasIconOnly && <>{children}</>}
|
|
32
|
-
</CustomButton>
|
|
33
|
-
) : (
|
|
34
|
-
<CustomButton
|
|
35
|
-
{...buttonProps}
|
|
36
|
-
className={`${props.kind ?? "contained"} ${
|
|
37
|
-
className ? className : ""
|
|
38
|
-
}`}
|
|
39
|
-
kind={props.kind ?? "contained"}
|
|
40
|
-
color={props.color ?? "primary"}
|
|
41
|
-
size={size}
|
|
42
|
-
startIcon={icon}
|
|
43
|
-
hasIconOnly={hasIconOnly}
|
|
44
|
-
>
|
|
45
|
-
{!hasIconOnly && <>{children}</>}
|
|
46
|
-
</CustomButton>
|
|
47
|
-
)}
|
|
48
|
-
</>
|
|
120
|
+
<CustomButton
|
|
121
|
+
{...restProps}
|
|
122
|
+
ref={ref}
|
|
123
|
+
className={`${props.kind ?? "contained"} ${className ? className : ""}`}
|
|
124
|
+
kind={props.kind ?? "contained"}
|
|
125
|
+
color={props.color ?? "primary"}
|
|
126
|
+
size={size}
|
|
127
|
+
startIcon={startIcon || icon}
|
|
128
|
+
hasIconOnly={hasIconOnly}
|
|
129
|
+
>
|
|
130
|
+
{!hasIconOnly && <>{children}</>}
|
|
131
|
+
</CustomButton>
|
|
49
132
|
);
|
|
50
|
-
};
|
|
133
|
+
});
|
|
51
134
|
|
|
52
135
|
export default Button;
|
|
@@ -8,22 +8,26 @@ import type { OverridableComponent } from "@mui/material/OverridableComponent";
|
|
|
8
8
|
* TODO: Omit 을 사용할 경우 component prop 타입 추론이 안되는 이슈 발생
|
|
9
9
|
* https://github.com/lunit-io/design-system/pull/133#discussion_r1354277785
|
|
10
10
|
* */
|
|
11
|
-
interface BaseButtonProps extends Omit<MuiButtonProps, "variant"> {
|
|
11
|
+
export interface BaseButtonProps extends Omit<MuiButtonProps, "variant"> {
|
|
12
12
|
icon?: React.ReactNode;
|
|
13
|
+
variant?: "contained" | "outlined" | "text" | "ghost";
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
interface ContainedButtonProps extends BaseButtonProps {
|
|
16
|
+
export interface ContainedButtonProps extends BaseButtonProps {
|
|
16
17
|
kind?: "contained";
|
|
18
|
+
variant?: "contained";
|
|
17
19
|
color?: "primary" | "secondary" | "error";
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
interface GhostButtonProps extends BaseButtonProps {
|
|
22
|
+
export interface GhostButtonProps extends BaseButtonProps {
|
|
21
23
|
kind?: "ghost";
|
|
24
|
+
variant?: "text" | "ghost";
|
|
22
25
|
color?: "primary" | "secondary" | "error";
|
|
23
26
|
}
|
|
24
27
|
|
|
25
|
-
interface OutlinedButtonProps extends BaseButtonProps {
|
|
28
|
+
export interface OutlinedButtonProps extends BaseButtonProps {
|
|
26
29
|
kind?: "outlined";
|
|
30
|
+
variant?: "outlined";
|
|
27
31
|
color?: "primary" | "secondary";
|
|
28
32
|
}
|
|
29
33
|
|
|
@@ -19,8 +19,11 @@ import type {
|
|
|
19
19
|
} from "./Chip.types";
|
|
20
20
|
|
|
21
21
|
const Chip: ChipType = (props: ChipProps) => {
|
|
22
|
-
const { kind, onDelete, onClick, ...restProps } = props;
|
|
23
|
-
|
|
22
|
+
const { kind, variant, onDelete, onClick, ...restProps } = props;
|
|
23
|
+
|
|
24
|
+
const isOutlined = kind === "outlined" || variant === "outlined";
|
|
25
|
+
|
|
26
|
+
if (isOutlined) return <OutlinedChip {...props} />;
|
|
24
27
|
else if (onClick) return <EnableContainedChip {...props} />;
|
|
25
28
|
else if (onDelete) return <DeletableContainedChip {...props} />;
|
|
26
29
|
|
|
@@ -63,7 +66,7 @@ const getLabelMargin = (
|
|
|
63
66
|
};
|
|
64
67
|
|
|
65
68
|
const ReadOnlyContainedChip = (props: ReadOnlyContainedChipProps) => {
|
|
66
|
-
const { color = "primary", thumbnail, sx, ...restProps } = props;
|
|
69
|
+
const { color = "primary", thumbnail, sx, variant, ...restProps } = props;
|
|
67
70
|
|
|
68
71
|
return (
|
|
69
72
|
<StyledContainedChipBase
|
|
@@ -89,6 +92,7 @@ const EnableContainedChip = (props: EnableContainedChipProps) => {
|
|
|
89
92
|
onDelete,
|
|
90
93
|
onClick,
|
|
91
94
|
sx,
|
|
95
|
+
variant,
|
|
92
96
|
...restProps
|
|
93
97
|
} = props;
|
|
94
98
|
|
|
@@ -117,7 +121,14 @@ const DeleteIconWithHoverLayer = ({ onClick }: { onClick: () => void }) => {
|
|
|
117
121
|
);
|
|
118
122
|
};
|
|
119
123
|
const DeletableContainedChip = (props: DeletableContainedChipProps) => {
|
|
120
|
-
const {
|
|
124
|
+
const {
|
|
125
|
+
color = "primary",
|
|
126
|
+
thumbnail,
|
|
127
|
+
onDelete,
|
|
128
|
+
sx,
|
|
129
|
+
variant,
|
|
130
|
+
...restProps
|
|
131
|
+
} = props;
|
|
121
132
|
|
|
122
133
|
return (
|
|
123
134
|
<StyledContainedChipDeletable
|
|
@@ -6,6 +6,8 @@ import type {
|
|
|
6
6
|
} from "@mui/material";
|
|
7
7
|
import type { OverridableComponent } from "@mui/material/OverridableComponent";
|
|
8
8
|
|
|
9
|
+
type DesignSystemChipKind = "outlined" | "contained";
|
|
10
|
+
type DesignSystemAndMuiContainedChipKind = "filled" | "contained";
|
|
9
11
|
type ColorKeys = keyof typeof CHIP_COLORS;
|
|
10
12
|
export type ChipColor = (typeof CHIP_COLORS)[ColorKeys];
|
|
11
13
|
export type ChipThumbnail = string | JSX.Element;
|
|
@@ -18,12 +20,16 @@ export interface BaseChipProps
|
|
|
18
20
|
MuiChipProps,
|
|
19
21
|
"label" | "sx" | "style" | "classes" | "onDelete"
|
|
20
22
|
> {
|
|
21
|
-
kind
|
|
23
|
+
// either kind or variant
|
|
24
|
+
kind?: DesignSystemChipKind;
|
|
25
|
+
variant?: "outlined" | DesignSystemAndMuiContainedChipKind;
|
|
26
|
+
// mui variant = outlined | "filled" | undefined
|
|
22
27
|
color?: ChipColor;
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
export interface OutlinedChipProps extends BaseChipProps {
|
|
26
31
|
kind?: "outlined";
|
|
32
|
+
variant?: "outlined";
|
|
27
33
|
onClick?: never;
|
|
28
34
|
onDelete?: never;
|
|
29
35
|
}
|
|
@@ -32,9 +38,10 @@ export interface BaseContainedChipProps
|
|
|
32
38
|
extends BaseChipProps,
|
|
33
39
|
Omit<
|
|
34
40
|
MuiChipProps,
|
|
35
|
-
"color" | "size" | "
|
|
41
|
+
"color" | "size" | "avatar" | "deleteIcon" | "icon" | "variant"
|
|
36
42
|
> {
|
|
37
43
|
kind?: "contained";
|
|
44
|
+
variant?: DesignSystemAndMuiContainedChipKind;
|
|
38
45
|
thumbnail?: ChipThumbnail;
|
|
39
46
|
onClick?: () => void;
|
|
40
47
|
}
|
|
@@ -25,6 +25,7 @@ const SingleTextField = forwardRef<HTMLDivElement, SingleTextFieldProps>(
|
|
|
25
25
|
|
|
26
26
|
return (
|
|
27
27
|
<BaseTextField
|
|
28
|
+
variant="outlined"
|
|
28
29
|
{...restProps}
|
|
29
30
|
ref={ref}
|
|
30
31
|
textFieldSize={size}
|
|
@@ -57,19 +58,19 @@ const SingleTextField = forwardRef<HTMLDivElement, SingleTextFieldProps>(
|
|
|
57
58
|
const MultiTextField = forwardRef<HTMLDivElement, MultiTextFieldProps>(
|
|
58
59
|
({ size = "small", ...restProps }, ref) => {
|
|
59
60
|
return (
|
|
60
|
-
<BaseTextField
|
|
61
|
+
<BaseTextField
|
|
62
|
+
variant="outlined"
|
|
63
|
+
{...restProps}
|
|
64
|
+
ref={ref}
|
|
65
|
+
textFieldSize={size}
|
|
66
|
+
multiline
|
|
67
|
+
/>
|
|
61
68
|
);
|
|
62
69
|
}
|
|
63
70
|
);
|
|
64
71
|
|
|
65
72
|
const TextField = forwardRef<HTMLDivElement, TextFieldProps>((props, ref) => {
|
|
66
|
-
const {
|
|
67
|
-
rows,
|
|
68
|
-
size,
|
|
69
|
-
multiline = false,
|
|
70
|
-
variant = "outlined",
|
|
71
|
-
...restProps
|
|
72
|
-
} = props;
|
|
73
|
+
const { rows, size, multiline = false, variant, ...restProps } = props;
|
|
73
74
|
|
|
74
75
|
return multiline ? (
|
|
75
76
|
<MultiTextField
|
|
@@ -77,11 +78,10 @@ const TextField = forwardRef<HTMLDivElement, TextFieldProps>((props, ref) => {
|
|
|
77
78
|
ref={ref}
|
|
78
79
|
maxRows={Infinity}
|
|
79
80
|
size={size}
|
|
80
|
-
variant={variant}
|
|
81
81
|
rows={rows}
|
|
82
82
|
/>
|
|
83
83
|
) : (
|
|
84
|
-
<SingleTextField {...restProps} ref={ref} size={size}
|
|
84
|
+
<SingleTextField {...restProps} ref={ref} size={size} />
|
|
85
85
|
);
|
|
86
86
|
});
|
|
87
87
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { SxProps } from "@mui/material";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
TextFieldProps as MuiTextFieldProps,
|
|
4
|
+
OutlinedTextFieldProps,
|
|
5
|
+
} from "@mui/material/TextField";
|
|
3
6
|
|
|
4
7
|
export type TextFieldSize = "small" | "medium" | "large";
|
|
5
8
|
export interface BaseTextFieldProps
|
|
@@ -8,12 +11,16 @@ export interface BaseTextFieldProps
|
|
|
8
11
|
"size" | "value" | "helperText" | "variant"
|
|
9
12
|
> {
|
|
10
13
|
/**
|
|
11
|
-
* The design system TextField
|
|
14
|
+
* The design system TextField has only on kind, which is "contained"
|
|
15
|
+
Below are all return same kind "contained"
|
|
16
|
+
<TextField variant="outlined" />
|
|
17
|
+
<TextField variant="contained" />
|
|
18
|
+
<TextField variant="filled" />
|
|
19
|
+
<TextField variant="standard" />
|
|
12
20
|
*/
|
|
13
|
-
variant?: "
|
|
21
|
+
variant?: MuiTextFieldProps["variant"];
|
|
14
22
|
value?: string;
|
|
15
23
|
helperText?: string;
|
|
16
|
-
|
|
17
24
|
/**
|
|
18
25
|
* @default "small"
|
|
19
26
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { styled, Switch as MuiSwitch, SwitchProps } from "@mui/material";
|
|
2
2
|
interface ToggleProps extends SwitchProps {
|
|
3
|
-
toggleSize: "
|
|
3
|
+
toggleSize: "small" | "large";
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
const toggleStyles = {
|
|
7
|
-
|
|
7
|
+
small: {
|
|
8
8
|
root: {
|
|
9
9
|
width: 28,
|
|
10
10
|
height: 18,
|
|
@@ -65,7 +65,7 @@ const indeterminateStyles = {
|
|
|
65
65
|
borderRadius: 2,
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
|
-
|
|
68
|
+
small: {
|
|
69
69
|
switchChecked: {
|
|
70
70
|
top: 6,
|
|
71
71
|
left: -4,
|
|
@@ -94,7 +94,7 @@ export const CommonToggle = styled(MuiSwitch, {
|
|
|
94
94
|
|
|
95
95
|
return {
|
|
96
96
|
...toggleStyle.root,
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
padding: 0,
|
|
99
99
|
overflow: "visible",
|
|
100
100
|
backgroundColor: "transparent",
|