Skip to content

Commit 31a13ad

Browse files
committed
chore: update types
1 parent 3451c07 commit 31a13ad

File tree

3 files changed

+44
-51
lines changed

3 files changed

+44
-51
lines changed

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,7 @@ const _Chip: React.ForwardRefRenderFunction<BladeElementRef, ChipProps> = (
197197
<Icon color={chipIconColor} size={chipIconSizes[_size]} />
198198
</BaseBox>
199199
) : null}
200-
<Text
201-
{...chipTextSizes[_size]}
202-
type="normal"
203-
truncateAfterLines={1}
204-
color={chipTextColor}
205-
>
200+
<Text {...chipTextSizes[_size]} truncateAfterLines={1} color={chipTextColor}>
206201
{children}
207202
</Text>
208203
</StyledChipWrapper>

packages/blade/src/components/Chip/chipTokens.ts

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ChipGroupProps } from './ChipGroup';
2-
import type { Theme } from '~components/BladeProvider';
3-
import type { DotNotationColorStringToken, DotNotationSpacingStringToken } from '~utils/types';
2+
import type { ChipBorderColors, ChipBackgroundColors } from './types';
3+
import type { DotNotationSpacingStringToken } from '~utils/types';
44
import type { SelectorInputHoverTokens } from '~components/Form/Selector/types';
55
import { size } from '~tokens/global';
66
import type { IconProps } from '~components/Icons';
@@ -74,45 +74,13 @@ const chipHorizontalPaddingTokens: ChipHorizontalPaddingTokens = {
7474
},
7575
};
7676

77-
type InteractiveBackgroundColors<
78-
T extends 'positive' | 'negative' | 'primary'
79-
> = `interactive.background.${T}.${DotNotationColorStringToken<
80-
Theme['colors']['interactive']['background'][T]
81-
>}`;
82-
83-
type InteractiveBorderColors<
84-
T extends 'positive' | 'negative' | 'primary'
85-
> = `interactive.border.${T}.${DotNotationColorStringToken<
86-
Theme['colors']['interactive']['background'][T]
87-
>}`;
88-
8977
type TextColorTokens = BaseTextProps['color'];
9078
type IconColorTokens = IconProps['color'];
9179
type ChipColorTokens = {
9280
text: Record<string, TextColorTokens>;
93-
icon: Record<string, IconColorTokens | 'surface.background.primary.intense'>;
94-
background: Record<
95-
string,
96-
Record<
97-
string,
98-
| InteractiveBackgroundColors<'positive'>
99-
| InteractiveBackgroundColors<'negative'>
100-
| InteractiveBackgroundColors<'primary'>
101-
| 'transparent'
102-
| 'interactive.background.gray.faded'
103-
>
104-
>;
105-
border: Record<
106-
string,
107-
Record<
108-
string,
109-
| InteractiveBorderColors<'positive'>
110-
| InteractiveBorderColors<'negative'>
111-
| InteractiveBorderColors<'primary'>
112-
| 'interactive.border.gray.default'
113-
| 'interactive.border.gray.disabled'
114-
>
115-
>;
81+
icon: Record<string, IconColorTokens>;
82+
background: Record<string, Record<string, ChipBackgroundColors>>;
83+
border: Record<string, Record<string, ChipBorderColors>>;
11684
};
11785

11886
const chipColorTokens: ChipColorTokens = {
@@ -124,8 +92,8 @@ const chipColorTokens: ChipColorTokens = {
12492
negative: 'interactive.text.negative.subtle',
12593
},
12694
icon: {
127-
unchecked: 'interactive.text.gray.subtle',
128-
disabled: 'interactive.text.gray.disabled',
95+
unchecked: 'interactive.icon.gray.subtle',
96+
disabled: 'interactive.icon.gray.disabled',
12997
primary: 'interactive.icon.primary.normal',
13098
positive: 'feedback.icon.positive.intense',
13199
negative: 'feedback.icon.negative.intense',
@@ -179,8 +147,8 @@ const getChipInputHoverTokens = (color: ChipGroupProps['color']): SelectorInputH
179147
return {
180148
default: {
181149
background: {
182-
checked: 'transparent',
183-
unchecked: 'transparent',
150+
checked: 'colors.surface.background.gray.intense',
151+
unchecked: 'colors.surface.background.gray.intense',
184152
},
185153
border: {
186154
checked: `colors.${chipColorTokens.border[color || 'default'].hover}` as never,
@@ -216,7 +184,10 @@ const chipTextSizes = {
216184
},
217185
} as const;
218186

219-
const chipMotionTokens = {
187+
const chipMotionTokens: Record<
188+
'duration' | 'easing',
189+
'motion.duration.xquick' | 'motion.easing.standard.effective'
190+
> = {
220191
duration: 'motion.duration.xquick',
221192
easing: 'motion.easing.standard.effective',
222193
};

packages/blade/src/components/Chip/types.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import type { StyledPropsBlade } from '~components/Box/styledProps';
22
import type { Theme } from '~components/BladeProvider';
33
import type { IconComponent } from '~components/Icons';
4-
import type { DotNotationColorStringToken, StringChildrenType, TestID } from '~utils/types';
4+
import type { StringChildrenType, TestID } from '~utils/types';
5+
import type { DotNotationToken } from '~utils/lodashButBetter/get';
56

67
type ChipProps = {
78
/**
@@ -106,8 +107,32 @@ type ChipGroupContextType = Pick<
106107
'isDisabled' | 'name' | 'defaultValue' | 'value' | 'onChange' | 'size' | 'color' | 'selectionType'
107108
> & { state?: State };
108109

110+
type InteractiveBackgroundColors<
111+
T extends 'positive' | 'negative' | 'primary'
112+
> = `interactive.background.${T}.${DotNotationToken<
113+
Theme['colors']['interactive']['background'][T]
114+
>}`;
115+
116+
type InteractiveBorderColors<
117+
T extends 'positive' | 'negative' | 'primary'
118+
> = `interactive.border.${T}.${DotNotationToken<Theme['colors']['interactive']['border'][T]>}`;
119+
120+
type ChipBackgroundColors =
121+
| InteractiveBackgroundColors<'positive'>
122+
| InteractiveBackgroundColors<'negative'>
123+
| InteractiveBackgroundColors<'primary'>
124+
| 'transparent'
125+
| 'interactive.background.gray.faded';
126+
127+
type ChipBorderColors =
128+
| InteractiveBorderColors<'positive'>
129+
| InteractiveBorderColors<'negative'>
130+
| InteractiveBorderColors<'primary'>
131+
| 'interactive.border.gray.default'
132+
| 'interactive.border.gray.disabled';
133+
109134
type AnimatedChipProps = {
110-
borderColor: DotNotationColorStringToken<Theme['colors']>;
135+
borderColor: ChipBorderColors;
111136
isPressed?: boolean;
112137
isDisabled?: boolean;
113138
isDesktop?: boolean;
@@ -117,7 +142,7 @@ type AnimatedChipProps = {
117142

118143
type StyledChipWrapperProps = {
119144
color: ChipGroupProps['color'];
120-
borderColor: DotNotationColorStringToken<Theme['colors']>;
145+
borderColor: ChipBorderColors;
121146
isChecked?: boolean;
122147
isDisabled?: boolean;
123148
theme: Theme;
@@ -131,4 +156,6 @@ export type {
131156
ChipProps,
132157
State,
133158
StyledChipWrapperProps,
159+
ChipBorderColors,
160+
ChipBackgroundColors,
134161
};

0 commit comments

Comments
 (0)