@team-monolith/cds 0.4.0 → 0.4.3
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/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +5 -1
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/src/App.tsx +0 -7
- package/src/cds/CodleDesignSystemProvider.tsx +0 -93
- package/src/cds/README.md +0 -23
- package/src/cds/components/AlertDialog/AlertDialog.tsx +0 -101
- package/src/cds/components/AlertDialog/AlertDialogActions.tsx +0 -34
- package/src/cds/components/AlertDialog/AlertDialogContent.tsx +0 -36
- package/src/cds/components/AlertDialog/AlertDialogTitle.tsx +0 -63
- package/src/cds/components/AlertDialog/index.tsx +0 -4
- package/src/cds/components/Banner.tsx +0 -176
- package/src/cds/components/Button.tsx +0 -256
- package/src/cds/components/CheckboxInput.tsx +0 -270
- package/src/cds/components/Input.tsx +0 -171
- package/src/cds/components/InputBase.tsx +0 -226
- package/src/cds/components/Pagination.tsx +0 -99
- package/src/cds/components/PinInput.tsx +0 -322
- package/src/cds/components/RadioInput.tsx +0 -226
- package/src/cds/components/SquareButton.tsx +0 -229
- package/src/cds/components/Switch.tsx +0 -129
- package/src/cds/components/Tag.tsx +0 -155
- package/src/cds/components/Tooltip.tsx +0 -104
- package/src/cds/foundation/color.ts +0 -83
- package/src/cds/foundation/shadows.ts +0 -17
- package/src/cds/icons/Arrows/index.ts +0 -2
- package/src/cds/icons/Media/index.ts +0 -2
- package/src/cds/icons/System/index.ts +0 -2
- package/src/cds/icons/arrows.tsx +0 -116
- package/src/cds/icons/brand.tsx +0 -13
- package/src/cds/icons/design.tsx +0 -15
- package/src/cds/icons/map.tsx +0 -14
- package/src/cds/icons/system.tsx +0 -143
- package/src/cds/index.ts +0 -64
- package/src/cds/patterns/Card/Card.tsx +0 -294
- package/src/cds/patterns/Card/class-icon.svg +0 -28
- package/src/cds/patterns/Card/index.tsx +0 -2
- package/src/cds/patterns/Card/material-icon.svg +0 -25
- package/src/cds/patterns/Card/problem-icon.svg +0 -25
- package/src/cds/patterns/Card/thumbnail/sample.png +0 -0
- package/src/cds/patterns/Dialog/Dialog.tsx +0 -57
- package/src/cds/patterns/Dialog/DialogContent.tsx +0 -28
- package/src/cds/patterns/Dialog/DialogNavigation.tsx +0 -29
- package/src/cds/patterns/Dialog/DialogNavigationContext.tsx +0 -9
- package/src/cds/patterns/Dialog/DialogNavigationItem.tsx +0 -42
- package/src/cds/patterns/Dialog/DialogPanel.tsx +0 -40
- package/src/cds/patterns/Dialog/DialogPanels.tsx +0 -24
- package/src/cds/patterns/Dialog/DialogPanelsContext.tsx +0 -9
- package/src/cds/patterns/Dialog/DialogTitle.tsx +0 -55
- package/src/cds/patterns/Dialog/index.tsx +0 -7
- package/src/cds/patterns/Dropdown/Dropdown.tsx +0 -111
- package/src/cds/patterns/Dropdown/DropdownItem.tsx +0 -203
- package/src/cds/patterns/Dropdown/DropdownMenu.tsx +0 -176
- package/src/cds/patterns/Dropdown/index.tsx +0 -2
- package/src/cds/patterns/EmptyState/EmptyState.tsx +0 -91
- package/src/cds/patterns/EmptyState/empty-state-icon.svg +0 -36
- package/src/cds/patterns/EmptyState/index.tsx +0 -2
- package/src/cds/patterns/Navigation/NavigationContext.tsx +0 -9
- package/src/cds/patterns/Navigation/NavigationHorizontal.tsx +0 -32
- package/src/cds/patterns/Navigation/NavigationItem.tsx +0 -36
- package/src/cds/patterns/Navigation/NavigationVertical.tsx +0 -39
- package/src/cds/patterns/Navigation/index.tsx +0 -3
- package/src/cds/patterns/SegmentedControl/SegmentedControlButton.tsx +0 -55
- package/src/cds/patterns/SegmentedControl/SegmentedControlGroup.tsx +0 -81
- package/src/cds/patterns/SegmentedControl/SegmentedControlGroupPropsContext.tsx +0 -9
- package/src/cds/patterns/SegmentedControl/SegmentedControlSquareButton.tsx +0 -51
- package/src/cds/patterns/SegmentedControl/index.ts +0 -3
- package/src/cds/patterns/Table/Table.tsx +0 -62
- package/src/cds/patterns/Table/TableBody.tsx +0 -30
- package/src/cds/patterns/Table/TableCell.tsx +0 -253
- package/src/cds/patterns/Table/TableHead.tsx +0 -30
- package/src/cds/patterns/Table/TablePropsContext.tsx +0 -9
- package/src/cds/patterns/Table/TableRow.tsx +0 -70
- package/src/cds/patterns/Table/TableVariantContext.tsx +0 -9
- package/src/cds/patterns/Table/index.tsx +0 -15
- package/src/cds/utils/hover.tsx +0 -24
- package/src/cds/utils/reset.tsx +0 -19
- package/src/cds/utils/zIndex.tsx +0 -3
- package/src/index.tsx +0 -10
- package/tsconfig.json +0 -22
- /package/{src/cds → @types}/emotion.d.ts +0 -0
- /package/{src/cds → @types}/svg.d.ts +0 -0
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @emotion/react */
|
|
2
|
-
import { SerializedStyles, css, Theme, useTheme } from "@emotion/react";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import styled from "@emotion/styled";
|
|
5
|
-
import { ZINDEX } from "../utils/zIndex";
|
|
6
|
-
import { InputHTMLAttributes } from "react";
|
|
7
|
-
|
|
8
|
-
export type RadioInputType = "default" | "selected";
|
|
9
|
-
|
|
10
|
-
const TYPE_TO_ICON_STYLE = (
|
|
11
|
-
theme: Theme,
|
|
12
|
-
type: RadioInputType,
|
|
13
|
-
disabled: boolean
|
|
14
|
-
): SerializedStyles => {
|
|
15
|
-
return {
|
|
16
|
-
default: css`
|
|
17
|
-
path {
|
|
18
|
-
stroke: ${theme.color.background.neutralAltActive};
|
|
19
|
-
fill: ${theme.color.background.neutralBase};
|
|
20
|
-
}
|
|
21
|
-
${disabled
|
|
22
|
-
? css`
|
|
23
|
-
cursor: default;
|
|
24
|
-
path {
|
|
25
|
-
stroke: ${theme.color.background.primaryDisabled};
|
|
26
|
-
fill: ${theme.color.background.neutralAlt};
|
|
27
|
-
}
|
|
28
|
-
`
|
|
29
|
-
: css`
|
|
30
|
-
input[type="radio"]:hover + & {
|
|
31
|
-
path {
|
|
32
|
-
stroke: ${theme.color.background.primary};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
`}
|
|
36
|
-
`,
|
|
37
|
-
selected: css`
|
|
38
|
-
path {
|
|
39
|
-
stroke: ${theme.color.background.primary};
|
|
40
|
-
fill: ${theme.color.background.neutralBase};
|
|
41
|
-
}
|
|
42
|
-
rect {
|
|
43
|
-
fill: ${theme.color.background.primary};
|
|
44
|
-
}
|
|
45
|
-
${disabled
|
|
46
|
-
? css`
|
|
47
|
-
cursor: default;
|
|
48
|
-
path {
|
|
49
|
-
stroke: ${theme.color.background.primaryDisabled};
|
|
50
|
-
fill: ${theme.color.background.neutralAlt};
|
|
51
|
-
}
|
|
52
|
-
rect {
|
|
53
|
-
fill: ${theme.color.background.primaryDisabled};
|
|
54
|
-
}
|
|
55
|
-
`
|
|
56
|
-
: css`
|
|
57
|
-
input[type="radio"]:hover + & {
|
|
58
|
-
path {
|
|
59
|
-
stroke: ${theme.color.background.primaryActive};
|
|
60
|
-
}
|
|
61
|
-
rect {
|
|
62
|
-
fill: ${theme.color.background.primaryActive};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
`}
|
|
66
|
-
`,
|
|
67
|
-
}[type];
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export interface RadioInputProps {
|
|
71
|
-
className?: string;
|
|
72
|
-
// component: React.ElementType; // 불필요한 dom 중첩을 막기 위해 사용하지 않습니다.
|
|
73
|
-
|
|
74
|
-
/** 라디오 버튼의 선택 여부(Controlled) */
|
|
75
|
-
checked: boolean;
|
|
76
|
-
/** 라디오 버튼의 라벨 */
|
|
77
|
-
label?: string;
|
|
78
|
-
/** 라디오 버튼의 하단 마진(8px) 여부 */
|
|
79
|
-
spacer?: boolean;
|
|
80
|
-
/** 라디오 버튼의 비활성화 여부 */
|
|
81
|
-
disabled?: boolean;
|
|
82
|
-
/** 라디오 버튼 선택값 변경시 호출되는 함수 */
|
|
83
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
84
|
-
/** HTML input 태그에 전달될 props */
|
|
85
|
-
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=420-3704&t=lvpbJKdtz7Lb8wIQ-0)
|
|
90
|
-
*/
|
|
91
|
-
const RadioInput = React.forwardRef<any, RadioInputProps>((props, ref) => {
|
|
92
|
-
const {
|
|
93
|
-
className,
|
|
94
|
-
checked,
|
|
95
|
-
label,
|
|
96
|
-
spacer,
|
|
97
|
-
disabled,
|
|
98
|
-
onChange,
|
|
99
|
-
inputProps,
|
|
100
|
-
...other
|
|
101
|
-
} = props;
|
|
102
|
-
|
|
103
|
-
if (!label) {
|
|
104
|
-
return <RadioButton {...props} ref={ref} />;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const radioProps = {
|
|
108
|
-
checked,
|
|
109
|
-
spacer,
|
|
110
|
-
disabled,
|
|
111
|
-
onChange,
|
|
112
|
-
inputProps,
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<Label className={className} ref={ref} {...other}>
|
|
117
|
-
<RadioButton {...radioProps} />
|
|
118
|
-
<span
|
|
119
|
-
css={css`
|
|
120
|
-
margin-left: 8px;
|
|
121
|
-
`}
|
|
122
|
-
>
|
|
123
|
-
{label}
|
|
124
|
-
</span>
|
|
125
|
-
</Label>
|
|
126
|
-
);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const RadioButton = React.forwardRef<any, RadioInputProps>((props, ref) => {
|
|
130
|
-
const {
|
|
131
|
-
className,
|
|
132
|
-
checked,
|
|
133
|
-
label,
|
|
134
|
-
spacer = false,
|
|
135
|
-
disabled = false,
|
|
136
|
-
onChange,
|
|
137
|
-
inputProps,
|
|
138
|
-
...other
|
|
139
|
-
} = props;
|
|
140
|
-
const type: RadioInputType = props.checked ? "selected" : "default";
|
|
141
|
-
|
|
142
|
-
return (
|
|
143
|
-
<RadioButtonContainer
|
|
144
|
-
className={className}
|
|
145
|
-
spacer={spacer}
|
|
146
|
-
ref={ref}
|
|
147
|
-
{...other}
|
|
148
|
-
>
|
|
149
|
-
<StyledInput
|
|
150
|
-
type="radio"
|
|
151
|
-
{...inputProps}
|
|
152
|
-
checked={checked}
|
|
153
|
-
disabled={disabled}
|
|
154
|
-
onChange={onChange}
|
|
155
|
-
/>
|
|
156
|
-
<RadioButtonIcon type={type} disabled={disabled} />
|
|
157
|
-
</RadioButtonContainer>
|
|
158
|
-
);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
const Label = styled.label`
|
|
162
|
-
display: flex;
|
|
163
|
-
position: relative;
|
|
164
|
-
width: fit-content;
|
|
165
|
-
font-size: 14px;
|
|
166
|
-
font-weight: 500;
|
|
167
|
-
line-height: 16px;
|
|
168
|
-
color: ${({ theme }) => theme.color.foreground.neutralBase};
|
|
169
|
-
align-self: center;
|
|
170
|
-
`;
|
|
171
|
-
|
|
172
|
-
const RadioButtonContainer = styled.span<{
|
|
173
|
-
spacer: boolean;
|
|
174
|
-
}>(
|
|
175
|
-
({ spacer }) => css`
|
|
176
|
-
display: inline-flex;
|
|
177
|
-
position: relative;
|
|
178
|
-
width: 16px;
|
|
179
|
-
height: 16px;
|
|
180
|
-
cursor: pointer;
|
|
181
|
-
margin-bottom: ${spacer ? "8px" : "0"};
|
|
182
|
-
`
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
const StyledInput = styled.input`
|
|
186
|
-
cursor: inherit;
|
|
187
|
-
position: absolute;
|
|
188
|
-
top: 0;
|
|
189
|
-
left: 0;
|
|
190
|
-
opacity: 0;
|
|
191
|
-
width: 16px;
|
|
192
|
-
height: 16px;
|
|
193
|
-
margin: 0;
|
|
194
|
-
padding: 0;
|
|
195
|
-
// input 컴포넌트는 보이지 않지만, 클릭이 가능하게 z-index를 설정합니다.
|
|
196
|
-
z-index: ${ZINDEX.inputBase};
|
|
197
|
-
`;
|
|
198
|
-
|
|
199
|
-
// default와 selected 구조가 유사하여 하나의 컴포넌트로 표현합니다.
|
|
200
|
-
const RadioButtonIcon = (props: {
|
|
201
|
-
type: RadioInputType;
|
|
202
|
-
disabled: boolean;
|
|
203
|
-
}) => {
|
|
204
|
-
const theme = useTheme();
|
|
205
|
-
return (
|
|
206
|
-
<svg
|
|
207
|
-
width="16"
|
|
208
|
-
height="16"
|
|
209
|
-
viewBox="0 0 16 16"
|
|
210
|
-
fill="none"
|
|
211
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
212
|
-
css={TYPE_TO_ICON_STYLE(theme, props.type, props.disabled)}
|
|
213
|
-
>
|
|
214
|
-
<path
|
|
215
|
-
d="M0.5 8C0.5 3.85786 3.85786 0.5 8 0.5C12.1421 0.5 15.5 3.85786 15.5 8C15.5 12.1421 12.1421 15.5 8 15.5C3.85786 15.5 0.5 12.1421 0.5 8Z"
|
|
216
|
-
fill="currentColor"
|
|
217
|
-
stroke="currentColor"
|
|
218
|
-
/>
|
|
219
|
-
{props.type === "selected" && (
|
|
220
|
-
<rect x="4" y="4" width="8" height="8" rx="4" fill="currentColor" />
|
|
221
|
-
)}
|
|
222
|
-
</svg>
|
|
223
|
-
);
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
export default RadioInput;
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @emotion/react */
|
|
2
|
-
import { css, SerializedStyles, Theme } from "@emotion/react";
|
|
3
|
-
import styled from "@emotion/styled";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { HOVER } from "../utils/hover";
|
|
6
|
-
|
|
7
|
-
export type SquareButtonColor = "danger" | "primary" | "secondary" | "icon";
|
|
8
|
-
|
|
9
|
-
export type SquareButtonSize = "large" | "medium" | "small" | "xsmall";
|
|
10
|
-
|
|
11
|
-
export interface SquareButtonProps {
|
|
12
|
-
className?: string;
|
|
13
|
-
component?: React.ElementType;
|
|
14
|
-
|
|
15
|
-
/** 비활성화 여부 */
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
|
|
18
|
-
/** 컴포넌트 색상 */
|
|
19
|
-
color: SquareButtonColor;
|
|
20
|
-
|
|
21
|
-
/** 컴포넌트 크기 */
|
|
22
|
-
size: SquareButtonSize;
|
|
23
|
-
|
|
24
|
-
/** 컴포넌트 내 표기될 아이콘 */
|
|
25
|
-
icon: React.ReactNode;
|
|
26
|
-
|
|
27
|
-
/** 컴포넌트 하단에 표기될 문자열 */
|
|
28
|
-
label?: string;
|
|
29
|
-
|
|
30
|
-
/** 전체 너비 유무 */
|
|
31
|
-
fullWidth?: boolean;
|
|
32
|
-
|
|
33
|
-
/** 버튼 클릭 시 호출될 콜백 함수 */
|
|
34
|
-
onClick?: () => void;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const COLOR_TO_BUTTON_STYLE = (theme: Theme, color: SquareButtonColor) =>
|
|
38
|
-
({
|
|
39
|
-
danger: css`
|
|
40
|
-
border: none;
|
|
41
|
-
background: ${theme.color.background.danger};
|
|
42
|
-
color: ${theme.color.foreground.neutralAlt};
|
|
43
|
-
|
|
44
|
-
${HOVER(css`
|
|
45
|
-
background: ${theme.color.background.dangerActive};
|
|
46
|
-
`)}
|
|
47
|
-
&:disabled {
|
|
48
|
-
background: ${theme.color.background.dangerDisabled};
|
|
49
|
-
}
|
|
50
|
-
`,
|
|
51
|
-
secondary: css`
|
|
52
|
-
background: ${theme.color.background.neutralAlt};
|
|
53
|
-
border: none;
|
|
54
|
-
color: ${theme.color.foreground.neutralBase};
|
|
55
|
-
|
|
56
|
-
${HOVER(css`
|
|
57
|
-
background: ${theme.color.background.neutralAltActive};
|
|
58
|
-
color: ${theme.color.foreground.neutralBase};
|
|
59
|
-
`)}
|
|
60
|
-
&:disabled {
|
|
61
|
-
background: ${theme.color.background.neutralAlt};
|
|
62
|
-
color: ${theme.color.foreground.neutralBaseDisabled};
|
|
63
|
-
}
|
|
64
|
-
`,
|
|
65
|
-
primary: css`
|
|
66
|
-
background: ${theme.color.background.primary};
|
|
67
|
-
border: none;
|
|
68
|
-
color: ${theme.color.foreground.neutralAlt};
|
|
69
|
-
|
|
70
|
-
${HOVER(css`
|
|
71
|
-
background: ${theme.color.background.primaryActive};
|
|
72
|
-
`)}
|
|
73
|
-
&:disabled {
|
|
74
|
-
background: ${theme.color.background.primaryDisabled};
|
|
75
|
-
}
|
|
76
|
-
`,
|
|
77
|
-
icon: css`
|
|
78
|
-
background: none;
|
|
79
|
-
border: none;
|
|
80
|
-
color: ${theme.color.foreground.neutralBase};
|
|
81
|
-
|
|
82
|
-
${HOVER(css`
|
|
83
|
-
background: ${theme.color.background.neutralAltActive};
|
|
84
|
-
color: ${theme.color.foreground.neutralBase};
|
|
85
|
-
`)}
|
|
86
|
-
&:disabled {
|
|
87
|
-
background: none;
|
|
88
|
-
color: ${theme.color.foreground.neutralBaseDisabled};
|
|
89
|
-
}
|
|
90
|
-
`,
|
|
91
|
-
}[color]);
|
|
92
|
-
|
|
93
|
-
const SIZE_TO_BUTTON_STYLE: { [K in SquareButtonSize]: SerializedStyles } = {
|
|
94
|
-
large: css`
|
|
95
|
-
width: 56px;
|
|
96
|
-
height: 56px;
|
|
97
|
-
padding: 16px;
|
|
98
|
-
|
|
99
|
-
svg {
|
|
100
|
-
width: 24px;
|
|
101
|
-
height: 24px;
|
|
102
|
-
}
|
|
103
|
-
`,
|
|
104
|
-
medium: css`
|
|
105
|
-
width: 48px;
|
|
106
|
-
height: 48px;
|
|
107
|
-
padding: 14px;
|
|
108
|
-
|
|
109
|
-
svg {
|
|
110
|
-
width: 20px;
|
|
111
|
-
height: 20px;
|
|
112
|
-
}
|
|
113
|
-
`,
|
|
114
|
-
small: css`
|
|
115
|
-
width: 36px;
|
|
116
|
-
height: 36px;
|
|
117
|
-
padding: 10px;
|
|
118
|
-
|
|
119
|
-
svg {
|
|
120
|
-
width: 16px;
|
|
121
|
-
height: 16px;
|
|
122
|
-
}
|
|
123
|
-
`,
|
|
124
|
-
xsmall: css`
|
|
125
|
-
width: 24px;
|
|
126
|
-
height: 24px;
|
|
127
|
-
padding: 6px;
|
|
128
|
-
|
|
129
|
-
svg {
|
|
130
|
-
width: 12px;
|
|
131
|
-
height: 12px;
|
|
132
|
-
}
|
|
133
|
-
`,
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const SIZE_TO_LABEL_STYLE: { [K in SquareButtonSize]: SerializedStyles } = {
|
|
137
|
-
large: css`
|
|
138
|
-
font-size: 18px;
|
|
139
|
-
line-height: 28px;
|
|
140
|
-
`,
|
|
141
|
-
medium: css`
|
|
142
|
-
font-size: 18px;
|
|
143
|
-
line-height: 28px;
|
|
144
|
-
`,
|
|
145
|
-
small: css`
|
|
146
|
-
font-size: 18px;
|
|
147
|
-
line-height: 28px;
|
|
148
|
-
`,
|
|
149
|
-
xsmall: css`
|
|
150
|
-
font-size: 14px;
|
|
151
|
-
line-height: 22px;
|
|
152
|
-
`,
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=22-374&t=kTLv3t86qtGalHSS-0)
|
|
157
|
-
*/
|
|
158
|
-
const SquareButton = React.forwardRef<any, SquareButtonProps>(
|
|
159
|
-
(props, ref): React.ReactElement => {
|
|
160
|
-
const {
|
|
161
|
-
className,
|
|
162
|
-
component: Component = "span",
|
|
163
|
-
disabled,
|
|
164
|
-
color,
|
|
165
|
-
size,
|
|
166
|
-
icon,
|
|
167
|
-
label,
|
|
168
|
-
fullWidth,
|
|
169
|
-
onClick,
|
|
170
|
-
...other
|
|
171
|
-
} = props;
|
|
172
|
-
return (
|
|
173
|
-
<Component
|
|
174
|
-
{...other}
|
|
175
|
-
ref={ref}
|
|
176
|
-
className={className}
|
|
177
|
-
css={css`
|
|
178
|
-
display: flex;
|
|
179
|
-
flex-direction: column;
|
|
180
|
-
align-items: center;
|
|
181
|
-
gap: 8px;
|
|
182
|
-
|
|
183
|
-
width: ${fullWidth ? "100%" : "fit-content"};
|
|
184
|
-
`}
|
|
185
|
-
>
|
|
186
|
-
<Button
|
|
187
|
-
color={color}
|
|
188
|
-
size={size}
|
|
189
|
-
disabled={disabled}
|
|
190
|
-
fullWidth={fullWidth}
|
|
191
|
-
onClick={onClick}
|
|
192
|
-
>
|
|
193
|
-
{icon}
|
|
194
|
-
</Button>
|
|
195
|
-
{label && (
|
|
196
|
-
<Label disabled={disabled} size={size}>
|
|
197
|
-
{label}
|
|
198
|
-
</Label>
|
|
199
|
-
)}
|
|
200
|
-
</Component>
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
const Button = styled.button<{
|
|
206
|
-
color: SquareButtonColor;
|
|
207
|
-
size: SquareButtonSize;
|
|
208
|
-
fullWidth?: boolean;
|
|
209
|
-
}>`
|
|
210
|
-
border-radius: 8px;
|
|
211
|
-
cursor: pointer;
|
|
212
|
-
&:disabled {
|
|
213
|
-
cursor: default;
|
|
214
|
-
}
|
|
215
|
-
${({ theme, color }) => COLOR_TO_BUTTON_STYLE(theme, color)}
|
|
216
|
-
${({ size }) => SIZE_TO_BUTTON_STYLE[size]}
|
|
217
|
-
${({ fullWidth }) => fullWidth && "width: 100%;"}
|
|
218
|
-
`;
|
|
219
|
-
|
|
220
|
-
const Label = styled.span<{ disabled?: boolean; size: SquareButtonSize }>`
|
|
221
|
-
font-weight: 400;
|
|
222
|
-
color: ${({ theme, disabled }) =>
|
|
223
|
-
disabled
|
|
224
|
-
? theme.color.foreground.neutralBaseDisabled
|
|
225
|
-
: theme.color.foreground.neutralBase};
|
|
226
|
-
${({ size }) => SIZE_TO_LABEL_STYLE[size]}
|
|
227
|
-
`;
|
|
228
|
-
|
|
229
|
-
export default SquareButton;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @emotion/react */
|
|
2
|
-
import styled from "@emotion/styled";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { Switch as MuiSwitch } from "@mui/material";
|
|
5
|
-
import { css } from "@emotion/react";
|
|
6
|
-
|
|
7
|
-
export type SwitchSize = "small" | "large";
|
|
8
|
-
|
|
9
|
-
export interface SwitchProps {
|
|
10
|
-
className?: string;
|
|
11
|
-
// component: React.ElementType; // MUI Switch에서는 component를 지원하지 않습니다.
|
|
12
|
-
|
|
13
|
-
/** 스위치 체크 상태 여부 */
|
|
14
|
-
checked: boolean;
|
|
15
|
-
|
|
16
|
-
/** 스위치 활성화 여부
|
|
17
|
-
* @default false */
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
|
|
20
|
-
/** 스위치 크기 */
|
|
21
|
-
size: SwitchSize;
|
|
22
|
-
|
|
23
|
-
/** 스위치 상태 변경 시 호출될 콜백 함수 */
|
|
24
|
-
onChange?: (
|
|
25
|
-
event: React.ChangeEvent<HTMLInputElement>,
|
|
26
|
-
checked: boolean
|
|
27
|
-
) => void;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=36-1577&t=9sDLb4XIOdmF2VMc-0)
|
|
32
|
-
*/
|
|
33
|
-
const Switch = React.forwardRef<any, SwitchProps>(
|
|
34
|
-
(props, ref): React.ReactElement => {
|
|
35
|
-
const {
|
|
36
|
-
className,
|
|
37
|
-
checked,
|
|
38
|
-
disabled = false,
|
|
39
|
-
size,
|
|
40
|
-
onChange,
|
|
41
|
-
...other
|
|
42
|
-
} = props;
|
|
43
|
-
return (
|
|
44
|
-
<StyledSwitch
|
|
45
|
-
{...other}
|
|
46
|
-
ref={ref}
|
|
47
|
-
className={className}
|
|
48
|
-
checked={checked}
|
|
49
|
-
disabled={disabled}
|
|
50
|
-
onChange={onChange}
|
|
51
|
-
switchSize={size}
|
|
52
|
-
></StyledSwitch>
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const SIZE_TO_SWTICH_SIZE: {
|
|
58
|
-
[K in SwitchSize]: {
|
|
59
|
-
width: string;
|
|
60
|
-
height: string;
|
|
61
|
-
translateX: string;
|
|
62
|
-
thumbSize: string;
|
|
63
|
-
};
|
|
64
|
-
} = {
|
|
65
|
-
large: {
|
|
66
|
-
width: "44px",
|
|
67
|
-
height: "22px",
|
|
68
|
-
translateX: "22px",
|
|
69
|
-
thumbSize: "18px",
|
|
70
|
-
},
|
|
71
|
-
small: {
|
|
72
|
-
width: "28px",
|
|
73
|
-
height: "16px",
|
|
74
|
-
translateX: "12px",
|
|
75
|
-
thumbSize: "12px",
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
const StyledSwitch = styled(MuiSwitch)<{ switchSize: SwitchSize }>(
|
|
80
|
-
({ theme, switchSize }) => css`
|
|
81
|
-
width: ${SIZE_TO_SWTICH_SIZE[switchSize].width};
|
|
82
|
-
height: ${SIZE_TO_SWTICH_SIZE[switchSize].height};
|
|
83
|
-
padding: 0; // 기존 Mui padding 속성 override
|
|
84
|
-
& .MuiSwitch-switchBase {
|
|
85
|
-
padding: 2px;
|
|
86
|
-
&.Mui-checked {
|
|
87
|
-
transform: translateX(${SIZE_TO_SWTICH_SIZE[switchSize].translateX});
|
|
88
|
-
color: ${theme.color.foreground.neutralAlt};
|
|
89
|
-
& + .MuiSwitch-track {
|
|
90
|
-
opacity: 1;
|
|
91
|
-
background-color: ${theme.color.background.primary};
|
|
92
|
-
}
|
|
93
|
-
&.Mui-disabled + .MuiSwitch-track {
|
|
94
|
-
opacity: 1;
|
|
95
|
-
background-color: ${theme.color.background.primaryDisabled};
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
&.Mui-disabled + .MuiSwitch-track {
|
|
99
|
-
opacity: 1;
|
|
100
|
-
background-color: ${theme.color.background.neutralAltDisabled};
|
|
101
|
-
}
|
|
102
|
-
&:hover {
|
|
103
|
-
background-color: inherit; // 기존 Mui hover 속성 override
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
.Mui-disabled .MuiSwitch-thumb {
|
|
107
|
-
filter: none;
|
|
108
|
-
box-shadow: none;
|
|
109
|
-
background-color: ${theme.color.foreground.neutralAltDisabled};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.MuiSwitch-thumb {
|
|
113
|
-
box-shadow: none;
|
|
114
|
-
filter: drop-shadow(0px 2px 4px rgba(0, 35, 11, 0.2));
|
|
115
|
-
width: ${SIZE_TO_SWTICH_SIZE[switchSize].thumbSize};
|
|
116
|
-
height: ${SIZE_TO_SWTICH_SIZE[switchSize].thumbSize};
|
|
117
|
-
border-radius: 77px;
|
|
118
|
-
transition: width 300ms;
|
|
119
|
-
}
|
|
120
|
-
.MuiSwitch-track {
|
|
121
|
-
border-radius: 16px;
|
|
122
|
-
opacity: 1;
|
|
123
|
-
background-color: ${theme.color.background.neutralAltActive};
|
|
124
|
-
box-sizing: border-box;
|
|
125
|
-
}
|
|
126
|
-
`
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
export default Switch;
|