@team-monolith/cds 1.19.1 → 1.20.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.
@@ -0,0 +1,33 @@
1
+ import { PolymorphicProps } from "@mui/base";
2
+ import React from "react";
3
+ export type SwitchButtonColor = "grey" | "white" | "none";
4
+ export type SwitchButtonSize = "medium" | "xsmall";
5
+ export interface SwitchButtonOwnProps<RootComponentType extends React.ElementType> {
6
+ className?: string;
7
+ component?: RootComponentType;
8
+ /** 스위치 버튼 색상 */
9
+ color: SwitchButtonColor;
10
+ /** 스위치 버튼 크기 */
11
+ size: SwitchButtonSize;
12
+ /** on/off status를 나타냅니다. */
13
+ isOn: boolean;
14
+ /** on 일때의 아이콘 */
15
+ onIcon: React.ReactNode;
16
+ /** off 일때의 아이콘 */
17
+ offIcon: React.ReactNode;
18
+ /** 아이콘 오른쪽에 나타낼 숫자. 전달하지 않으면 나타나지 않습니다. */
19
+ count?: number;
20
+ /** on/off 변경시 호출되는 콜백 함수 */
21
+ onChange: (isOn: boolean) => void;
22
+ }
23
+ export type SwitchButtonProps<RootComponentType extends React.ElementType = SwitchButtonTypeMap["defaultComponent"]> = PolymorphicProps<SwitchButtonTypeMap<RootComponentType>, RootComponentType>;
24
+ export interface SwitchButtonTypeMap<RootComponentType extends React.ElementType = "button"> {
25
+ props: SwitchButtonOwnProps<RootComponentType>;
26
+ defaultComponent: RootComponentType;
27
+ }
28
+ type SwitchButtonComponent = <RootComponentType extends React.ElementType = "button">(props: SwitchButtonProps<RootComponentType>) => React.ReactElement | null;
29
+ /**
30
+ * [피그마](https://www.figma.com/file/CxpgZcJFoRPWEZyx5RC0tq/Framework-System?node-id=766%3A11274&mode=dev)
31
+ */
32
+ declare const SwitchButton: SwitchButtonComponent;
33
+ export default SwitchButton;
@@ -0,0 +1,117 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
13
+ /** @jsxImportSource @emotion/react */
14
+ import { css, useTheme } from "@emotion/react";
15
+ import { HOVER } from "../utils/hover";
16
+ import React from "react";
17
+ import styled from "@emotion/styled";
18
+ const COLOR_TO_SWITCH_BUTTON_STYLE = (theme, color, isOn) => ({
19
+ grey: css `
20
+ ${isOn
21
+ ? css `
22
+ background: ${theme.color.background.neutralAltActive};
23
+ opacity: 0.6;
24
+ `
25
+ : css `
26
+ background: ${theme.color.background.neutralAlt};
27
+ opacity: 0.6;
28
+ ${HOVER(css `
29
+ opacity: 1;
30
+ `)}
31
+ `}
32
+ `,
33
+ white: css `
34
+ ${isOn
35
+ ? css `
36
+ background: ${theme.color.background.neutralAlt};
37
+ opacity: 0.6;
38
+ `
39
+ : css `
40
+ background: ${theme.color.background.neutralBase};
41
+ opacity: 0.6;
42
+ ${HOVER(css `
43
+ opacity: 1;
44
+ `)}
45
+ `}
46
+ `,
47
+ none: css `
48
+ ${isOn
49
+ ? css `
50
+ background: ${theme.color.background.neutralAlt};
51
+ opacity: 0.6;
52
+ `
53
+ : css `
54
+ background: none;
55
+ opacity: 0.6;
56
+ ${HOVER(css `
57
+ opacity: 1;
58
+ `)}
59
+ `}
60
+ `,
61
+ })[color];
62
+ const SIZE_TO_SWITCH_BUTTON_STYLE = (size) => ({
63
+ medium: css `
64
+ padding: 8px 12px;
65
+ gap: 8px;
66
+ height: 40px;
67
+ svg {
68
+ width: 24px;
69
+ height: 24px;
70
+ }
71
+ span {
72
+ font-size: 16px;
73
+ line-height: 20px;
74
+ }
75
+ `,
76
+ xsmall: css `
77
+ padding: 4px 6px;
78
+ gap: 4px;
79
+ height: 24px;
80
+ svg {
81
+ width: 16px;
82
+ height: 16px;
83
+ }
84
+ span {
85
+ font-size: 12px;
86
+ line-height: 16px;
87
+ }
88
+ `,
89
+ })[size];
90
+ /**
91
+ * [피그마](https://www.figma.com/file/CxpgZcJFoRPWEZyx5RC0tq/Framework-System?node-id=766%3A11274&mode=dev)
92
+ */
93
+ const SwitchButton = React.forwardRef(function SwitchButton(props, ref) {
94
+ const { className, component: Component = "button", color, size, isOn, onIcon, offIcon, count, onChange } = props, other = __rest(props, ["className", "component", "color", "size", "isOn", "onIcon", "offIcon", "count", "onChange"]);
95
+ const theme = useTheme();
96
+ return (_jsxs(Component, Object.assign({ type: "button" }, other, { className: className, ref: ref, css: [
97
+ css `
98
+ display: flex;
99
+ justify-content: center;
100
+ align-items: center;
101
+ width: fit-content;
102
+ cursor: pointer;
103
+ border: none;
104
+ border-radius: 99px;
105
+ text-decoration: none;
106
+ `,
107
+ COLOR_TO_SWITCH_BUTTON_STYLE(theme, color, isOn),
108
+ SIZE_TO_SWITCH_BUTTON_STYLE(size),
109
+ ], onClick: () => onChange(!isOn) }, { children: [isOn ? onIcon : offIcon, count !== undefined && _jsx(Count, { children: count })] })));
110
+ });
111
+ const Count = styled.span(({ theme }) => css `
112
+ color: ${theme.color.foreground.neutralBase};
113
+ /* Default/Label/16px-Md */
114
+ font-family: ${theme.fontFamily.ui};
115
+ font-weight: 500;
116
+ `);
117
+ export default SwitchButton;
@@ -154,3 +154,57 @@ export declare const customEmbeddedColorSvg: string;
154
154
  export declare const CustomEmbeddedColorIcon: React.ForwardRefExoticComponent<{
155
155
  className?: string | undefined;
156
156
  } & React.RefAttributes<any>>;
157
+ export declare const customEmoHeartSvg: string;
158
+ export declare const CustomEmoHeartIcon: React.ForwardRefExoticComponent<{
159
+ className?: string | undefined;
160
+ color?: string | undefined;
161
+ } & React.RefAttributes<any>>;
162
+ export declare const customEmoHeartColorSvg: string;
163
+ export declare const CustomEmoHeartColorIcon: React.ForwardRefExoticComponent<{
164
+ className?: string | undefined;
165
+ } & React.RefAttributes<any>>;
166
+ export declare const customEmoHundredSvg: string;
167
+ export declare const CustomEmoHundredIcon: React.ForwardRefExoticComponent<{
168
+ className?: string | undefined;
169
+ color?: string | undefined;
170
+ } & React.RefAttributes<any>>;
171
+ export declare const customEmoHundredColorSvg: string;
172
+ export declare const CustomEmoHundredColorIcon: React.ForwardRefExoticComponent<{
173
+ className?: string | undefined;
174
+ } & React.RefAttributes<any>>;
175
+ export declare const customEmoStarsSvg: string;
176
+ export declare const CustomEmoStarsIcon: React.ForwardRefExoticComponent<{
177
+ className?: string | undefined;
178
+ color?: string | undefined;
179
+ } & React.RefAttributes<any>>;
180
+ export declare const customEmoStarsColorSvg: string;
181
+ export declare const CustomEmoStarsColorIcon: React.ForwardRefExoticComponent<{
182
+ className?: string | undefined;
183
+ } & React.RefAttributes<any>>;
184
+ export declare const customEmoThumbupSvg: string;
185
+ export declare const CustomEmoThumbupIcon: React.ForwardRefExoticComponent<{
186
+ className?: string | undefined;
187
+ color?: string | undefined;
188
+ } & React.RefAttributes<any>>;
189
+ export declare const customEmoThumbupColorSvg: string;
190
+ export declare const CustomEmoThumbupColorIcon: React.ForwardRefExoticComponent<{
191
+ className?: string | undefined;
192
+ } & React.RefAttributes<any>>;
193
+ export declare const customEmoClapSvg: string;
194
+ export declare const CustomEmoClapIcon: React.ForwardRefExoticComponent<{
195
+ className?: string | undefined;
196
+ color?: string | undefined;
197
+ } & React.RefAttributes<any>>;
198
+ export declare const customEmoClapColorSvg: string;
199
+ export declare const CustomEmoClapColorIcon: React.ForwardRefExoticComponent<{
200
+ className?: string | undefined;
201
+ } & React.RefAttributes<any>>;
202
+ export declare const customBoardSvg: string;
203
+ export declare const CustomBoardIcon: React.ForwardRefExoticComponent<{
204
+ className?: string | undefined;
205
+ color?: string | undefined;
206
+ } & React.RefAttributes<any>>;
207
+ export declare const customBoardColorSvg: string;
208
+ export declare const CustomBoardColorIcon: React.ForwardRefExoticComponent<{
209
+ className?: string | undefined;
210
+ } & React.RefAttributes<any>>;