@team-monolith/cds 1.20.1 → 1.20.2
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.
|
@@ -15,10 +15,10 @@ export interface SwitchButtonOwnProps<RootComponentType extends React.ElementTyp
|
|
|
15
15
|
onIcon: React.ReactNode;
|
|
16
16
|
/** off 일때의 아이콘 */
|
|
17
17
|
offIcon: React.ReactNode;
|
|
18
|
-
/** 아이콘 오른쪽에 나타낼
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
|
|
18
|
+
/** 아이콘 오른쪽에 나타낼 부분. 전달하지 않으면 나타나지 않습니다. */
|
|
19
|
+
content?: React.ReactNode;
|
|
20
|
+
/** 버튼 클릭시 실행될 콜백 */
|
|
21
|
+
onClick: () => void;
|
|
22
22
|
}
|
|
23
23
|
export type SwitchButtonProps<RootComponentType extends React.ElementType = SwitchButtonTypeMap["defaultComponent"]> = PolymorphicProps<SwitchButtonTypeMap<RootComponentType>, RootComponentType>;
|
|
24
24
|
export interface SwitchButtonTypeMap<RootComponentType extends React.ElementType = "button"> {
|
|
@@ -91,7 +91,7 @@ const SIZE_TO_SWITCH_BUTTON_STYLE = (size) => ({
|
|
|
91
91
|
* [피그마](https://www.figma.com/file/CxpgZcJFoRPWEZyx5RC0tq/Framework-System?node-id=766%3A11274&mode=dev)
|
|
92
92
|
*/
|
|
93
93
|
const SwitchButton = React.forwardRef(function SwitchButton(props, ref) {
|
|
94
|
-
const { className, component: Component = "button", color, size, isOn, onIcon, offIcon,
|
|
94
|
+
const { className, component: Component = "button", color, size, isOn, onIcon, offIcon, content, onClick } = props, other = __rest(props, ["className", "component", "color", "size", "isOn", "onIcon", "offIcon", "content", "onClick"]);
|
|
95
95
|
const theme = useTheme();
|
|
96
96
|
return (_jsxs(Component, Object.assign({ type: "button" }, other, { className: className, ref: ref, css: [
|
|
97
97
|
css `
|
|
@@ -106,9 +106,9 @@ const SwitchButton = React.forwardRef(function SwitchButton(props, ref) {
|
|
|
106
106
|
`,
|
|
107
107
|
COLOR_TO_SWITCH_BUTTON_STYLE(theme, color, isOn),
|
|
108
108
|
SIZE_TO_SWITCH_BUTTON_STYLE(size),
|
|
109
|
-
], onClick:
|
|
109
|
+
], onClick: onClick }, { children: [isOn ? onIcon : offIcon, content && _jsx(Content, { children: content })] })));
|
|
110
110
|
});
|
|
111
|
-
const
|
|
111
|
+
const Content = styled.span(({ theme }) => css `
|
|
112
112
|
color: ${theme.color.foreground.neutralBase};
|
|
113
113
|
/* Default/Label/16px-Md */
|
|
114
114
|
font-family: ${theme.fontFamily.ui};
|