@team-monolith/cds 1.6.0 → 1.6.1

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.
@@ -1,7 +1,9 @@
1
1
  import React from "react";
2
2
  import { ButtonProps } from "../..";
3
- export interface SegmentedControlButtonProps extends Omit<ButtonProps, "color" | "size"> {
3
+ export interface SegmentedControlButtonProps extends Omit<ButtonProps, "color" | "size" | "startIcon" | "endIcon"> {
4
4
  value: string;
5
+ startIcon?: React.ReactNode | ((isActive: boolean) => React.ReactNode);
6
+ endIcon?: React.ReactNode | ((isActive: boolean) => React.ReactNode);
5
7
  }
6
8
  /**
7
9
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
@@ -20,7 +20,7 @@ import { Button, shadows } from "../..";
20
20
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
21
21
  */
22
22
  export const SegmentedControlButton = React.forwardRef(function SegmentedControlButton(props, ref) {
23
- const { onClick } = props, other = __rest(props, ["onClick"]);
23
+ const { onClick, startIcon, endIcon } = props, other = __rest(props, ["onClick", "startIcon", "endIcon"]);
24
24
  const context = useContext(SegmentedControlGroupPropsContext);
25
25
  const handleClick = (e) => {
26
26
  var _a;
@@ -30,20 +30,17 @@ export const SegmentedControlButton = React.forwardRef(function SegmentedControl
30
30
  const isActive = context.multiSelect
31
31
  ? context.value.includes(props.value)
32
32
  : context.value === props.value;
33
- return (_jsx(StyledButton, Object.assign({}, other, { ref: ref, isActive: isActive, color: isActive ? "white" : "textNeutral", size: context.size, onClick: handleClick })));
33
+ return (_jsx(StyledButton, Object.assign({}, other, { ref: ref, startIcon: typeof startIcon === "function" ? startIcon(isActive) : startIcon, endIcon: typeof endIcon === "function" ? endIcon(isActive) : endIcon, isActive: isActive, color: isActive ? "white" : "textNeutral", size: context.size, onClick: handleClick })));
34
34
  });
35
35
  const StyledButton = styled(Button, {
36
36
  shouldForwardProp: (prop) => prop !== "isActive",
37
- })(({ theme, isActive }) => css `
37
+ })(({ isActive }) => css `
38
38
  display: flex;
39
39
  justify-content: center;
40
40
  flex-grow: 1;
41
41
  ${isActive &&
42
42
  `
43
43
  box-shadow: ${shadows.shadow04};
44
- svg {
45
- color: ${theme.color.foreground.primary};
46
- }
47
44
  span {
48
45
  font-weight: 700;
49
46
  }
@@ -1,7 +1,8 @@
1
1
  import React from "react";
2
2
  import { SquareButtonProps } from "../..";
3
- export interface SegmentedControlSquareButtonProps extends Omit<SquareButtonProps, "color" | "size"> {
3
+ export interface SegmentedControlSquareButtonProps extends Omit<SquareButtonProps, "color" | "size" | "icon"> {
4
4
  value: string;
5
+ icon: React.ReactNode | ((isActive: boolean) => React.ReactNode);
5
6
  }
6
7
  /**
7
8
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
@@ -20,7 +20,7 @@ import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsC
20
20
  * [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
21
21
  */
22
22
  export const SegmentedControlSquareButton = React.forwardRef(function SegmentedControlSquareButton(props, ref) {
23
- const { onClick } = props, other = __rest(props, ["onClick"]);
23
+ const { onClick, icon } = props, other = __rest(props, ["onClick", "icon"]);
24
24
  const context = useContext(SegmentedControlGroupPropsContext);
25
25
  const handleClick = () => {
26
26
  var _a;
@@ -30,20 +30,17 @@ export const SegmentedControlSquareButton = React.forwardRef(function SegmentedC
30
30
  const isActive = context.multiSelect
31
31
  ? context.value.includes(props.value)
32
32
  : context.value === props.value;
33
- return (_jsx(StyledSquareButton, Object.assign({}, other, { ref: ref, isActive: isActive, color: isActive ? "white" : "icon", size: context.size, fullWidth: context.fullWidth, onClick: handleClick })));
33
+ return (_jsx(StyledSquareButton, Object.assign({}, other, { ref: ref, isActive: isActive, icon: typeof icon === "function" ? icon(isActive) : icon, color: isActive ? "white" : "icon", size: context.size, fullWidth: context.fullWidth, onClick: handleClick })));
34
34
  });
35
35
  const StyledSquareButton = styled(SquareButton, {
36
36
  shouldForwardProp: (prop) => prop !== "isActive",
37
- })(({ theme, isActive }) => css `
37
+ })(({ isActive }) => css `
38
38
  display: flex;
39
39
  justify-content: center;
40
40
  flex-grow: 1;
41
41
  ${isActive &&
42
42
  `
43
- box-shadow: ${shadows.shadow04};
44
- svg {
45
- color: ${theme.color.foreground.primary};
46
- }
43
+ box-shadow: ${shadows.shadow04};
47
44
  span {
48
45
  font-weight: 700;
49
46
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,