Skip to content

Commit 3949bce

Browse files
authored
Infra/ Migrate Incubator.TextField to DesignTokens (#1834)
* migrate Incubator.TextField to DesignTokens * update disabled color * set error color from screen
1 parent 9d96b45 commit 3949bce

File tree

11 files changed

+39
-28
lines changed

11 files changed

+39
-28
lines changed

demo/src/screens/incubatorScreens/IncubatorTextFieldScreen.tsx

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ export default class TextFieldScreen extends Component {
3030
renderTrailingAccessory() {
3131
const {searching} = this.state;
3232
if (searching) {
33-
return <ActivityIndicator color={Colors.grey10}/>;
33+
return <ActivityIndicator color={Colors.$iconDefault}/>;
3434
} else {
3535
return (
3636
<Button
3737
iconSource={Assets.icons.demo.search}
3838
link
3939
marginL-s2
40-
grey10
40+
$iconDefault
4141
onPress={() => {
4242
this.setState({searching: true});
4343
setTimeout(() => {
@@ -68,8 +68,8 @@ export default class TextFieldScreen extends Component {
6868
placeholder="Floating placeholder"
6969
floatingPlaceholder
7070
floatingPlaceholderColor={{
71-
focus: Colors.grey10,
72-
default: Colors.grey30
71+
focus: Colors.$textDefault,
72+
default: Colors.$textNeutral
7373
}}
7474
// floatingPlaceholderStyle={Typography.text60}
7575
// style={Typography.text60}
@@ -114,7 +114,7 @@ export default class TextFieldScreen extends Component {
114114
placeholder="Enter weight"
115115
text70
116116
trailingAccessory={
117-
<Text text70 grey30>
117+
<Text text70 $textNeutral>
118118
Kg.
119119
</Text>
120120
}
@@ -191,7 +191,12 @@ export default class TextFieldScreen extends Component {
191191

192192
<TextField
193193
label="Email"
194-
labelColor={{default: Colors.grey10, focus: Colors.blue20, error: Colors.red30, disabled: Colors.grey40}}
194+
labelColor={{
195+
default: Colors.$textDefault,
196+
focus: Colors.$textGeneral,
197+
error: Colors.$textDangerLight,
198+
disabled: Colors.$textDisabled
199+
}}
195200
placeholder="Enter valid email"
196201
validationMessage="Email is invalid"
197202
validate={'email'}
@@ -215,7 +220,9 @@ export default class TextFieldScreen extends Component {
215220
label="Label"
216221
placeholder="Enter text..."
217222
preset={preset}
218-
dynamicFieldStyle={(_state, {preset}) => (preset === 'withUnderline' ? styles.withUnderline : styles.withFrame)}
223+
dynamicFieldStyle={(_state, {preset}) =>
224+
preset === 'withUnderline' ? styles.withUnderline : styles.withFrame
225+
}
219226
editable={!shouldDisable}
220227
/>
221228

@@ -233,7 +240,7 @@ export default class TextFieldScreen extends Component {
233240
{Assets.emojis.grapes} {Assets.emojis.melon} {Assets.emojis.banana}
234241
</Text>
235242
}
236-
charCounterStyle={{color: Colors.blue30}}
243+
charCounterStyle={{color: Colors.$textGeneral}}
237244
maxLength={20}
238245
fieldStyle={styles.withFrame}
239246
/>
@@ -257,8 +264,12 @@ export default class TextFieldScreen extends Component {
257264
validate={'number'}
258265
validationMessage="Invalid price"
259266
// @ts-expect-error
260-
formatter={(value) => (isNaN(value) ? value : priceFormatter.format(Number(value)))}
261-
leadingAccessory={<Text marginR-s1 grey30>$</Text>}
267+
formatter={value => (isNaN(value) ? value : priceFormatter.format(Number(value)))}
268+
leadingAccessory={
269+
<Text marginR-s1 $textNeutral>
270+
$
271+
</Text>
272+
}
262273
fieldStyle={styles.withUnderline}
263274
/>
264275
</View>
@@ -272,12 +283,12 @@ const styles = StyleSheet.create({
272283
container: {},
273284
withUnderline: {
274285
borderBottomWidth: 1,
275-
borderColor: Colors.grey40,
286+
borderColor: Colors.$outlineDisabledHeavy,
276287
paddingBottom: 4
277288
},
278289
withFrame: {
279290
borderWidth: 1,
280-
borderColor: Colors.grey40,
291+
borderColor: Colors.$outlineDisabledHeavy,
281292
padding: 4,
282293
borderRadius: 2
283294
}

generatedTypes/src/incubator/TextField/presets/default.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ declare const _default: {
33
validateOnBlur: boolean;
44
floatingPlaceholderColor: {
55
focus: string;
6-
error: any;
6+
error: string;
77
disabled: string;
88
};
99
labelColor: {
1010
focus: string;
11-
error: any;
11+
error: string;
1212
disabled: string;
1313
};
1414
fieldStyle: {

generatedTypes/src/incubator/TextField/usePreset.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
10681068
label?: string | undefined;
10691069
labelColor: import("./types").ColorType | {
10701070
focus: string;
1071-
error: any;
1071+
error: string;
10721072
disabled: string;
10731073
};
10741074
labelStyle?: import("react-native").TextStyle | undefined;
@@ -1077,7 +1077,7 @@ export default function usePreset({ preset, ...props }: InternalTextFieldProps):
10771077
floatingPlaceholder?: boolean | undefined;
10781078
floatingPlaceholderColor: import("./types").ColorType | {
10791079
focus: string;
1080-
error: any;
1080+
error: string;
10811081
disabled: string;
10821082
};
10831083
floatOnFocus?: boolean | undefined;

src/incubator/TextField/CharCounter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const CharCounter = ({maxLength, charCounterStyle, testID}: CharCounterProps) =>
2424
}
2525

2626
return (
27-
<Text grey30 style={[styles.container, charCounterStyle]} testID={testID}>
27+
<Text $textNeutral style={[styles.container, charCounterStyle]} testID={testID}>
2828
{`${_.size(value)}/${maxLength}`}
2929
</Text>
3030
);

src/incubator/TextField/FloatingPlaceholder.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const FLOATING_PLACEHOLDER_SCALE = 0.875;
3434

3535
const FloatingPlaceholder = ({
3636
placeholder,
37-
floatingPlaceholderColor = Colors.grey40,
37+
floatingPlaceholderColor = Colors.$textNeutralLight,
3838
floatingPlaceholderStyle,
3939
floatOnFocus,
4040
validationMessagePosition,

src/incubator/TextField/Input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import FieldContext from './FieldContext';
88
import useImperativeInputHandle from './useImperativeInputHandle';
99

1010
const DEFAULT_INPUT_COLOR: ColorType = {
11-
default: Colors.grey10,
12-
disabled: Colors.grey40
11+
default: Colors.$textDefault,
12+
disabled: Colors.$textDisabled
1313
};
1414
export interface InputProps
1515
extends Omit<TextInputProps, 'placeholderTextColor'>,

src/incubator/TextField/Label.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface LabelProps {
3030

3131
const Label = ({
3232
label,
33-
labelColor = Colors.grey10,
33+
labelColor = Colors.$textDefault,
3434
labelStyle,
3535
labelProps,
3636
validationMessagePosition,

src/incubator/TextField/Presenter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function getColorByState(color?: ColorType, context?: FieldContextType) {
1919
finalColor = color?.focus;
2020
}
2121

22-
finalColor = finalColor || color?.default || Colors.grey10;
22+
finalColor = finalColor || color?.default || Colors.$textDefault;
2323
}
2424

2525
return finalColor;

src/incubator/TextField/ValidationMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const ValidationMessage = ({
4141
const showValidationMessage = !context.isValid || (!validate && !!validationMessage);
4242

4343
return (
44-
<Text testID={testID} red30 style={[styles.validationMessage, validationMessageStyle]}>
44+
<Text testID={testID} $textDangerLight style={[styles.validationMessage, validationMessageStyle]}>
4545
{showValidationMessage ? relevantValidationMessage : ''}
4646
</Text>
4747
);

src/incubator/TextField/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ const TextField = (props: InternalTextFieldProps) => {
217217
)}
218218
{children || (
219219
<Input
220-
placeholderTextColor={hidePlaceholder ? 'transparent' : Colors.grey30}
220+
placeholderTextColor={hidePlaceholder ? 'transparent' : Colors.$textNeutral}
221221
{...others}
222222
style={[typographyStyle, colorStyle, others.style]}
223223
onFocus={onFocus}

src/incubator/TextField/presets/default.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import {StyleSheet} from 'react-native';
22
import {Colors, Spacings, Typography} from '../../../style';
33

44
const colorByState = {
5-
focus: Colors.primary,
6-
error: Colors.error,
7-
disabled: Colors.grey40
5+
focus: Colors.$textPrimary,
6+
error: Colors.$textDangerLight,
7+
disabled: Colors.$textDisabled
88
};
99

1010
const styles = StyleSheet.create({
1111
field: {
1212
borderBottomWidth: 1,
13-
borderBottomColor: Colors.grey50,
13+
borderBottomColor: Colors.$outlineNeutralMedium,
1414
paddingBottom: Spacings.s2
1515
},
1616
input: {

0 commit comments

Comments
 (0)