This repository is currently being migrated. It's locked while the migration is in progress.
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathinputs.scss
More file actions
425 lines (353 loc) · 9.6 KB
/
inputs.scss
File metadata and controls
425 lines (353 loc) · 9.6 KB
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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
// This is a copy of the entire ~uswds/src/stylesheets/elements/input.scss file
// so that we can convert the rem values for USWDS v3.
/*
Original: @import "~uswds/src/stylesheets/elements/inputs";
***THIS IS USWDS v1***
*/
@use '../../override-function' as *;
@use "../../../../dist/tokens/scss/variables" as tok;
@use "../../core-variables" as core-vars;
@use '../../mixins' as mix;
@use '../variables' as vars;
@use '../core/utilities' as util;
// scss-lint:disable QualifyingElement, PropertyCount
$input-line-height: 1.3;
$input-border-width: scale-rem(0.1rem); // Using rem instead of px so function uses same units
$input-padding-vertical: scale-rem(1rem);
// input heights will vary by browser and type
// if height not explicitly set
$input-height-exact: (
(vars.$base-font-size * $input-line-height) +
($input-padding-vertical * 2) +
($input-border-width * 2)
);
// truncated to 1 decimal place
// (i.e., 1.21rem -> 1.2rem)
$input-height: calc(floor($input-height-exact * 10) / 10);
// Block form elements
/* stylelint-disable selector-no-qualifying-type */
input,
textarea,
select {
appearance: none;
border: 1px solid vars.$color-gray;
border-radius: 0;
box-sizing: border-box;
color: tok.$vads-color-base; // standardize on firefox
display: block;
font-size: 16px;
height: 42px;
line-height: $input-line-height;
margin: 0.2em 0;
max-width: 460px;
padding: 10px 11.2px;
width: 100%;
&.usa-input-success {
border: 3px solid vars.$color-green-light;
}
}
/* stylelint-enable */
.usa-input-error {
border-left: 4px solid vars.$color-secondary-dark;
margin-top: scale-rem(3rem);
padding-bottom: scale-rem(0.8rem);
padding-left: scale-rem(1.5rem);
padding-top: scale-rem(0.8rem);
position: relative;
right: scale-rem(1.9rem);
input,
textarea,
select {
border: 3px solid vars.$color-secondary-dark;
width: calc(100% + scale-rem(1.9rem)); // 1.5rem left padding + 4px border from input error spacing
}
label {
margin-top: 0;
}
.usa-input-inline {
border: $input-border-width solid vars.$color-gray;
width: inherit;
}
.usa-input-inline-error {
border: 3px solid vars.$color-secondary-dark;
}
}
.usa-input-error-label {
display: block;
font-size: vars.$base-font-size;
font-weight: vars.$font-bold;
}
.usa-input-error-message {
color: vars.$color-secondary-dark;
display: block;
font-size: vars.$base-font-size;
font-weight: vars.$font-bold;
padding-bottom: 3px;
padding-top: 3px;
}
// Deprecated: Some screen readers can't read CSS content.
// Will be removed in 2.0.
.usa-input-required:after {
color: vars.$color-secondary-darkest;
content: ' (*required)';
}
// Deprecated: Some screen readers can't read CSS content.
// Will be removed in 2.0.
.usa-input-optional:after {
color: vars.$color-gray-medium;
content: ' (optional)';
}
.usa-input-label-helper {
color: vars.$color-gray-medium;
}
.usa-input-label-required {
color: vars.$color-secondary-darkest;
}
label {
display: block;
margin-top: scale-rem(3rem);
max-width: vars.$input-max-width;
}
textarea {
height: scale-rem(16rem);
}
select {
appearance: none;
background-color: tok.$vads-color-white;
background-image: url(~@department-of-veterans-affairs/css-library/dist/img/arrow-both.png);
// Ensure browsers that don't support SVG in background-image (IE 11 and below) fall back to PNG.
// See https://www.broken-links.com/2010/06/14/using-svg-in-backgrounds-with-png-fallback/
background-image: none, url(~@department-of-veterans-affairs/css-library/dist/img/arrow-both.svg), url(~@department-of-veterans-affairs/css-library/dist/img/arrow-both.png);
background-position: right scale-rem(1.3rem) center;
background-repeat: no-repeat;
background-size: scale-rem(1rem);
padding-right: scale-rem(3rem);
&::-ms-expand {
display: none;
}
// Show default webkit style on select element when autofilled to show icon
&:-webkit-autofill {
appearance: menulist;
}
// Remove dotted outline from select element on focus in Firefox
&:-moz-focusring {
color: transparent;
text-shadow: 0 0 0 tok.$vads-color-black;
}
}
option:first-child {
font-weight: vars.$font-bold;
}
legend {
font-size: vars.$h2-font-size;
font-weight: vars.$font-bold;
}
.usa-fieldset-inputs {
label {
margin-top: 0;
}
}
// Hint text
.usa-form-hint {
color: vars.$color-gray-medium;
font-family: tok.$font-family-sans;
margin-bottom: 0;
}
// Custom checkboxes
[type=checkbox],
[type=radio] {
// The actual input element is only visible to screen readers, because
// all visual styling is done via the label.
@include util.sr-only();
.lt-ie9 & {
border: 0;
float: left;
margin: 0.4em 0.4em 0 0;
position: static;
width: auto;
}
}
[type=checkbox] + label,
[type=radio] + label {
cursor: pointer;
font-weight: 400;
margin-bottom: 0.65em;
}
[type=checkbox] + label::before,
[type=radio] + label::before {
background: tok.$vads-color-white;
content: '\a0';
display: inline-block;
text-indent: 0.15em;
vertical-align: middle\0; // Target IE 11 and below to vertically center inputs
}
[type=checkbox] + label::before {
border-radius: vars.$checkbox-border-radius;
box-shadow: 0 0 0 1px vars.$color-gray-medium;
height: vars.$spacing-medium;
line-height: vars.$spacing-medium;
margin-left: 1px;
margin-right: 0.6em;
width: vars.$spacing-medium;
}
[type=radio] + label::before {
border-radius: 100%;
box-shadow: 0 0 0 2px tok.$vads-color-white, 0 0 0 3px vars.$color-gray-medium;
height: scale-rem(1.4rem); // Size overrides to account for shape + checked styling
line-height: scale-rem(1.4rem);
margin-left: 3px;
margin-right: scale-rem(0.75em);
width: scale-rem(1.4rem);
}
[type=checkbox]:checked + label::before,
[type=radio]:checked + label::before {
background-color: vars.$color-primary;
box-shadow: 0 0 0 1px vars.$color-primary;
}
[type=radio]:checked + label::before {
box-shadow: 0 0 0 2px tok.$vads-color-white, 0 0 0 4px vars.$color-primary;
}
[type=checkbox]:checked + label::before,
[type=checkbox]:checked:disabled + label::before {
background-image: url(~@department-of-veterans-affairs/css-library/dist/img/correct8.png);
background-image: url(~@department-of-veterans-affairs/css-library/dist/img/correct8.svg);
background-position: 50%;
background-repeat: no-repeat;
}
[type=radio]:focus + label::before {
outline: mix.$focus-outline;
outline-offset: mix.$focus-spacing * 2; // Double the offset to account for circular shape
}
[type=checkbox]:disabled + label {
color: vars.$color-gray-lighter;
}
[type=checkbox]:focus + label::before {
outline: mix.$focus-outline;
outline-offset: mix.$focus-spacing;
}
[type=checkbox]:disabled + label::before,
[type=radio]:disabled + label::before {
background: vars.$color-gray-lightest;
box-shadow: 0 0 0 1px vars.$color-gray-light;
cursor: not-allowed;
}
@media print {
[type=checkbox]:checked + label::before,
[type=checkbox]:checked:disabled + label::before {
background-image: none;
background-color: tok.$vads-color-white;
content: url(~@department-of-veterans-affairs/css-library/dist/img/correct8-alt.png);
content: url(~@department-of-veterans-affairs/css-library/dist/img/correct8-alt.svg);
text-indent: 0;
}
[type=radio]:checked:disabled + label::before,
[type=radio]:checked + label::before {
box-shadow: 0 0 0 2px tok.$vads-color-white, inset 0 0 0 14px vars.$color-primary, 0 0 0 4px vars.$color-primary;
}
}
// Range inputs
// Change to $color-focus in 2.0
@mixin range-focus {
box-shadow: 0 0 0 2px vars.$color-primary;
}
@mixin range-track {
background: vars.$color-gray-lighter;
border: 1px solid vars.$color-gray-medium;
cursor: pointer;
height: scale-rem(1.6rem);
width: 100%;
}
@mixin range-thumb {
background: vars.$color-gray-lightest;
box-shadow: 0 0 0 1px vars.$color-gray-medium;
border-radius: scale-rem(1.5rem);
cursor: pointer;
height: scale-rem(2.5rem);
width: scale-rem(2.5rem);
}
@mixin range-ms-fill {
background: vars.$color-gray-light;
border: 1px solid vars.$color-gray-medium;
border-radius: scale-rem(2rem);
}
[type=range] {
appearance: none;
border: none;
padding-left: 0;
overflow: hidden;
width: 100%;
&:focus {
outline: none;
&::-webkit-slider-thumb {
@include range-focus;
}
&::-moz-range-thumb {
@include range-focus;
}
&::-ms-thumb {
@include range-focus;
}
}
&::-webkit-slider-runnable-track {
@include range-track;
}
&::-moz-range-track {
@include range-track;
}
&::-ms-track {
@include range-track;
}
&::-webkit-slider-thumb {
@include range-thumb;
appearance: none;
margin-top: scale-rem(-0.6rem);
}
&::-moz-range-thumb {
@include range-thumb;
}
&::-ms-thumb {
@include range-thumb;
}
&::-ms-fill-lower {
@include range-ms-fill;
}
&::-ms-fill-upper {
@include range-ms-fill;
}
}
// File input type
[type='file'] {
border: none;
padding-left: 0;
}
// Memorable dates
.usa-date-of-birth { /* stylelint-disable-line */
label {
margin-top: 0;
}
[type=number] {
-moz-appearance: textfield;
&::-webkit-inner-spin-button {
appearance: none;
}
&::-webkit-contacts-auto-fill-button {
visibility: hidden;
display: none !important; /* stylelint-disable-line declaration-no-important */
pointer-events: none;
height: 0;
width: 0;
margin: 0;
}
}
}
.usa-form-group-day,
.usa-form-group-month,
.usa-form-group-year {
clear: none;
float: left;
margin-right: scale-rem(1.5rem);
width: scale-rem(5rem);
}
.usa-form-group-year {
width: scale-rem(7rem);
}