@@ -18,22 +18,26 @@ import Image from '../image';
18
18
import Text from '../text' ;
19
19
import TouchableOpacity from '../touchableOpacity' ;
20
20
21
- const DEFAULT_COLOR_BY_STATE = {
21
+
22
+ const COLOR_BY_STATE = {
22
23
default : Colors . grey10 ,
23
24
focus : Colors . grey10 ,
24
25
error : Colors . grey10 ,
25
26
disabled : Colors . grey50
26
27
} ;
27
- const DEFAULT_UNDERLINE_COLOR_BY_STATE = {
28
+ const UNDERLINE_COLOR_BY_STATE = {
28
29
default : Colors . grey50 ,
29
30
focus : Colors . blue30 ,
30
31
error : Colors . red30
31
32
} ;
32
-
33
- const DEFAULT_PLACEHOLDER_COLOR_BY_STATE = {
33
+ const PLACEHOLDER_COLOR_BY_STATE = {
34
34
default : Colors . grey30 ,
35
35
focus : Colors . blue30
36
36
} ;
37
+ const CHAR_COUNTER_COLOR_BY_STATE = {
38
+ default : Colors . grey30 ,
39
+ error : Colors . red30
40
+ } ;
37
41
38
42
const LABEL_TYPOGRAPHY = Typography . text80 ;
39
43
const ICON_SIZE = 24 ;
@@ -254,7 +258,7 @@ export default class TextField extends BaseInput {
254
258
if ( _ . isString ( colorProp ) ) {
255
259
return colorProp || Colors . dark10 ;
256
260
} else if ( _ . isPlainObject ( colorProp ) ) {
257
- const mergedColorState = { ...DEFAULT_COLOR_BY_STATE , ...colorProp } ;
261
+ const mergedColorState = { ...COLOR_BY_STATE , ...colorProp } ;
258
262
259
263
if ( this . isDisabled ( ) ) {
260
264
return disabledColor || mergedColorState . disabled ;
@@ -344,7 +348,7 @@ export default class TextField extends BaseInput {
344
348
const { floatingPlaceholderState} = this . state ;
345
349
const { expandable, placeholder, placeholderTextColor, floatingPlaceholderColor, multiline} = this . getThemeProps ( ) ;
346
350
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 ) ;
348
352
349
353
if ( this . shouldFakePlaceholder ( ) ) {
350
354
return (
@@ -367,7 +371,7 @@ export default class TextField extends BaseInput {
367
371
inputRange : [ 0 , 1 ] ,
368
372
outputRange : [
369
373
placeholderColor ,
370
- this . getStateColor ( floatingPlaceholderColor || DEFAULT_PLACEHOLDER_COLOR_BY_STATE )
374
+ this . getStateColor ( floatingPlaceholderColor || PLACEHOLDER_COLOR_BY_STATE )
371
375
]
372
376
} ) ,
373
377
lineHeight : this . shouldFloatPlaceholder ( ) ? LABEL_TYPOGRAPHY . lineHeight : typography . lineHeight
@@ -386,7 +390,7 @@ export default class TextField extends BaseInput {
386
390
387
391
renderTitle ( ) {
388
392
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 ) ;
390
394
391
395
if ( ! floatingPlaceholder && title ) {
392
396
return < Text style = { [ { color} , this . styles . topLabel , this . styles . label , titleStyle ] } > { title } </ Text > ;
@@ -400,7 +404,7 @@ export default class TextField extends BaseInput {
400
404
if ( maxLength && showCharacterCounter ) {
401
405
const counter = this . getCharCount ( ) ;
402
406
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 ;
404
408
const color = this . isDisabled ( ) && disabledColor ? disabledColor : textColor ;
405
409
406
410
return (
@@ -519,7 +523,7 @@ export default class TextField extends BaseInput {
519
523
] ;
520
524
521
525
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 ) ;
523
527
const isEditable = ! this . isDisabled ( ) && ! expandable ;
524
528
525
529
return (
@@ -579,7 +583,7 @@ export default class TextField extends BaseInput {
579
583
580
584
render ( ) {
581
585
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 ) ;
583
587
584
588
return (
585
589
< View style = { [ this . styles . container , containerStyle ] } collapsable = { false } >
0 commit comments