Skip to content
This repository was archived by the owner on Mar 25, 2025. It is now read-only.

Commit 5756acf

Browse files
authored
fix(chip): prevent to shrink icon in Chip (#56)
Icon in Chip component shouldn't shrink even if there is not enough space. Also change icon color to darker color.
1 parent a3d810f commit 5756acf

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

packages/core/src/Chip/__snapshots__/index.test.tsx.snap

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,13 @@ exports[`Chips with icon 1`] = `
416416
}
417417
418418
.c4 {
419-
width: 24px;
420-
color: rgb(122,122,122);
421-
margin-left: -8px;
419+
-webkit-flex: 0 0 min-content;
420+
-ms-flex: 0 0 min-content;
421+
flex: 0 0 min-content;
422+
overflow: visible;
423+
margin-left: -4px;
424+
margin-right: 4px;
425+
color: rgb(82,82,82);
422426
}
423427
424428
.c7 {

packages/core/src/Chip/index.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ import styled from 'styled-components'
55

66
import { CloseIcon } from 'practical-react-components-icons'
77

8-
import { spacing, componentSize } from '../designparams'
8+
import { spacing } from '../designparams'
99
import { ClickableIcon, Icon, IconType } from '../Icon'
1010
import { Typography } from '../Typography'
1111
import { BaseChip, BaseChipProps } from './BaseChip'
1212

13-
const ChipIcon = styled(Icon)`
14-
width: ${componentSize.mini};
15-
color: ${({ theme }) => theme.color.text05()};
16-
margin-left: -${spacing.medium};
13+
const ChipIcon = styled(Icon).attrs({ size: 'small' })`
14+
flex: 0 0 min-content;
15+
overflow: visible;
16+
margin-left: -${spacing.small};
17+
margin-right: ${spacing.small};
18+
color: ${({ theme }) => theme.color.text03()};
1719
`
1820

1921
const ChipRemoveIcon = styled(ClickableIcon).attrs({
@@ -22,6 +24,7 @@ const ChipRemoveIcon = styled(ClickableIcon).attrs({
2224
icon: CloseIcon,
2325
})`
2426
flex: 0 0 min-content;
27+
overflow: visible;
2528
margin-left: ${spacing.small};
2629
`
2730

@@ -47,9 +50,7 @@ export const Chip = React.forwardRef<HTMLDivElement, ChipProps>(
4750
const component = useMemo(() => {
4851
return (
4952
<>
50-
{!error && icon !== undefined ? (
51-
<ChipIcon icon={icon} size="small" />
52-
) : null}
53+
{!error && icon !== undefined ? <ChipIcon icon={icon} /> : null}
5354
<Typography variant="chip-tag-text">{text}</Typography>
5455
{onRemove ? <ChipRemoveIcon onClick={onRemove} /> : null}
5556
</>

packages/core/src/Select/__snapshots__/MultiSelect.test.tsx.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ exports[`Select Direction 1`] = `
204204
-webkit-flex: 0 0 min-content;
205205
-ms-flex: 0 0 min-content;
206206
flex: 0 0 min-content;
207+
overflow: visible;
207208
margin-left: 4px;
208209
}
209210
@@ -603,6 +604,7 @@ exports[`Select Direction 2`] = `
603604
-webkit-flex: 0 0 min-content;
604605
-ms-flex: 0 0 min-content;
605606
flex: 0 0 min-content;
607+
overflow: visible;
606608
margin-left: 4px;
607609
}
608610
@@ -1009,6 +1011,7 @@ exports[`Select Other 1`] = `
10091011
-webkit-flex: 0 0 min-content;
10101012
-ms-flex: 0 0 min-content;
10111013
flex: 0 0 min-content;
1014+
overflow: visible;
10121015
margin-left: 4px;
10131016
}
10141017
@@ -1422,6 +1425,7 @@ exports[`Select Other 2`] = `
14221425
-webkit-flex: 0 0 min-content;
14231426
-ms-flex: 0 0 min-content;
14241427
flex: 0 0 min-content;
1428+
overflow: visible;
14251429
margin-left: 4px;
14261430
}
14271431
@@ -1821,6 +1825,7 @@ exports[`Select Width 1`] = `
18211825
-webkit-flex: 0 0 min-content;
18221826
-ms-flex: 0 0 min-content;
18231827
flex: 0 0 min-content;
1828+
overflow: visible;
18241829
margin-left: 4px;
18251830
}
18261831
@@ -2220,6 +2225,7 @@ exports[`Select Width 2`] = `
22202225
-webkit-flex: 0 0 min-content;
22212226
-ms-flex: 0 0 min-content;
22222227
flex: 0 0 min-content;
2228+
overflow: visible;
22232229
margin-left: 4px;
22242230
}
22252231
@@ -2651,6 +2657,7 @@ exports[`Select Width 3`] = `
26512657
-webkit-flex: 0 0 min-content;
26522658
-ms-flex: 0 0 min-content;
26532659
flex: 0 0 min-content;
2660+
overflow: visible;
26542661
margin-left: 4px;
26552662
}
26562663

0 commit comments

Comments
 (0)