Skip to content

Commit 80275e3

Browse files
authored
fix charCounter state colors; shorting constants names (#653)
1 parent f1819fd commit 80275e3

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/components/inputs/TextField.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,26 @@ import Image from '../image';
1818
import Text from '../text';
1919
import TouchableOpacity from '../touchableOpacity';
2020

21-
const DEFAULT_COLOR_BY_STATE = {
21+
22+
const COLOR_BY_STATE = {
2223
default: Colors.grey10,
2324
focus: Colors.grey10,
2425
error: Colors.grey10,
2526
disabled: Colors.grey50
2627
};
27-
const DEFAULT_UNDERLINE_COLOR_BY_STATE = {
28+
const UNDERLINE_COLOR_BY_STATE = {
2829
default: Colors.grey50,
2930
focus: Colors.blue30,
3031
error: Colors.red30
3132
};
32-
33-
const DEFAULT_PLACEHOLDER_COLOR_BY_STATE = {
33+
const PLACEHOLDER_COLOR_BY_STATE = {
3434
default: Colors.grey30,
3535
focus: Colors.blue30
3636
};
37+
const CHAR_COUNTER_COLOR_BY_STATE = {
38+
default: Colors.grey30,
39+
error: Colors.red30
40+
};
3741

3842
const LABEL_TYPOGRAPHY = Typography.text80;
3943
const ICON_SIZE = 24;
@@ -254,7 +258,7 @@ export default class TextField extends BaseInput {
254258
if (_.isString(colorProp)) {
255259
return colorProp || Colors.dark10;
256260
} else if (_.isPlainObject(colorProp)) {
257-
const mergedColorState = {...DEFAULT_COLOR_BY_STATE, ...colorProp};
261+
const mergedColorState = {...COLOR_BY_STATE, ...colorProp};
258262

259263
if (this.isDisabled()) {
260264
return disabledColor || mergedColorState.disabled;
@@ -344,7 +348,7 @@ export default class TextField extends BaseInput {
344348
const {floatingPlaceholderState} = this.state;
345349
const {expandable, placeholder, placeholderTextColor, floatingPlaceholderColor, multiline} = this.getThemeProps();
346350
const typography = this.getTypography();
347-
const placeholderColor = this.getStateColor(placeholderTextColor || DEFAULT_PLACEHOLDER_COLOR_BY_STATE.default);
351+
const placeholderColor = this.getStateColor(placeholderTextColor || PLACEHOLDER_COLOR_BY_STATE.default);
348352

349353
if (this.shouldFakePlaceholder()) {
350354
return (
@@ -367,7 +371,7 @@ export default class TextField extends BaseInput {
367371
inputRange: [0, 1],
368372
outputRange: [
369373
placeholderColor,
370-
this.getStateColor(floatingPlaceholderColor || DEFAULT_PLACEHOLDER_COLOR_BY_STATE)
374+
this.getStateColor(floatingPlaceholderColor || PLACEHOLDER_COLOR_BY_STATE)
371375
]
372376
}),
373377
lineHeight: this.shouldFloatPlaceholder() ? LABEL_TYPOGRAPHY.lineHeight : typography.lineHeight
@@ -386,7 +390,7 @@ export default class TextField extends BaseInput {
386390

387391
renderTitle() {
388392
const {floatingPlaceholder, title, titleColor, titleStyle} = this.getThemeProps();
389-
const color = this.getStateColor(titleColor || DEFAULT_PLACEHOLDER_COLOR_BY_STATE);
393+
const color = this.getStateColor(titleColor || PLACEHOLDER_COLOR_BY_STATE);
390394

391395
if (!floatingPlaceholder && title) {
392396
return <Text style={[{color}, this.styles.topLabel, this.styles.label, titleStyle]}>{title}</Text>;
@@ -400,7 +404,7 @@ export default class TextField extends BaseInput {
400404
if (maxLength && showCharacterCounter) {
401405
const counter = this.getCharCount();
402406
const textColor =
403-
this.isCounterLimit() && focused ? DEFAULT_COLOR_BY_STATE.error : DEFAULT_COLOR_BY_STATE.default;
407+
this.isCounterLimit() && focused ? CHAR_COUNTER_COLOR_BY_STATE.error : CHAR_COUNTER_COLOR_BY_STATE.default;
404408
const color = this.isDisabled() && disabledColor ? disabledColor : textColor;
405409

406410
return (
@@ -519,7 +523,7 @@ export default class TextField extends BaseInput {
519523
];
520524

521525
const placeholderText = this.getPlaceholderText();
522-
const placeholderColor = this.getStateColor(placeholderTextColor || DEFAULT_PLACEHOLDER_COLOR_BY_STATE.default);
526+
const placeholderColor = this.getStateColor(placeholderTextColor || PLACEHOLDER_COLOR_BY_STATE.default);
523527
const isEditable = !this.isDisabled() && !expandable;
524528

525529
return (
@@ -579,7 +583,7 @@ export default class TextField extends BaseInput {
579583

580584
render() {
581585
const {expandable, containerStyle, underlineColor, useTopErrors, hideUnderline} = this.getThemeProps();
582-
const underlineStateColor = this.getStateColor(underlineColor || DEFAULT_UNDERLINE_COLOR_BY_STATE);
586+
const underlineStateColor = this.getStateColor(underlineColor || UNDERLINE_COLOR_BY_STATE);
583587

584588
return (
585589
<View style={[this.styles.container, containerStyle]} collapsable={false}>

0 commit comments

Comments
 (0)