forked from carbon-design-system/carbon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_form.scss
230 lines (196 loc) · 6.13 KB
/
_form.scss
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
//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//
@use '../../config' as *;
@use '../../spacing' as *;
@use '../../theme' as *;
@use '../../type' as *;
@use '../../utilities/convert' as *;
@use '../../utilities/focus-outline' as *;
@use '../../utilities/skeleton' as *;
@use '../..//utilities/button-reset';
/// @type Number
/// @access public
/// @group global-themes
$input-label-weight: 400 !default;
@mixin form {
// Override Chrome autocomplete styles
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus {
box-shadow: 0 0 0 1000px $field inset;
-webkit-text-fill-color: $text-primary;
}
.#{$prefix}--fieldset {
@include reset;
}
.#{$prefix}--form-item {
@include type-style('body-compact-01');
display: flex;
// We specify `auto` as the default value so that the form item does
// not collapse in IE11 due to a `flex-basis` of 0 only working with
// `flex-direction: row`
flex: 1 1 auto;
flex-direction: column;
align-items: flex-start;
}
.#{$prefix}--label {
@include reset;
@include type-style('label-01');
display: inline-block;
margin-bottom: $spacing-03;
color: $text-secondary;
font-weight: $input-label-weight;
line-height: 1rem;
vertical-align: baseline;
}
.#{$prefix}--label--no-margin {
margin-bottom: 0;
}
.#{$prefix}--label + .#{$prefix}--tooltip {
position: relative;
top: 0.2rem;
left: 0.5rem;
}
.#{$prefix}--label + .#{$prefix}--tooltip .#{$prefix}--tooltip__trigger {
@include button-reset.reset();
display: flex;
align-items: center;
justify-content: center;
@include type-style('label-01');
}
.#{$prefix}--label
+ .#{$prefix}--tooltip
.#{$prefix}--tooltip__trigger:focus {
outline: 1px solid $focus;
}
.#{$prefix}--label + .#{$prefix}--tooltip .#{$prefix}--tooltip__trigger svg {
fill: $icon-secondary;
}
.#{$prefix}--label
+ .#{$prefix}--tooltip
.#{$prefix}--tooltip__trigger
svg
:hover {
fill: $icon-primary;
}
.#{$prefix}--label + .#{$prefix}--toggletip {
top: 0.2rem;
left: 0.5rem;
}
// Skeleton State
.#{$prefix}--label.#{$prefix}--skeleton {
@include skeleton;
width: rem(75px);
height: rem(14px);
}
input[type='number'] {
font-family: font-family('sans');
}
input[data-invalid]:not(:focus),
.#{$prefix}--number[data-invalid] input[type='number']:not(:focus),
.#{$prefix}--text-input__field-wrapper[data-invalid]
> .#{$prefix}--text-input--invalid:not(:focus),
.#{$prefix}--text-area__wrapper[data-invalid]
> .#{$prefix}--text-area--invalid:not(:focus),
.#{$prefix}--select-input__wrapper[data-invalid]
.#{$prefix}--select-input:not(:focus),
.#{$prefix}--list-box[data-invalid]:not(:focus),
.#{$prefix}--combo-box[data-invalid]:not(.#{$prefix}--multi-select--selected)
.#{$prefix}--text-input:not(:focus) {
@include focus-outline('invalid');
}
input[data-invalid],
.#{$prefix}--number[data-invalid] .#{$prefix}--number__input-wrapper,
.#{$prefix}--number__input-wrapper--warning,
.#{$prefix}--date-picker-input__wrapper,
.#{$prefix}--date-picker-input__wrapper--warn,
.#{$prefix}--date-picker-input__wrapper--invalid,
.#{$prefix}--time-picker--invalid,
.#{$prefix}--text-input__field-wrapper[data-invalid],
.#{$prefix}--text-input__field-wrapper--warning,
.#{$prefix}--text-input__field-wrapper--warning > .#{$prefix}--text-input,
.#{$prefix}--text-area__wrapper[data-invalid],
.#{$prefix}--select-input__wrapper[data-invalid],
.#{$prefix}--select--warning .#{$prefix}--select-input__wrapper,
.#{$prefix}--time-picker[data-invalid],
.#{$prefix}--list-box[data-invalid],
.#{$prefix}--list-box--warning {
~ .#{$prefix}--form-requirement {
display: block;
overflow: visible;
max-height: rem(200px);
font-weight: 400;
}
}
input[data-invalid],
.#{$prefix}--number[data-invalid] .#{$prefix}--number__input-wrapper,
.#{$prefix}--date-picker-input__wrapper,
.#{$prefix}--date-picker-input__wrapper--invalid,
.#{$prefix}--time-picker--invalid,
.#{$prefix}--text-input__field-wrapper[data-invalid],
.#{$prefix}--text-area__wrapper[data-invalid],
.#{$prefix}--select-input__wrapper[data-invalid],
.#{$prefix}--time-picker[data-invalid],
.#{$prefix}--list-box[data-invalid] {
~ .#{$prefix}--form-requirement {
color: $text-error;
}
}
//Fluid Form
.#{$prefix}--form--fluid .#{$prefix}--text-input__field-wrapper[data-invalid],
.#{$prefix}--form--fluid .#{$prefix}--text-input__field-wrapper--warning {
display: block;
}
@if not enabled('enable-v11-release') {
.#{$prefix}--form--fluid .#{$prefix}--fieldset {
margin: 0;
}
}
.#{$prefix}--form--fluid input[data-invalid] {
outline: none;
}
.#{$prefix}--form--fluid .#{$prefix}--form-requirement {
padding: $spacing-03 rem(40px) $spacing-03 $spacing-05;
margin: 0;
}
// Fix for red ring when input is marked required in Firefox, refs #744
input:not(output):not([data-invalid]):-moz-ui-invalid {
box-shadow: none;
}
.#{$prefix}--form-requirement {
@include reset;
@include type-style('label-01');
display: none;
overflow: hidden;
max-height: 0;
margin: $spacing-02 0 0;
}
.#{$prefix}--select--inline .#{$prefix}--form__helper-text {
margin-top: 0;
}
.#{$prefix}--form__helper-text {
@include type-style('helper-text-01');
z-index: 0;
// Added to prevent error text from displaying under helper text in Safari (#6392)
width: 100%;
margin-top: $spacing-02;
color: $text-secondary;
opacity: 1;
}
.#{$prefix}--label--disabled,
.#{$prefix}--form__helper-text--disabled {
color: $text-disabled;
}
// If a FormGroup is disabled, Form labels and helper text nested inside should also be disabled
fieldset[disabled] .#{$prefix}--label,
fieldset[disabled] .#{$prefix}--form__helper-text {
color: $text-disabled;
}
}