-
Notifications
You must be signed in to change notification settings - Fork 46
/
input.css
249 lines (221 loc) · 7.59 KB
/
input.css
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
.input-base,
.input {
user-select: none;
appearance: none;
box-sizing: border-box;
/* Use the same color for the cursor */
caret-color: currentColor;
}
.label, .label-base {
padding: 0;
border: 0;
box-sizing: border-box;
font-family: inherit;
}
/* Electing to scope these as opposed to doing :root level definitions */
.field-error,
.field-error-large,
.field-error-small,
.label-skin,
.label,
.input-skin,
.input {
/* These custom props all fallback on the agnosticui main variables so main theme is preserved */
--agnosticui-input-error-color: var(--agnosticui-error-color, var(--agnosticui-secondary));
--agnosticui-input-font-color: var(--agnosticui-font-color, var(--agnosticui-dark));
--agnosticui-input-font-weight: var(--agnosticui-font-weight, 300);
--agnosticui-input-font-size: var(--agnosticui-font-size, var(--Space-16));
--agnosticui-input-label-font-size: calc(var(--agnosticui-input-font-size) - 2px);
--agnosticui-input-border-size: var(--agnosticui-border-size, 1px);
--agnosticui-input-border-color: var(--agnosticui-border-color, var(--agnosticui-gray-light));
--agnosticui-input-radius: var(--agnosticui-border-radius, var(--Space-4));
--agnosticui-input-underlined-color: var(--agnosticui-underlined-color, var(--agnosticui-gray-mid-dark));
--agnosticui-input-underlined-bg-color: var(--agnosticui-underlined-bg-color, var(--agnosticui-gray-extra-light));
/* TODO -- share these with agnosticui buttons */
--agnosticui-input-disabled-bg: var(--agnosticui-disabled-bg, var(--agnosticui-gray-light));
--agnosticui-input-disabled-color: var(--agnostic-disabled-color, var(--agnosticui-gray-dark));
/* these can be overriden, but it might mess with the balance of the inputheights across variants */
--agnosticui-input-vertical-pad: var(--agnosticui-vertical-pad, var(--Space-8));
--agnosticui-input-line-height: var(--agnosticui-line-height, 20px);
--agnosticui-input-side-padding: var(--agnosticui-side-padding, var(--Space-12));
--agnosticui-input-font-family: var(--agnosticui-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Ubuntu", "Fira Sans", Helvetica, "Droid Sans", "Helvetica Neue", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol");
--agnosticui-input-btn-radius: var(--agnosticui-border-radius, var(--Space-4));
color: var(--agnosticui-input-font-color);
font-family: var(--agnosticui-input-font-family);
font-weight: var(--agnosticui-input-font-weight);
font-size: var(--agnosticui-input-font-size);
line-height: var(--agnosticui-input-line-height);
width: 100%;
max-width: 100%;
}
.input-skin,
.input {
border-color: var(--agnosticui-input-border-size,
var(--agnosticui-default-btn-bgcolor)
);
/* seems like a reasonable default as chrome picks `outset` which results in a weird 3d effect */
border-style: solid;
/* this can be overriden, but it might mess with the balance of the button heights across variants */
border-width: var(--agnosticui-input-border-size);
border-color: var(--agnosticui-input-border-color);
padding-top: var(--agnosticui-input-vertical-pad);
padding-bottom: var(--agnosticui-input-vertical-pad);
padding-left: var(--agnosticui-input-side-padding);
padding-right: var(--agnosticui-input-side-padding);
/* Note we only want to set properties that we actually want
to transition in. For example, if we transition "all", the
inputs will "grow in" on page load—not a happy effect :) */
transition-property: box-shadow;
transition-duration: var(--agnosticui-timing-medium);
}
.label {
display: inline-block;
margin: 0 0 var(--agnosticui-input-vertical-pad);
vertical-align: initial;
}
/* Reset labels and field errors to be 2px less then input font size */
.field-error,
.label,
.label-skin {
font-size: var(--agnosticui-input-label-font-size);
}
.label-inline,
.input-inline {
width: auto;
}
/* When inlined, the margin-bottom will throw the label off-center with adjacent input */
.label-inline {
margin-top: 0;
margin-bottom: 0;
margin-left: 0;
margin-right: var(--agnosticui-input-side-padding);
}
/**
* Placeholder
*/
.input::-webkit-input-placeholder {
color: currentColor;
opacity: 0.5;
transition: opacity var(--agnosticui-timing-fast) ease-out;
}
.input::-moz-placeholder {
color: currentColor;
opacity: 0.5;
transition: opacity var(--agnosticui-timing-fast) ease-out;
}
.input::-ms-placeholder {
color: currentColor;
opacity: 0.5;
transition: opacity var(--agnosticui-timing-fast) ease-out;
}
.input:-ms-placeholder {
color: currentColor;
opacity: 0.5;
transition: opacity var(--agnosticui-timing-fast) ease-out;
}
/**
* Underlined inputs
*/
.input-underlined {
border-top: 0;
border-left: 0;
border-right: 0;
border-color: var(--agnosticui-input-underlined-color);
background-color: transparent;
}
.input-underlined-bg {
background-color: var(--agnosticui-input-underlined-bg-color);
}
/**
* Rounded inputs
*/
.input-rounded {
border-radius: var(--agnosticui-input-radius);
}
/**
* Errors
* We provide a class-based approach to setting errors which means we do
* not support :invalid, so it requires custom use of html4 validation API
* (see https://developer.mozilla.org/en-US/docs/Learn/Forms/Form_validation
* of the example in corresponding input.html file). The reason I elected to
* not include :invalid, is it seems to result in "shouting" at the user as
* I did not find an easy way to only kick in errors after a certain number
* of characters have been type (blur is actually better but I did not
* implement that in the contrived example).
*/
.label-error {
color: var(--agnosticui-input-error-color);
}
.input-error {
border-color: var(--agnosticui-input-error-color);
}
.label-error,
.field-error,
.field-error-small,
.field-error-large {
color: var(--agnosticui-input-error-color);
}
.field-error,
.field-error-small,
.field-error-large {
display: inline-block;
width: 100%;
margin: var(--agnosticui-input-vertical-pad) 0;
}
/**
* Sizes
*/
.input-large {
font-size: calc(var(--agnosticui-input-font-size) + var(--Space-4));
}
.field-error-large,
.label-large {
font-size: calc(var(--agnosticui-input-label-font-size) + 2px);
}
.input-large {
line-height: calc(var(--agnosticui-input-line-height) + var(--Space-4));
}
.input-small {
font-size: calc(var(--agnosticui-input-font-size) - var(--Space-4));
}
.field-error-small,
.label-small {
/* Since labels are already smaller, bringing them down var(--Space-4) here
just looks too small to my eye. */
font-size: calc(var(--agnosticui-input-label-font-size) - 2px);
}
.input-small {
line-height: calc(var(--agnosticui-input-line-height) - var(--Space-4));
}
.input:focus {
box-shadow: 0 0 0 3px rgba(55, 149, 225, 0.5);
/* High contrast mode outline */
outline: 3px solid transparent;
transition: box-shadow var(--agnosticui-timing-fast) ease-out;
}
/* Set the focus to transparent when there's an error since we use
borders that visually conflict. */
.input-error:focus {
box-shadow: 0 0 0 3px transparent;
}
/*
* Disabled State
*
* The disabled state uses the class .disabled,
* and the form attribute disabled="disabled".
* The use of !important is only added because this is a state
* that must be applied to all inputs when in a disabled state.
*/
.input.disabled,
.input:disabled {
/* High contrast mode outline hacks */
outline: 2px solid transparent;
outline-offset: -2px;
background: var(--agnosticui-input-disabled-bg) !important;
color: var(--agnosticui-input-disabled-color) !important;
cursor: default !important;
appearance: none !important;
box-shadow: none !important;
opacity: 0.8 !important;
cursor: not-allowed;
}