Skip to content

Commit a088447

Browse files
authored
Infra/ migrate chip to designTokens (#1937)
* migrate chip to designTokens * set default dismissColor
1 parent 5441b36 commit a088447

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

demo/src/screens/componentScreens/ChipScreen.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default class ChipScreen extends Component {
8181
renderExample = (text: string, chip: JSX.Element) => {
8282
return (
8383
<View row spread marginB-12>
84-
<Text text70>{text}</Text>
84+
<Text text70 $textDefault>{text}</Text>
8585
{chip}
8686
</View>
8787
);
@@ -91,30 +91,34 @@ export default class ChipScreen extends Component {
9191
return (
9292
<View style={{padding: 20}}>
9393
{this.state.showDialog && this.renderPickerDialog()}
94-
<Text marginB-20 text40>
94+
<Text marginB-20 text40 $textDefault>
9595
Chip
9696
</Text>
97-
<Text marginB-10 text70BO>
97+
<Text marginB-10 text70BO $textDefault>
9898
Default
9999
</Text>
100100
{this.renderExample('Label', <Chip label={'Chip'}/>)}
101101
{this.renderExample('Label + onPress', <Chip label={'Chip'} onPress={() => Alert.alert('onPress')}/>)}
102102
{this.renderExample('Label + onDismiss',
103103
<Chip
104104
label={'Chip'}
105-
iconColor={Colors.black}
105+
iconProps={{tintColor: Colors.$iconDefault}}
106106
onDismiss={() => Alert.alert('onDismiss')}
107107
onPress={() => Alert.alert('onPress')}
108108
dismissIconStyle={{width: 10, height: 10}}
109109
/>)}
110110
{this.renderExample('Icon',
111-
<Chip iconSource={checkmark} iconStyle={{width: 24, height: 24}} iconProps={{tintColor: Colors.black}}/>)}
111+
<Chip
112+
iconSource={checkmark}
113+
iconStyle={{width: 24, height: 24}}
114+
iconProps={{tintColor: Colors.$iconDefault}}
115+
/>)}
112116
{this.renderExample('Left icon',
113117
<Chip
114118
label={'Chip'}
115119
iconSource={checkmark}
116120
iconStyle={{width: 24, height: 24}}
117-
iconProps={{tintColor: Colors.black}}
121+
iconProps={{tintColor: Colors.$iconDefault}}
118122
/>)}
119123
{this.renderExample('Right icon + onPress + dynamic label',
120124
<Chip
@@ -135,7 +139,7 @@ export default class ChipScreen extends Component {
135139
label: '4',
136140
labelStyle: {
137141
...Typography.text80R,
138-
color: Colors.grey20
142+
color: Colors.$textNeutralHeavy
139143
}
140144
}}
141145
/>)}
@@ -148,7 +152,7 @@ export default class ChipScreen extends Component {
148152
}}
149153
/>)}
150154

151-
<Text marginT-20 marginB-10 text70BO>
155+
<Text marginT-20 marginB-10 text70BO $textDefault>
152156
Custom
153157
</Text>
154158
<View center row>
@@ -163,6 +167,7 @@ export default class ChipScreen extends Component {
163167
iconSource={checkmark}
164168
label={'Chip'}
165169
labelStyle={{color: Colors.white}}
170+
iconProps={{tintColor: Colors.white}}
166171
containerStyle={{borderColor: Colors.green20, backgroundColor: Colors.green20, marginLeft: Spacings.s3}}
167172
/>
168173
<Chip
@@ -171,7 +176,6 @@ export default class ChipScreen extends Component {
171176
label={'Chip'}
172177
labelStyle={{color: Colors.red20, marginHorizontal: Spacings.s3, ...Typography.text70BO}}
173178
iconStyle={{width: 16, height: 16}}
174-
iconColor={Colors.black}
175179
avatarProps={{source: avatarImage, size: 28}}
176180
onDismiss={() => Alert.alert('onDismiss')}
177181
dismissIconStyle={{width: 10, height: 10, marginRight: Spacings.s3}}
@@ -188,10 +192,10 @@ export default class ChipScreen extends Component {
188192
labelStyle={{marginRight: Spacings.s1}}
189193
badgeProps={{
190194
label: '44',
191-
backgroundColor: Colors.white,
195+
backgroundColor: Colors.$backgroundDefault,
192196
borderWidth: 2,
193-
borderColor: Colors.black,
194-
labelStyle: {color: Colors.black}
197+
borderColor: Colors.$backgroundInverted,
198+
labelStyle: {color: Colors.$textDefault}
195199
}}
196200
containerStyle={{
197201
borderWidth: 0,

src/components/chip/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, {useCallback} from 'react';
33
import {StyleSheet, StyleProp, ViewStyle, ViewProps, ImageStyle, TextStyle, ImageSourcePropType} from 'react-native';
44
import Assets from '../../assets';
55
import {asBaseComponent} from '../../commons/new';
6-
import {BorderRadiuses, Spacings} from 'style';
6+
import {BorderRadiuses, Spacings, Colors} from 'style';
77
import Avatar, {AvatarProps} from '../avatar';
88
import Badge, {BadgeProps} from '../badge';
99
import Text from '../text';
@@ -145,7 +145,7 @@ const Chip = ({
145145
borderRadius = BorderRadiuses.br100,
146146
containerStyle,
147147
onDismiss,
148-
dismissColor,
148+
dismissColor = Colors.$iconDefault,
149149
dismissIcon = Assets.icons.x,
150150
dismissIconStyle,
151151
dismissContainerStyle,
@@ -172,6 +172,7 @@ const Chip = ({
172172
<Icon
173173
source={isLeftIcon ? iconSource : rightIconSource}
174174
testID={`${testID}.icon`}
175+
tintColor={Colors.$iconDefault}
175176
{...iconProps}
176177
style={[getMargins('iconSource'), iconStyle]}
177178
/>
@@ -228,6 +229,7 @@ const Chip = ({
228229
<Text
229230
text90M
230231
numberOfLines={1}
232+
$textDefault
231233
style={[styles.label, getMargins('label'), labelStyle]}
232234
testID={`${testID}.label`}
233235
>
@@ -338,6 +340,7 @@ const styles = StyleSheet.create({
338340
justifyContent: 'center',
339341
flexDirection: 'row',
340342
borderWidth: 1,
343+
borderColor: Colors.$backgroundInverted,
341344
borderRadius: BorderRadiuses.br100
342345
},
343346
label: {

0 commit comments

Comments
 (0)