@team-monolith/cds 0.1.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.
Files changed (165) hide show
  1. package/README.md +46 -0
  2. package/dist/CodleDesignSystemProvider.d.ts +5 -0
  3. package/dist/CodleDesignSystemProvider.js +96 -0
  4. package/dist/components/AlertDialog/AlertDialog.d.ts +14 -0
  5. package/dist/components/AlertDialog/AlertDialog.js +45 -0
  6. package/dist/components/AlertDialog/AlertDialogActions.d.ts +8 -0
  7. package/dist/components/AlertDialog/AlertDialogActions.js +35 -0
  8. package/dist/components/AlertDialog/AlertDialogContent.d.ts +8 -0
  9. package/dist/components/AlertDialog/AlertDialogContent.js +36 -0
  10. package/dist/components/AlertDialog/AlertDialogTitle.d.ts +13 -0
  11. package/dist/components/AlertDialog/AlertDialogTitle.js +38 -0
  12. package/dist/components/AlertDialog/index.d.ts +4 -0
  13. package/dist/components/AlertDialog/index.js +4 -0
  14. package/dist/components/Banner.d.ts +29 -0
  15. package/dist/components/Banner.js +65 -0
  16. package/dist/components/Button.d.ts +26 -0
  17. package/dist/components/Button.js +72 -0
  18. package/dist/components/CheckboxInput.d.ts +27 -0
  19. package/dist/components/CheckboxInput.js +77 -0
  20. package/dist/components/Input.d.ts +17 -0
  21. package/dist/components/Input.js +72 -0
  22. package/dist/components/InputBase.d.ts +42 -0
  23. package/dist/components/InputBase.js +52 -0
  24. package/dist/components/Pagination.d.ts +27 -0
  25. package/dist/components/Pagination.js +32 -0
  26. package/dist/components/PinInput.d.ts +36 -0
  27. package/dist/components/PinInput.js +154 -0
  28. package/dist/components/RadioInput.d.ts +23 -0
  29. package/dist/components/RadioInput.js +78 -0
  30. package/dist/components/SquareButton.d.ts +26 -0
  31. package/dist/components/SquareButton.js +80 -0
  32. package/dist/components/Switch.d.ts +19 -0
  33. package/dist/components/Switch.js +59 -0
  34. package/dist/components/Tag.d.ts +21 -0
  35. package/dist/components/Tag.js +61 -0
  36. package/dist/components/Tooltip.d.ts +26 -0
  37. package/dist/components/Tooltip.js +50 -0
  38. package/dist/foundation/color.d.ts +75 -0
  39. package/dist/foundation/color.js +75 -0
  40. package/dist/foundation/shadows.d.ts +9 -0
  41. package/dist/foundation/shadows.js +10 -0
  42. package/dist/icons/arrows.d.ts +16 -0
  43. package/dist/icons/arrows.js +17 -0
  44. package/dist/icons/brand.d.ts +4 -0
  45. package/dist/icons/brand.js +13 -0
  46. package/dist/icons/map.d.ts +4 -0
  47. package/dist/icons/map.js +13 -0
  48. package/dist/icons/system.d.ts +25 -0
  49. package/dist/icons/system.js +20 -0
  50. package/dist/index.d.ts +2 -0
  51. package/dist/index.js +2 -0
  52. package/dist/patterns/Dropdown/Dropdown.d.ts +27 -0
  53. package/dist/patterns/Dropdown/Dropdown.js +41 -0
  54. package/dist/patterns/Dropdown/DropdownItem.d.ts +42 -0
  55. package/dist/patterns/Dropdown/DropdownItem.js +89 -0
  56. package/dist/patterns/Dropdown/DropdownMenu.d.ts +30 -0
  57. package/dist/patterns/Dropdown/DropdownMenu.js +85 -0
  58. package/dist/patterns/Dropdown/index.d.ts +2 -0
  59. package/dist/patterns/Dropdown/index.js +2 -0
  60. package/dist/patterns/EmptyState/EmptyState.d.ts +16 -0
  61. package/dist/patterns/EmptyState/EmptyState.js +36 -0
  62. package/dist/patterns/EmptyState/index.d.ts +2 -0
  63. package/dist/patterns/EmptyState/index.js +2 -0
  64. package/dist/patterns/Grid/EnhancedTableCell.d.ts +9 -0
  65. package/dist/patterns/Grid/EnhancedTableCell.js +122 -0
  66. package/dist/patterns/Grid/Grid.d.ts +51 -0
  67. package/dist/patterns/Grid/Grid.js +140 -0
  68. package/dist/patterns/Grid/index.d.ts +3 -0
  69. package/dist/patterns/Grid/index.js +2 -0
  70. package/dist/patterns/SegmentedControl/SegmentedControlButton.d.ts +8 -0
  71. package/dist/patterns/SegmentedControl/SegmentedControlButton.js +41 -0
  72. package/dist/patterns/SegmentedControl/SegmentedControlGroup.d.ts +26 -0
  73. package/dist/patterns/SegmentedControl/SegmentedControlGroup.js +50 -0
  74. package/dist/patterns/SegmentedControl/SegmentedControlGroupPropsContext.d.ts +5 -0
  75. package/dist/patterns/SegmentedControl/SegmentedControlGroupPropsContext.js +5 -0
  76. package/dist/patterns/SegmentedControl/SegmentedControlSquareButton.d.ts +8 -0
  77. package/dist/patterns/SegmentedControl/SegmentedControlSquareButton.js +45 -0
  78. package/dist/patterns/SegmentedControl/index.d.ts +3 -0
  79. package/dist/patterns/SegmentedControl/index.js +3 -0
  80. package/dist/patterns/Table/Table.d.ts +16 -0
  81. package/dist/patterns/Table/Table.js +33 -0
  82. package/dist/patterns/Table/TableBody.d.ts +8 -0
  83. package/dist/patterns/Table/TableBody.js +26 -0
  84. package/dist/patterns/Table/TableCell.d.ts +15 -0
  85. package/dist/patterns/Table/TableCell.js +78 -0
  86. package/dist/patterns/Table/TableHead.d.ts +8 -0
  87. package/dist/patterns/Table/TableHead.js +26 -0
  88. package/dist/patterns/Table/TableRow.d.ts +12 -0
  89. package/dist/patterns/Table/TableRow.js +29 -0
  90. package/dist/patterns/Table/TableSizeContext.d.ts +7 -0
  91. package/dist/patterns/Table/TableSizeContext.js +3 -0
  92. package/dist/patterns/Table/TableVariantContext.d.ts +6 -0
  93. package/dist/patterns/Table/TableVariantContext.js +3 -0
  94. package/dist/patterns/Table/index.d.ts +7 -0
  95. package/dist/patterns/Table/index.js +6 -0
  96. package/dist/utils/hover.d.ts +3 -0
  97. package/dist/utils/hover.js +14 -0
  98. package/dist/utils/reset.d.ts +2 -0
  99. package/dist/utils/reset.js +8 -0
  100. package/dist/utils/zIndex.d.ts +3 -0
  101. package/dist/utils/zIndex.js +3 -0
  102. package/package.json +52 -0
  103. package/public/favicon.ico +0 -0
  104. package/public/index.html +43 -0
  105. package/public/logo192.png +0 -0
  106. package/public/logo512.png +0 -0
  107. package/public/manifest.json +25 -0
  108. package/public/robots.txt +3 -0
  109. package/src/App.tsx +7 -0
  110. package/src/cds/CodleDesignSystemProvider.tsx +93 -0
  111. package/src/cds/README.md +23 -0
  112. package/src/cds/components/AlertDialog/AlertDialog.tsx +101 -0
  113. package/src/cds/components/AlertDialog/AlertDialogActions.tsx +34 -0
  114. package/src/cds/components/AlertDialog/AlertDialogContent.tsx +38 -0
  115. package/src/cds/components/AlertDialog/AlertDialogTitle.tsx +63 -0
  116. package/src/cds/components/AlertDialog/index.tsx +4 -0
  117. package/src/cds/components/Banner.tsx +176 -0
  118. package/src/cds/components/Button.tsx +239 -0
  119. package/src/cds/components/CheckboxInput.tsx +270 -0
  120. package/src/cds/components/Input.tsx +166 -0
  121. package/src/cds/components/InputBase.tsx +226 -0
  122. package/src/cds/components/Pagination.tsx +99 -0
  123. package/src/cds/components/PinInput.tsx +322 -0
  124. package/src/cds/components/RadioInput.tsx +226 -0
  125. package/src/cds/components/SquareButton.tsx +229 -0
  126. package/src/cds/components/Switch.tsx +129 -0
  127. package/src/cds/components/Tag.tsx +155 -0
  128. package/src/cds/components/Tooltip.tsx +104 -0
  129. package/src/cds/emotion.d.ts +70 -0
  130. package/src/cds/foundation/color.ts +83 -0
  131. package/src/cds/foundation/shadows.ts +17 -0
  132. package/src/cds/icons/arrows.tsx +61 -0
  133. package/src/cds/icons/brand.tsx +13 -0
  134. package/src/cds/icons/map.tsx +14 -0
  135. package/src/cds/icons/system.tsx +113 -0
  136. package/src/cds/index.ts +3 -0
  137. package/src/cds/patterns/Dropdown/Dropdown.tsx +111 -0
  138. package/src/cds/patterns/Dropdown/DropdownItem.tsx +203 -0
  139. package/src/cds/patterns/Dropdown/DropdownMenu.tsx +176 -0
  140. package/src/cds/patterns/Dropdown/index.tsx +2 -0
  141. package/src/cds/patterns/EmptyState/EmptyState.tsx +91 -0
  142. package/src/cds/patterns/EmptyState/empty-state-icon.svg +36 -0
  143. package/src/cds/patterns/EmptyState/index.tsx +2 -0
  144. package/src/cds/patterns/Grid/EnhancedTableCell.tsx +180 -0
  145. package/src/cds/patterns/Grid/Grid.tsx +360 -0
  146. package/src/cds/patterns/Grid/index.tsx +4 -0
  147. package/src/cds/patterns/SegmentedControl/SegmentedControlButton.tsx +41 -0
  148. package/src/cds/patterns/SegmentedControl/SegmentedControlGroup.tsx +81 -0
  149. package/src/cds/patterns/SegmentedControl/SegmentedControlGroupPropsContext.tsx +9 -0
  150. package/src/cds/patterns/SegmentedControl/SegmentedControlSquareButton.tsx +51 -0
  151. package/src/cds/patterns/SegmentedControl/index.ts +3 -0
  152. package/src/cds/patterns/Table/Table.tsx +56 -0
  153. package/src/cds/patterns/Table/TableBody.tsx +30 -0
  154. package/src/cds/patterns/Table/TableCell.tsx +242 -0
  155. package/src/cds/patterns/Table/TableHead.tsx +30 -0
  156. package/src/cds/patterns/Table/TableRow.tsx +54 -0
  157. package/src/cds/patterns/Table/TableSizeContext.tsx +10 -0
  158. package/src/cds/patterns/Table/TableVariantContext.tsx +9 -0
  159. package/src/cds/patterns/Table/index.tsx +15 -0
  160. package/src/cds/utils/hover.tsx +24 -0
  161. package/src/cds/utils/reset.tsx +19 -0
  162. package/src/cds/utils/zIndex.tsx +3 -0
  163. package/src/index.tsx +10 -0
  164. package/src/react-app-env.d.ts +1 -0
  165. package/tsconfig.json +22 -0
@@ -0,0 +1,229 @@
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;
@@ -0,0 +1,129 @@
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;
@@ -0,0 +1,155 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { css, SerializedStyles } from "@emotion/react";
3
+ import styled from "@emotion/styled";
4
+ import React from "react";
5
+ import { CloseFillIcon } from "../icons/system";
6
+ import { Theme, useTheme } from "@emotion/react";
7
+
8
+ export type TagColor =
9
+ | "default"
10
+ | "red"
11
+ | "teal"
12
+ | "orange"
13
+ | "blue"
14
+ | "green"
15
+ | "yellow"
16
+ | "black";
17
+
18
+ export interface TagProps {
19
+ className?: string;
20
+ component?: React.ElementType;
21
+
22
+ /** 컴포넌트 내 표기될 문자열 */
23
+ label: string;
24
+
25
+ /** 컴포넌트 좌측에 표기될 아이콘 */
26
+ icon?: React.ReactNode;
27
+
28
+ /** 컴포넌트의 색상 */
29
+ color?: TagColor;
30
+
31
+ /** 컴포넌트 우측에 표기될 닫기 버튼 유무 */
32
+ close: boolean;
33
+
34
+ /** 닫기 버튼 클릭 시 호출될 콜백 함수 */
35
+ onClick?: () => void;
36
+ }
37
+
38
+ const COLOR_TO_STYLE = (theme: Theme, color: TagColor): SerializedStyles =>
39
+ ({
40
+ default: css`
41
+ box-sizing: border-box;
42
+ background: ${theme.color.container.marbleContainer};
43
+ border: 1px solid ${theme.color.container.marbleOnContainer};
44
+ color: ${theme.color.container.marbleOnContainer};
45
+ `,
46
+ red: css`
47
+ box-sizing: border-box;
48
+ background: ${theme.color.container.dangerContainer};
49
+ border: 1px solid ${theme.color.container.dangerOnContainer};
50
+ color: ${theme.color.container.dangerOnContainer};
51
+ `,
52
+ teal: css`
53
+ box-sizing: border-box;
54
+ background: ${theme.color.container.infoContainer};
55
+ border: 1px solid ${theme.color.container.infoOnContainer};
56
+ color: ${theme.color.container.infoOnContainer};
57
+ `,
58
+ orange: css`
59
+ box-sizing: border-box;
60
+ background: ${theme.color.container.secondaryContainer};
61
+ border: 1px solid ${theme.color.container.secondaryOnContainer};
62
+ color: ${theme.color.container.secondaryOnContainer};
63
+ `,
64
+ blue: css`
65
+ box-sizing: border-box;
66
+ background: ${theme.color.container.primaryContainer};
67
+ border: 1px solid ${theme.color.container.primaryOnContainer};
68
+ color: ${theme.color.container.primaryOnContainer};
69
+ `,
70
+ green: css`
71
+ box-sizing: border-box;
72
+ background: ${theme.color.container.successContainer};
73
+ border: 1px solid ${theme.color.container.successOnContainer};
74
+ color: ${theme.color.container.successOnContainer};
75
+ `,
76
+ yellow: css`
77
+ box-sizing: border-box;
78
+ background: ${theme.color.container.warningContainer};
79
+ border: 1px solid ${theme.color.container.warningOnContainer};
80
+ color: ${theme.color.container.warningOnContainer};
81
+ `,
82
+ black: css`
83
+ background: ${theme.color.container.obsidianContainer};
84
+ color: ${theme.color.container.obsidianOnContainer};
85
+ `,
86
+ }[color]);
87
+
88
+ /**
89
+ * [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=42-869&t=HZXCHP0r0tbvMA6v-0)
90
+ */
91
+ const Tag = React.forwardRef<any, TagProps>(
92
+ (props, ref): React.ReactElement => {
93
+ const {
94
+ className,
95
+ component: Component = "span",
96
+ label,
97
+ icon,
98
+ color = "default",
99
+ close,
100
+ onClick,
101
+ ...other
102
+ } = props;
103
+ const theme = useTheme();
104
+ return (
105
+ <Component
106
+ {...other}
107
+ ref={ref}
108
+ className={className}
109
+ css={[
110
+ css`
111
+ box-sizing: border-box;
112
+ display: flex;
113
+ // flex가 화면 전체로 확장되지 않고 내부의 아이콘과 텍스트만 포함한다.
114
+ padding: 1px 8px;
115
+ align-items: center;
116
+ gap: 3px;
117
+ width: fit-content;
118
+ border-radius: 8px;
119
+
120
+ svg {
121
+ width: 14px;
122
+ height: 14px;
123
+ }
124
+ `,
125
+ COLOR_TO_STYLE(theme, color),
126
+ close
127
+ ? css`
128
+ cursor: pointer;
129
+ `
130
+ : undefined,
131
+ ]}
132
+ onClick={onClick}
133
+ >
134
+ {icon}
135
+ <span
136
+ css={css`
137
+ font-weight: 400;
138
+ font-size: 12px;
139
+ line-height: 20px;
140
+ `}
141
+ >
142
+ {label}
143
+ </span>
144
+ {close && <StyledCloseFillIcon />}
145
+ </Component>
146
+ );
147
+ }
148
+ );
149
+
150
+ const StyledCloseFillIcon = styled(CloseFillIcon)`
151
+ width: 10px;
152
+ height: 10px;
153
+ `;
154
+
155
+ export default Tag;
@@ -0,0 +1,104 @@
1
+ /** @jsxImportSource @emotion/react */
2
+ import { css } from "@emotion/react";
3
+ import styled from "@emotion/styled";
4
+ import React from "react";
5
+ import {
6
+ Tooltip as MuiTooltip,
7
+ TooltipProps as MuiTooltipProps,
8
+ } from "@mui/material";
9
+
10
+ export interface TooltipProps {
11
+ className?: string;
12
+ // MUI Tooltip의 component 속성이 CDS에서 기대하는 속성과 다르게 구현되어있고,
13
+ // Tooltip 컴포넌트에서 component 속성을 사용하는 경우가 많지 않을 것으로 판단,
14
+ // CDS에서 Tooltip의 component 속성을 구현하지 않습니다.
15
+ // component?: React.ElementType;
16
+
17
+ /** 툴팁에 표시될 제목 텍스트 */
18
+ title?: string;
19
+
20
+ /** 툴팁에 표시될 text 영역 값 */
21
+ text: React.ReactNode;
22
+
23
+ /** `true` 값일때 Tooltip을 오픈합니다. */
24
+ open?: boolean;
25
+
26
+ /** Tooltip이 오픈될 때 호출되는 함수. */
27
+ onOpen?: (event: React.SyntheticEvent) => void;
28
+
29
+ /** Tooltip이 닫힐 때 호출되는 함수. */
30
+ onClose?: (event: React.SyntheticEvent | Event) => void;
31
+
32
+ /**
33
+ * Tooltip placement.
34
+ * @default bottom
35
+ */
36
+ placement?:
37
+ | "bottom-end"
38
+ | "bottom-start"
39
+ | "bottom"
40
+ | "left-end"
41
+ | "left-start"
42
+ | "left"
43
+ | "right-end"
44
+ | "right-start"
45
+ | "right"
46
+ | "top-end"
47
+ | "top-start"
48
+ | "top";
49
+
50
+ /** 툴팁을 표시할 객체입니다. ref를 props로 받을 수 있어야합니다. */
51
+ children: React.ReactElement<any, any>;
52
+ }
53
+
54
+ /**
55
+ * [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=172-626&t=aFkKTFgWq2xFFGC5-0)
56
+ */
57
+ const Tooltip = React.forwardRef<any, TooltipProps>(
58
+ (props, ref): React.ReactElement => {
59
+ const { title, text, children, ...restProps } = props;
60
+ return (
61
+ <StyledTooltip
62
+ ref={ref}
63
+ title={
64
+ <>
65
+ {title && <TitleDiv>{title}</TitleDiv>}
66
+ {text}
67
+ </>
68
+ }
69
+ {...restProps}
70
+ >
71
+ {children}
72
+ </StyledTooltip>
73
+ );
74
+ }
75
+ );
76
+
77
+ // https://mui.com/material-ui/react-tooltip/#customization
78
+ const StyledTooltip = styled(({ className, ...props }: MuiTooltipProps) => (
79
+ <MuiTooltip {...props} classes={{ popper: className }} />
80
+ ))(
81
+ ({ theme }) => css`
82
+ .MuiTooltip-tooltip {
83
+ background: ${theme.color.foreground.neutralBase};
84
+ border-radius: 8px;
85
+ padding: 6px 10px;
86
+
87
+ display: flex;
88
+ flex-direction: column;
89
+ gap: 2px;
90
+
91
+ color: ${theme.color.background.neutralBase};
92
+ font-style: normal;
93
+ font-weight: 400;
94
+ font-size: 14px;
95
+ line-height: 22px;
96
+ }
97
+ `
98
+ );
99
+
100
+ const TitleDiv = styled.div`
101
+ font-weight: 700;
102
+ `;
103
+
104
+ export default Tooltip;
@@ -0,0 +1,70 @@
1
+ import "@emotion/react";
2
+
3
+ interface CodleColors {
4
+ background: {
5
+ neutralBase: string;
6
+ neutralAlt: string;
7
+ neutralAltActive: string;
8
+ neutralAltDisabled: string;
9
+ primary: string;
10
+ primaryActive: string;
11
+ primaryDisabled: string;
12
+ secondary: string;
13
+ secondaryActive: string;
14
+ secondaryDisabled: string;
15
+ danger: string;
16
+ dangerActive: string;
17
+ dangerDisabled: string;
18
+ success: string;
19
+ successActive: string;
20
+ successDisabled: string;
21
+ info: string;
22
+ infoActive: string;
23
+ infoDisabled: string;
24
+ warning: string;
25
+ warningActive: string;
26
+ warningDisabled: string;
27
+ };
28
+ foreground: {
29
+ neutralBase: string;
30
+ neutralBaseDisabled: string;
31
+ neutralAlt: string;
32
+ neutralAltDisabled: string;
33
+ primary: string;
34
+ primaryDisabled: string;
35
+ secondary: string;
36
+ secondaryDisabled: string;
37
+ danger: string;
38
+ dangerDisabled: string;
39
+ success: string;
40
+ successDisabled: string;
41
+ info: string;
42
+ infoDisabled: string;
43
+ warning: string;
44
+ warningDisabled: string;
45
+ };
46
+ container: {
47
+ primaryContainer: string;
48
+ primaryOnContainer: string;
49
+ secondaryContainer: string;
50
+ secondaryOnContainer: string;
51
+ dangerContainer: string;
52
+ dangerOnContainer: string;
53
+ successContainer: string;
54
+ successOnContainer: string;
55
+ infoContainer: string;
56
+ infoOnContainer: string;
57
+ warningContainer: string;
58
+ warningOnContainer: string;
59
+ obsidianContainer: string;
60
+ obsidianOnContainer: string;
61
+ marbleContainer: string;
62
+ marbleOnContainer: string;
63
+ };
64
+ }
65
+
66
+ declare module "@emotion/react" {
67
+ export interface Theme {
68
+ color: CodleColors;
69
+ }
70
+ }