Skip to content

Commit 5fc8ed0

Browse files
authored
refactor!: rebrand Chip & ChipGroup components (#1948)
1 parent 5c723ec commit 5fc8ed0

24 files changed

+596
-569
lines changed

packages/blade/.storybook/react/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const config: StorybookConfig = {
2828
'../../src/components/Indicator/**/*.stories.@(ts|tsx|js|jsx)',
2929
'../../src/components/Button/**/*.stories.@(ts|tsx|js|jsx)',
3030
'../../src/components/Divider/**/*.stories.@(ts|tsx|js|jsx)',
31+
'../../src/components/Chip/**/*.stories.@(ts|tsx|js|jsx)',
3132
'../../src/components/Carousel/**/*.stories.@(ts|tsx|js|jsx)',
3233
'../../src/components/List/**/*.stories.@(ts|tsx|js|jsx)',
3334
'../../src/components/Link/**/*.stories.@(ts|tsx|js|jsx)',

packages/blade/rebranded-components.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const rebrandedComponents = [
1313
'Link',
1414
'Popover',
1515
'Counter',
16+
'Chip',
17+
'ChipGroup',
1618
'Badge',
1719
'Indicator',
1820
'IconButton',

packages/blade/src/components/Chip/AnimatedChip.native.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const AnimatedChip = ({
2222
}: Omit<AnimatedChipProps, 'theme'>): React.ReactElement => {
2323
const { theme } = useTheme();
2424

25-
const easing = getIn(theme, chipMotionTokens.easing);
26-
const duration = getIn(theme, chipMotionTokens.duration);
25+
const easing = getIn(theme.motion, chipMotionTokens.easing);
26+
const duration = getIn(theme.motion, chipMotionTokens.duration);
2727

2828
const chipAnimation = useAnimatedStyle(() => {
2929
return {

packages/blade/src/components/Chip/AnimatedChip.web.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import { makeMotionTime } from '~utils/makeMotionTime';
88
import { castWebType } from '~utils';
99

1010
const AnimatedChip = styled(BaseBox)<AnimatedChipProps>((props) => {
11-
const easing = getIn(props.theme, chipMotionTokens.easing);
12-
const duration = castWebType(makeMotionTime(getIn(props.theme, chipMotionTokens.duration)));
11+
const easing = getIn(props.theme.motion, chipMotionTokens.easing);
12+
const duration = castWebType(
13+
makeMotionTime(getIn(props.theme.motion, chipMotionTokens.duration)),
14+
);
1315
return {
1416
...getAnimatedChipStyles(props),
1517
width: 'fit-content',

packages/blade/src/components/Chip/Chip.stories.tsx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,16 @@ export default {
7676
},
7777
},
7878
},
79-
intent: {
80-
description: 'This is deprecated in favor of the `color` prop.',
81-
table: {
82-
category: propsCategory.CHIP,
83-
type: {
84-
summary: '"none" | "positive" | "negative"',
85-
},
86-
},
87-
options: ['none', 'positive', 'negative'],
88-
control: {
89-
type: 'radio',
90-
},
91-
},
9279
color: {
9380
description:
9481
'Sets the color of the Chip. This overwrites the color set by the parent `ChipGroup` component',
9582
table: {
9683
category: propsCategory.CHIP,
9784
type: {
98-
summary: '"default" | "positive" | "negative"',
85+
summary: '"primary" | "positive" | "negative"',
9986
},
10087
},
101-
options: ['default', 'positive', 'negative'],
88+
options: ['primary', 'positive', 'negative'],
10289
control: {
10390
type: 'radio',
10491
},
@@ -133,5 +120,5 @@ const ChipTemplate: StoryFn<typeof ChipComponent> = ({ children, ...args }) => {
133120
export const Default = ChipTemplate.bind({});
134121
Default.storyName = 'Default';
135122
Default.args = {
136-
color: 'default',
123+
color: 'primary',
137124
};

packages/blade/src/components/Chip/Chip.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type OnChange = ({
3737
}) => void;
3838

3939
const _Chip: React.ForwardRefRenderFunction<BladeElementRef, ChipProps> = (
40-
{ isDisabled, value, children, icon: Icon, intent, color, testID, ...styledProps },
40+
{ isDisabled, value, children, icon: Icon, color, testID, ...styledProps },
4141
ref,
4242
) => {
4343
const { theme } = useTheme();
@@ -67,10 +67,7 @@ const _Chip: React.ForwardRefRenderFunction<BladeElementRef, ChipProps> = (
6767
: groupProps?.defaultValue?.includes(value as string); // If multiple selection, check if value is in defaultValue array
6868
const useChip = groupProps?.selectionType === 'single' ? useRadio : useCheckbox;
6969
const _size = groupProps?.size || 'small';
70-
const _intent = intent ?? groupProps?.intent;
71-
// If intent is proovided and it's not none, use intent otherwise use color
72-
const _color = color ?? groupProps?.color ?? 'default';
73-
const chipColor = _intent && _intent !== 'none' ? _intent : _color;
70+
const chipColor = color ?? groupProps?.color ?? 'primary';
7471

7572
const handleChange: OnChange = ({ isChecked, value }) => {
7673
if (isChecked) {
@@ -129,13 +126,13 @@ const _Chip: React.ForwardRefRenderFunction<BladeElementRef, ChipProps> = (
129126
const chipTextColor = chipColorTokens.text[textVariant];
130127
const chipIconColor = chipColorTokens.icon[textVariant];
131128

132-
let intentVariant = 'unchecked';
129+
let colorVariant = 'unchecked';
133130
const stateVariant = _isDisabled ? 'disabled' : 'default';
134131
if (_isChecked && chipColor) {
135-
intentVariant = chipColor;
132+
colorVariant = chipColor;
136133
}
137-
const chipBackgroundColor = chipColorTokens.background[intentVariant][stateVariant];
138-
const chipBorderColor = chipColorTokens.border[intentVariant][stateVariant];
134+
const chipBackgroundColor = chipColorTokens.background[colorVariant][stateVariant];
135+
const chipBorderColor = chipColorTokens.border[colorVariant][stateVariant];
139136

140137
return (
141138
<BaseBox
@@ -200,12 +197,7 @@ const _Chip: React.ForwardRefRenderFunction<BladeElementRef, ChipProps> = (
200197
<Icon color={chipIconColor} size={chipIconSizes[_size]} />
201198
</BaseBox>
202199
) : null}
203-
<Text
204-
{...chipTextSizes[_size]}
205-
type="normal"
206-
truncateAfterLines={1}
207-
color={chipTextColor}
208-
>
200+
<Text {...chipTextSizes[_size]} truncateAfterLines={1} color={chipTextColor}>
209201
{children}
210202
</Text>
211203
</StyledChipWrapper>

0 commit comments

Comments
 (0)