@@ -4,66 +4,84 @@ import { InputProps } from 'src';
4
4
5
5
interface InputWarp extends ThemeVariantValueOptions , Pick < InputProps , 'size' | 'addonAfter' | 'disabled' > { }
6
6
7
- export const Input = styled . input `
8
- outline : none;
9
- border : none;
10
- border-radius : 3px ;
11
- box-shadow : 0 0 0 0 rgba (19 , 124 , 189 , 0 ), 0 0 0 0 rgba (19 , 124 , 189 , 0 ), inset 0 0 0 1px rgba (16 , 22 , 26 , 0.15 ),
12
- inset 0 1px 1px rgba (16 , 22 , 26 , 0.2 );
13
- box-sizing : border-box;
14
- background : # fff ;
15
- height : 30px ;
16
- margin : 0 !important ;
17
- padding : 0 10px ;
18
- vertical-align : middle;
19
- line-height : 30px ;
20
- color : # 393e48 ;
21
- font-weight : 400 ;
22
- font-size : inherit;
23
- transition : box-shadow 0.3s cubic-bezier (0.4 , 1 , 0.75 , 0.9 );
24
- appearance : none;
25
- & : not (: first-child ) {
26
- padding-left : 26px ;
27
- }
28
- & : focus {
29
- box-shadow : 0 0 0 1px # 393e48, 0 0 0 3px rgba (57 , 62 , 72 , 0.17 ), inset 0 1px 1px rgba (16 , 22 , 26 , 0.2 );
30
- }
31
- & : hover {
32
- box-shadow : 0 0 0 1px # 6e6e6e, 0 0 0 3px rgba (57 , 62 , 72 , 0 ), inset 0 1px 1px rgba (16 , 22 , 26 , 0.2 );
33
- }
34
- & : focus & : hover {
35
- box-shadow : 0 0 0 1px # 6e6e6e, 0 0 0 3px rgba (57 , 62 , 72 , 0.17 ), inset 0 1px 1px rgba (16 , 22 , 26 , 0.2 );
36
- }
37
- & : disabled {
38
- box-shadow : none;
39
- background : # dddddd ;
40
- opacity : 0.75 ;
41
- color : # a5a5a5 ;
42
- cursor : not-allowed;
43
- resize : none;
44
- }
7
+ export const Input = styled . input < InputWarp > `
8
+ ${ ( props ) => {
9
+ const boxShadowColorInputBase = getThemeVariantValue ( props , `boxShadowColorInputBase` ) ;
10
+ const boxShadowColorInputInsHBase = getThemeVariantValue ( props , `boxShadowColorInputInsHBase` ) ;
11
+ const boxShadowColorInputInsVBase = getThemeVariantValue ( props , `boxShadowColorInputInsVBase` ) ;
12
+ const boxShadowColorInputVFocus = getThemeVariantValue ( props , `boxShadowColorInputVFocus` ) ;
13
+ const boxShadowColorInputHHover = getThemeVariantValue ( props , `boxShadowColorInputHHover` ) ;
14
+
15
+ return css `
16
+ outline : none;
17
+ border : none;
18
+ border-radius : 3px ;
19
+ box-shadow : 0 0 0 0 ${ boxShadowColorInputBase } , 0 0 0 0 ${ boxShadowColorInputBase } ,
20
+ inset 0 0 0 1px ${ boxShadowColorInputInsHBase } , inset 0 1px 1px ${ boxShadowColorInputInsVBase } ;
21
+ box-sizing : border-box;
22
+ background : ${ getThemeVariantValue ( props , `backgroundColorInputBase` ) } ;
23
+ height : ${ getThemeVariantValue ( props , `heightInputDefault` ) } ;
24
+ margin : 0 !important ;
25
+ padding : 0 10px ;
26
+ vertical-align : middle;
27
+ line-height : ${ getThemeVariantValue ( props , `heightInputDefault` ) } ;
28
+ color : ${ getThemeVariantValue ( props , `colorInputBase` ) } ;
29
+ font-weight : 400 ;
30
+ font-size : ${ getThemeVariantValue ( props , `fontSizeInputDefault` ) } ;
31
+ transition : box-shadow 0.3s cubic-bezier (0.4 , 1 , 0.75 , 0.9 );
32
+ appearance : none;
33
+ & : not (: first-child ) {
34
+ padding-left : 26px ;
35
+ }
36
+ & : focus {
37
+ box-shadow : 0 0 0 1px ${ getThemeVariantValue ( props , `boxShadowColorInputHFocus` ) } ,
38
+ 0 0 0 3px ${ boxShadowColorInputVFocus } , inset 0 1px 1px ${ boxShadowColorInputInsVBase } ;
39
+ }
40
+ & : hover {
41
+ box-shadow : 0 0 0 1px ${ boxShadowColorInputHHover } ,
42
+ 0 0 0 3px ${ getThemeVariantValue ( props , `boxShadowColorInputVHover` ) } ,
43
+ inset 0 1px 1px ${ boxShadowColorInputInsVBase } ;
44
+ }
45
+ & : focus & : hover {
46
+ box-shadow : 0 0 0 1px ${ boxShadowColorInputHHover } , 0 0 0 3px ${ boxShadowColorInputVFocus } ,
47
+ inset 0 1px 1px ${ boxShadowColorInputInsVBase } ;
48
+ }
49
+ & : disabled {
50
+ box-shadow : none;
51
+ background : ${ getThemeVariantValue ( props , `backgrounColorInputDisabled` ) } ;
52
+ opacity : 0.75 ;
53
+ color : ${ getThemeVariantValue ( props , `colorInputDisabled` ) } ;
54
+ cursor : not-allowed;
55
+ resize : none;
56
+ }
57
+ ` ;
58
+ } }
45
59
` ;
46
60
47
- export const InputAddonAfter = styled . span `
48
- position : absolute;
49
- top : 3px ;
50
- right : 3px ;
51
- display : flex;
52
- bottom : 3px ;
53
- > * {
54
- display : flex !important ;
55
- align-items : center;
56
- }
61
+ export const InputAddonAfter = styled . span < InputWarp > `
62
+ ${ ( props ) => {
63
+ return css `
64
+ position : absolute;
65
+ top : ${ getThemeVariantValue ( props , `topInputAddonAfter` ) } ;
66
+ right : ${ getThemeVariantValue ( props , `topInputAddonAfter` ) } ;
67
+ display : flex;
68
+ bottom : ${ getThemeVariantValue ( props , `topInputAddonAfter` ) } ;
69
+ > * {
70
+ display : flex !important ;
71
+ align-items : center;
72
+ }
73
+ ` ;
74
+ } }
57
75
` ;
58
76
59
77
const InputWarp = styled . div < InputWarp > `
60
78
position: relative;
61
79
font-size: ${ ( props ) => getThemeVariantValue ( props , 'fontSizeDefault' ) } ;
62
- line-height: '14px' ;
63
- width: 100% ;
80
+ line-height: ${ ( props ) => getThemeVariantValue ( props , 'lineHeightInputsDefault' ) } ;
81
+ width: ${ ( props ) => getThemeVariantValue ( props , 'widthInputsDefault' ) } ;
64
82
65
83
& ${ Input } {
66
- width: 100% ;
84
+ width: ${ ( props ) => getThemeVariantValue ( props , 'widthInputsDefault' ) } ;
67
85
}
68
86
69
87
> .w-icon {
@@ -76,10 +94,10 @@ const InputWarp = styled.div<InputWarp>`
76
94
${ ( props ) => {
77
95
if ( props . size === 'large' ) {
78
96
return css `
79
- font-size : ${ ( props ) => getThemeVariantValue ( props , 'fontSizeLarge' ) } ;
97
+ font-size : ${ getThemeVariantValue ( props , 'fontSizeLarge' ) } ;
80
98
${ Input } {
81
- line-height : 36 px ;
82
- height : 36 px ;
99
+ line-height : ${ getThemeVariantValue ( props , 'lineHeightInputLarge' ) } ;
100
+ height : ${ getThemeVariantValue ( props , 'lineHeightInputLarge' ) } ;
83
101
}
84
102
` ;
85
103
}
@@ -90,29 +108,57 @@ const InputWarp = styled.div<InputWarp>`
90
108
return css `
91
109
min-width : 20px ;
92
110
${ Input } {
93
- line-height : 24 px ;
94
- height : 24 px ;
111
+ line-height : ${ getThemeVariantValue ( props , 'lineHeightInputSmall' ) } ;
112
+ height : ${ getThemeVariantValue ( props , 'lineHeightInputSmall' ) } ;
95
113
padding : 0 6px ;
96
114
& : not (: first-child ) {
97
115
padding-left : 26px ;
98
116
}
99
117
}
100
118
${ InputAddonAfter } {
101
119
> * {
102
- line-height : 16 px ;
103
- min-height : 16 px ;
120
+ line-height : ${ getThemeVariantValue ( props , 'lineHeightInputAddonAfter' ) } ;
121
+ min-height : ${ getThemeVariantValue ( props , 'lineHeightInputAddonAfter' ) } ;
104
122
}
105
123
}
106
124
` ;
107
125
}
108
126
} }
109
127
` ;
110
128
129
+ Input . defaultProps = {
130
+ defaultTheme : {
131
+ colorInputBase : '#393e48' ,
132
+ boxShadowColorInputHBase : 'rgba(19, 124, 189, 0)' ,
133
+ boxShadowColorInputInsHBase : 'rgba(16, 22, 26, 0.15)' ,
134
+ boxShadowColorInputInsVBase : 'rgba(16, 22, 26, 0.2)' ,
135
+ backgroundColorInputBase : '#fff' ,
136
+ heightInputDefault : '30px' ,
137
+ fontSizeInputDefault : 'inherit' ,
138
+ boxShadowColorInputHFocus : '#393e48' ,
139
+ boxShadowColorInputVFocus : 'rgba(57, 62, 72, 0.17)' ,
140
+ boxShadowColorInputHHover : '#6e6e6e' ,
141
+ boxShadowColorInputVHover : 'rgba(57, 62, 72, 0)' ,
142
+ backgrounColorInputDisabled : '#dddddd' ,
143
+ colorInputDisabled : '#a5a5a5' ,
144
+ } ,
145
+ } ;
146
+
147
+ InputAddonAfter . defaultProps = {
148
+ defaultTheme : {
149
+ topInputAddonAfter : '3px' ,
150
+ } ,
151
+ } ;
152
+
111
153
InputWarp . defaultProps = {
112
154
defaultTheme : {
113
- fontSizeSmall : '12px' ,
114
155
fontSizeDefault : '14px' ,
115
156
fontSizeLarge : '16px' ,
157
+ lineHeightInputsDefault : '14px' ,
158
+ widthInputsDefault : '100%' ,
159
+ lineHeightInputLarge : '36px' ,
160
+ lineHeightInputSmall : '24px' ,
161
+ lineHeightInputAddonAfter : '16px' ,
116
162
} ,
117
163
} ;
118
164
0 commit comments