-
Notifications
You must be signed in to change notification settings - Fork 96
/
Form.scss
417 lines (346 loc) · 9.46 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
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
.form {
height: 100%;
min-height: 0;
max-height: 100%;
padding-bottom: 0;
display: flex;
flex-direction: column;
> fieldset {
flex: 1 1 auto;
}
> .btn-toolbar {
min-height: $toolbar-total-height;
margin-bottom: 0;
border-top: 1px solid $border-color;
padding-top: 13px;
.form-group {
margin-bottom: 0;
}
}
.panel--padded > & {
margin-left: -$panel-padding-x;
margin-right: -$panel-padding-x;
}
}
.form--padded {
> fieldset,
.btn-toolbar {
min-height: $toolbar-total-height;
padding: $spacer * .625 $grid-gutter-width-half;
}
}
// Form divider lines
.form__divider::after,
.form-group::after {
border-bottom: 1px solid $border-color-light;
visibility: visible;
width: 100%;
content: "\0020";
display: block;
}
.form__divider::after {
margin: $spacer 0;
}
.form-group::after {
margin: $spacer 0 #{-$spacer};
}
// Remove underline and column offset. Used on places like tree batch actions.
// Apply form--no-dividers to a form element, or form-field--no-divider to an individal
// form field.
.form--no-dividers .form-group,
.form-field--no-divider {
padding-bottom: 0;
&::after {
visibility: hidden;
content: "";
display: none;
}
}
.form-group {
padding-bottom: $spacer;
.form-group {
padding-bottom: 0;
&::after {
border-bottom: 0;
margin: 0;
visibility: hidden;
}
}
// Reset .file bootstrap overrides to default styles
// TODO rename .file to a different class name as it conflicts with default bootstrap
&.file {
height: auto;
display: block;
cursor: auto;
position: static;
}
// TODO Fix for when the .form-group--no-label class is used but there is actually a label
&.form-group--no-label:not(.stacked) .form__field-label + .form__field-holder {
margin-left: 0;
}
&.field--merge-below:after {
border-bottom: 0;
box-shadow: none;
}
}
.form__field-label {
// If word is to long force break with hyphenation
@include break-word();
}
.form__field-holder {
max-width: $input-max-width;
margin-bottom: auto;
}
.form__field-message {
display: block;
margin: 0.5em 0;
&--error {
color: $red;
}
}
.form__field-extra-label,
.form__field-description {
color: $text-muted;
margin-top: $input-padding-y;
margin-bottom: $input-padding-y;
font-size: $font-size-sm;
&:empty {
display: none;
}
}
.form__field-extra-label {
font-style: italic;
}
// Icons used in readonly fields (eg URL field in assetAdmin)
.form-control-static__icon::before {
color: lighten($text-muted, 20%);
vertical-align: middle;
margin-right: 6px;
}
// Readonlys should be converted to an input
.form__field-holder p.readonly,
.form__field-holder input.readonly,
.form__field-holder span.readonly,
.readonly .form__field-holder > div {
padding-top: $input-padding-y;
padding-bottom: $input-padding-y;
padding-left: $input-btn-padding-x;
padding-right: $input-btn-padding-x;
margin-bottom: 0;
background-color: $input-disabled-bg;
border: 1px solid darken($input-disabled-bg, 3%);
@include border-radius($input-border-radius);
&:focus {
border-color: $input-focus-border-color;
outline: none;
}
}
// Fix for IE inputs not holding line-height
input[type="text"] {
min-height: calc(#{$line-height-base} + #{$input-padding-y} * 2 + #{$input-btn-border-width} * 2);
}
// Radio / Checkbox
input[type="checkbox"],
input[type="radio"],
input.checkbox,
input.radio {
display: inline;
margin-right: 6px;
}
// Grouped/Nested form fields
// Nested as only as a fix for date fields within the filter panel
.form__fieldgroup > .form__fieldgroup-item {
display: inline-block;
margin-right: map_get($spacers, 2);
margin-top: 8px;
min-width: 166px;
vertical-align: bottom; // Align fields with no labels
}
.form__fieldgroup-label {
display: block;
font-size: $font-size-sm;
color: $text-muted;
}
.cms-edit-form .form__field-holder--stacked {
.form__field-label {
padding-left: 0;
padding-right: 0;
}
.form__field-holder {
margin-left: -$grid-gutter-width-half;
}
}
@mixin form-responsive($breakpoint-inline, $breakpoint-inline-limit-width, $breakpoint-inline-limit-width-max) {
@include media-breakpoint-up($breakpoint-inline) {
.form-group {
@include make-row();
// Composite fields
// TODO reduce nesting
.form__field-holder .form-group {
.form__field-holder,
.form__field-label {
@include make-col-ready();
@include make-col(12);
}
.form__field-holder {
margin-left: 0;
left: 0;
&.form-check {
margin-left: $panel-padding-x;
left: 0;
}
}
// TODO make label display on the right side like normal .form__field-extra-label
.form__field-extra-label {
@include make-col(12);
margin-left: 0;
}
}
&::after {
margin: $spacer $grid-gutter-width-half #{-$spacer};
width: calc(100% - #{$grid-gutter-width}); // IE10 fix for avoiding horizontal scrollbars
}
&:not(.stacked) {
.form__field-label {
@include make-col(3);
// Override the `<label>` default with .form-control-label styles
padding-top: $input-padding-y;
padding-bottom: $input-padding-y;
margin-bottom: 0;
display: block;
}
.form__field-holder {
@include make-col-ready();
@include make-col(9);
}
}
}
.form-group.checkbox > .form__field-holder,
.form-group--no-label > .form__field-holder,
.form__field-holder--no-label {
@include make-col-offset(3);
// IE For some reason in IE10 the gutters are not accounted for in the offset (perhaps box-sizing issue)
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
left: $grid-gutter-width;
}
}
.form__field-label {
@include make-col-ready();
@include make-col(12);
}
.stacked .form__field-holder {
@include make-col-ready();
@include make-col(12);
max-width: 100%;
}
// Outer CompositeField doesn't have label but inner CompositeField does
.form-group--no-label .form-group .form__field-holder {
margin-left: 0;
}
.form__field-extra-label {
@include make-col-ready();
@include make-col(9);
@include make-col-offset(2);
// IE10 Possibly scrollbar effects the width to push columns
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
margin-left: 0;
}
}
.optionset,
.selection-group {
margin-top: 7px;
}
}
@include media-breakpoint-up($breakpoint-inline-limit-width) {
.form-group:not(.stacked) {
.form__field-label {
@include make-col(2);
}
.form__field-holder {
@include make-col(8);
// IE10 Possibly scrollbar effects the width to push columns
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
@include make-col(6);
}
}
}
.form-group--no-label .form__field-holder,
.form__field-holder--no-label {
@include make-col-offset(2);
}
.form-group.checkbox .form__field-holder {
// Based off of make-col-offset() mixin but adding the panel padding-x to offset
// the checkbox width
$_field-margin-left: percentage(calc(2 / $grid-columns));
margin-left: calc(#{$_field-margin-left} + #{$panel-padding-x});
}
.stacked .form__field-holder {
@include make-col(10);
}
// HTML editor to expand to maximise to the space
.form-group.htmleditor {
.form__field-holder {
@include make-col(12);
}
}
.form__field-extra-label {
@include make-col(2);
margin-left: 0;
}
}
@include media-breakpoint-up($breakpoint-inline-limit-width-max) {
.form-group:not(.stacked) {
.form__field-holder {
@include make-col(7);
}
}
// Max-width to visually match other stacked fields + label
.form-group.htmleditor.stacked .form__field-holder {
@include make-col(12);
max-width: calc(#{$input-max-width} + 16.66667%);
// IE 11 renders the field wider than 100% with the above max-width
@media all and (-ms-high-contrast: none) {
*::-ms-backdrop,
& {
max-width: 100%;
}
}
}
.form__field-extra-label {
@include make-col(3);
margin-left: 0;
// IE10 Possibly scrollbar effects the width to push columns
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
@include make-col(1);
}
}
}
}
// Fix height of date-fields collapsing in IE
input[type=date],
input[type=time],
input[type=datetime-local],
input[type=month] {
&.form-control {
min-height: calc(#{$input-padding-y} * 2 + #{$line-height-base} + 2px);
// Reduce huge line-height for BS date-fields
@media screen and (-webkit-min-device-pixel-ratio: 0) {
line-height: $line-height-base;
}
}
}
.input-group .form-control {
z-index: auto;
}
// fix vertical-align of add-ons
.input-group-addon {
line-height: $line-height-base;
}
// TEMPORARY
// Apply .form--inline to forms to state whether or not the label and input should become inline
// @include form-responsive(turns inline, stops being full width, reduced portion of screen width is used)
.form--inline,
.ss-insert-link .form__fieldgroup,
.cms-edit-form {
@include form-responsive(lg, xl, xxl);
}