Skip to content

Commit

Permalink
feat: option for hiding check icon on selected chip (#3969)
Browse files Browse the repository at this point in the history
Co-authored-by: Evan Cheung <[email protected]>
  • Loading branch information
Big-Cheung and Evan Cheung authored Aug 2, 2023
1 parent f62b694 commit 9a7f40b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/components/Chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ export type Props = $Omit<React.ComponentProps<typeof Surface>, 'mode'> & {
* Whether to display overlay on selected chip
*/
showSelectedOverlay?: boolean;
/**
* Whether to display default check icon on selected chip.
* Note: Check will not be shown if `icon` is specified. If specified, `icon` will be shown regardless of `selected`.
*/
showSelectedCheck?: boolean;
/**
* Color of the ripple effect.
*/
Expand Down Expand Up @@ -180,6 +185,7 @@ const Chip = ({
selectedColor,
rippleColor: customRippleColor,
showSelectedOverlay = false,
showSelectedCheck = true,
ellipsizeMode,
compact,
elevated = false,
Expand Down Expand Up @@ -256,7 +262,10 @@ const Chip = ({
const multiplier = isV3 ? (compact ? 1.5 : 2) : 1;
const labelSpacings = {
marginRight: onClose ? 0 : 8 * multiplier,
marginLeft: avatar || icon || selected ? 4 * multiplier : 8 * multiplier,
marginLeft:
avatar || icon || (selected && showSelectedCheck)
? 4 * multiplier
: 8 * multiplier,
};
const contentSpacings = {
paddingRight: isV3 ? (onClose ? 34 : 0) : onClose ? 32 : 4,
Expand Down Expand Up @@ -320,7 +329,7 @@ const Chip = ({
: avatar}
</View>
) : null}
{icon || selected ? (
{icon || (selected && showSelectedCheck) ? (
<View
style={[
styles.icon,
Expand Down

0 comments on commit 9a7f40b

Please sign in to comment.