1
1
import { FC } from 'react' ;
2
2
import styled , { css } from 'styled-components' ;
3
3
import { variant } from 'styled-system' ;
4
- import { Colors } from '../../essentials' ;
5
4
import { BaseInput , InternalInputComponentProps } from './BaseInput' ;
6
5
import { activeBoxedPosition , BoxedInputLabel } from './BoxedInputLabel' ;
6
+ import { getSemanticValue } from '../../utils/cssVariables' ;
7
+ import { InputProps } from './InputProps' ;
7
8
8
9
const errorStyles = css `
9
- box-shadow : inset 0 0 0 0.0625rem ${ Colors . NEGATIVE_ORANGE_900 } ;
10
- border-color : ${ Colors . NEGATIVE_ORANGE_900 } ;
10
+ box-shadow : inset 0 0 0 0.0625rem ${ getSemanticValue ( 'border-danger-emphasized' ) } ;
11
+ border-color : ${ getSemanticValue ( 'border-danger-emphasized' ) } ;
11
12
12
13
& ~ ${ BoxedInputLabel } {
13
- color : ${ Colors . NEGATIVE_ORANGE_900 } ;
14
+ color : ${ getSemanticValue ( 'text-dangerInverted' ) } ;
14
15
}
15
16
` ;
16
17
17
- const sizeVariant = variant ( {
18
+ const sizeVariant = variant < Record < string , unknown > , InputProps [ 'size' ] > ( {
18
19
prop : 'size' ,
19
20
variants : {
20
21
small : {
@@ -30,32 +31,32 @@ const sizeVariant = variant({
30
31
31
32
const getLabelColor = ( { hasValue, inverted } : InternalInputComponentProps ) => {
32
33
if ( inverted ) {
33
- return Colors . AUTHENTIC_BLUE_200 ;
34
+ return getSemanticValue ( 'text-secondaryInverted' ) ;
34
35
}
35
36
36
37
if ( hasValue ) {
37
- return Colors . AUTHENTIC_BLUE_550 ;
38
+ return getSemanticValue ( 'text-secondary' ) ;
38
39
}
39
40
40
- return Colors . AUTHENTIC_BLUE_350 ;
41
+ return getSemanticValue ( 'text-tertiary' ) ;
41
42
} ;
42
43
43
44
const BoxedInput : FC < InternalInputComponentProps > = styled ( BaseInput ) < InternalInputComponentProps > `
44
45
${ sizeVariant }
45
46
& + ${ BoxedInputLabel } {
46
- ${ p => ( p . hasValue || p . placeholder ? activeBoxedPosition ( p . size as Pick < InternalInputComponentProps , 'size' > ) : undefined ) } ;
47
+ ${ p => ( p . hasValue || p . placeholder ? activeBoxedPosition ( p . size ) : undefined ) } ;
47
48
color: ${ getLabelColor } ;
48
- background: ${ p => ( p . inverted ? Colors . AUTHENTIC_BLUE_900 : Colors . WHITE ) } ;
49
+ background: ${ p => getSemanticValue ( p . inverted ? 'background-primary-inverted' : 'background-primary-default' ) } ;
49
50
background: ${ p =>
50
- `linear-gradient(0deg, ${ p . inverted ? Colors . AUTHENTIC_BLUE_900 : Colors . WHITE } calc(50% + ${
51
- ( p . size as Pick < InternalInputComponentProps , 'size' > ) === 'small' ? '0.0825rem ' : '0.0625rem '
52
- } ), transparent 50%)`} ;
51
+ `linear-gradient(0deg, ${ getSemanticValue (
52
+ p . inverted ? 'background-primary-inverted ' : 'background-primary-default '
53
+ ) } calc(50% + ${ p . size === 'small' ? '0.0825rem' : '0.0625rem' } ), transparent 50%)`} ;
53
54
}
54
55
55
56
${ p => ( p . error ? errorStyles : undefined ) }
56
57
&:disabled {
57
58
& + ${ BoxedInputLabel } {
58
- color: ${ p => ( p . inverted ? Colors . AUTHENTIC_BLUE_550 : Colors . AUTHENTIC_BLUE_200 ) } ;
59
+ color: ${ p => getSemanticValue ( p . inverted ? 'text-disabledInverted' : 'text-disabled' ) } ;
59
60
}
60
61
}
61
62
@@ -64,19 +65,20 @@ const BoxedInput: FC<InternalInputComponentProps> = styled(BaseInput)<InternalIn
64
65
&:-webkit-autofill:focus,
65
66
&:-webkit-autofill:active {
66
67
& + ${ BoxedInputLabel } {
67
- ${ p => activeBoxedPosition ( p . size as Pick < InternalInputComponentProps , 'size' > ) } ;
68
+ ${ p => activeBoxedPosition ( p . size ) } ;
68
69
}
69
70
}
70
71
71
72
&:focus:not(:disabled) {
72
73
& + ${ BoxedInputLabel } {
73
- ${ p => activeBoxedPosition ( p . size as Pick < InternalInputComponentProps , 'size' > ) } ;
74
- color: ${ p => ( p . inverted ? Colors . WHITE : Colors . ACTION_BLUE_900 ) } ;
75
- background: ${ p => ( p . inverted ? Colors . AUTHENTIC_BLUE_900 : Colors . WHITE ) } ;
74
+ ${ p => activeBoxedPosition ( p . size ) } ;
75
+ color: ${ p => getSemanticValue ( p . inverted ? 'text-primaryInverted' : 'text-info' ) } ;
76
76
background: ${ p =>
77
- `linear-gradient(0deg, ${ p . inverted ? Colors . AUTHENTIC_BLUE_900 : Colors . WHITE } calc(50% + ${
78
- ( p . size as Pick < InternalInputComponentProps , 'size' > ) === 'small' ? '0.0825rem' : '0.0625rem'
79
- } ), transparent 50%)`} ;
77
+ getSemanticValue ( p . inverted ? 'background-primary-inverted' : 'background-primary-default' ) } ;
78
+ background: ${ p =>
79
+ `linear-gradient(0deg, ${ getSemanticValue (
80
+ p . inverted ? 'background-primary-inverted' : 'background-primary-default'
81
+ ) } calc(50% + ${ p . size === 'small' ? '0.0825rem' : '0.0625rem' } ), transparent 50%)`} ;
80
82
}
81
83
}
82
84
` ;
0 commit comments