[AAI] Remove Robby Maharajh & Harish Kajur as committers
[aai/sparky-fe.git] / resources / scss / bootstrap / _forms.scss
1 //
2 // Forms
3 // --------------------------------------------------
4
5 // Normalize non-controls
6 //
7 // Restyle and baseline non-control form elements.
8
9 fieldset {
10   padding: 0;
11   margin: 0;
12   border: 0;
13   // Chrome and Firefox set a `min-width: min-content;` on fieldsets,
14   // so we reset that to ensure it behaves more like a standard block element.
15   // See https://github.com/twbs/bootstrap/issues/12359.
16   min-width: 0;
17 }
18
19 legend {
20   display: block;
21   width: 100%;
22   padding: 0;
23   margin-bottom: $line-height-computed;
24   font-size: ($font-size-base * 1.5);
25   line-height: inherit;
26   color: $legend-color;
27   border: 0;
28   border-bottom: 1px solid $legend-border-color;
29 }
30
31 label {
32   display: inline-block;
33   max-width: 100%; // Force IE8 to wrap long content (see https://github.com/twbs/bootstrap/issues/13141)
34   margin-bottom: 5px;
35   font-weight: bold;
36 }
37
38 // Normalize form controls
39 //
40 // While most of our form styles require extra classes, some basic normalization
41 // is required to ensure optimum display with or without those classes to better
42 // address browser inconsistencies.
43
44 // Override content-box in Normalize (* isn't specific enough)
45 input[type="search"] {
46   @include box-sizing(border-box);
47 }
48
49 // Position radios and checkboxes better
50 input[type="radio"],
51 input[type="checkbox"] {
52   margin: 4px 0 0;
53   margin-top: 1px \9; // IE8-9
54   line-height: normal;
55 }
56
57 input[type="file"] {
58   display: block;
59 }
60
61 // Make range inputs behave like textual form controls
62 input[type="range"] {
63   display: block;
64   width: 100%;
65 }
66
67 // Make multiple select elements height not fixed
68 select[multiple],
69 select[size] {
70   height: auto;
71 }
72
73 // Focus for file, radio, and checkbox
74 input[type="file"]:focus,
75 input[type="radio"]:focus,
76 input[type="checkbox"]:focus {
77   @include tab-focus;
78 }
79
80 // Adjust output element
81 output {
82   display: block;
83   padding-top: ($padding-base-vertical + 1);
84   font-size: $font-size-base;
85   line-height: $line-height-base;
86   color: $input-color;
87 }
88
89 // Common form controls
90 //
91 // Shared size and type resets for form controls. Apply `.form-control` to any
92 // of the following form controls:
93 //
94 // select
95 // textarea
96 // input[type="text"]
97 // input[type="password"]
98 // input[type="datetime"]
99 // input[type="datetime-local"]
100 // input[type="date"]
101 // input[type="month"]
102 // input[type="time"]
103 // input[type="week"]
104 // input[type="number"]
105 // input[type="email"]
106 // input[type="url"]
107 // input[type="search"]
108 // input[type="tel"]
109 // input[type="color"]
110
111 .form-control {
112   display: block;
113   width: 100%;
114   height: $input-height-base; // Make inputs at least the height of their button counterpart (base line-height + padding + border)
115   padding: $padding-base-vertical $padding-base-horizontal;
116   font-size: $font-size-base;
117   line-height: $line-height-base;
118   color: $input-color;
119   background-color: $input-bg;
120   background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214
121   border: 1px solid $input-border;
122   border-radius: $input-border-radius; // Note: This has no effect on <select>s in some browsers, due to the limited stylability of <select>s in CSS.
123   @include box-shadow(inset 0 1px 1px rgba(0, 0, 0, .075));
124   @include transition(border-color ease-in-out .15s, box-shadow ease-in-out .15s);
125
126   // Customize the `:focus` state to imitate native WebKit styles.
127   @include form-control-focus;
128
129   // Placeholder
130   @include placeholder;
131
132   // Disabled and read-only inputs
133   //
134   // HTML5 says that controls under a fieldset > legend:first-child won't be
135   // disabled if the fieldset is disabled. Due to implementation difficulty, we
136   // don't honor that edge case; we style them as disabled anyway.
137   &[disabled],
138   &[readonly],
139   fieldset[disabled] & {
140         background-color: $input-bg-disabled;
141         opacity: 1; // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655
142   }
143
144   &[disabled],
145   fieldset[disabled] & {
146         cursor: $cursor-disabled;
147   }
148
149   // [converter] extracted textarea& to textarea.form-control
150 }
151
152 // Reset height for `textarea`s
153 textarea.form-control {
154   height: auto;
155 }
156
157 // Search inputs in iOS
158 //
159 // This overrides the extra rounded corners on search inputs in iOS so that our
160 // `.form-control` class can properly style them. Note that this cannot simply
161 // be added to `.form-control` as it's not specific enough. For details, see
162 // https://github.com/twbs/bootstrap/issues/11586.
163
164 input[type="search"] {
165   -webkit-appearance: none;
166 }
167
168 // Special styles for iOS temporal inputs
169 //
170 // In Mobile Safari, setting `display: block` on temporal inputs causes the
171 // text within the input to become vertically misaligned. As a workaround, we
172 // set a pixel line-height that matches the given height of the input, but only
173 // for Safari. See https://bugs.webkit.org/show_bug.cgi?id=139848
174 //
175 // Note that as of 8.3, iOS doesn't support `datetime` or `week`.
176
177 @media screen and (-webkit-min-device-pixel-ratio: 0) {
178   input[type="date"],
179   input[type="time"],
180   input[type="datetime-local"],
181   input[type="month"] {
182         &.form-control {
183           line-height: $input-height-base;
184         }
185
186         &.input-sm,
187         .input-group-sm & {
188           line-height: $input-height-small;
189         }
190
191         &.input-lg,
192         .input-group-lg & {
193           line-height: $input-height-large;
194         }
195   }
196 }
197
198 // Form groups
199 //
200 // Designed to help with the organization and spacing of vertical forms. For
201 // horizontal forms, use the predefined grid classes.
202
203 .form-group {
204   margin-bottom: $form-group-margin-bottom;
205 }
206
207 // Checkboxes and radios
208 //
209 // Indent the labels to position radios/checkboxes as hanging controls.
210
211 .radio,
212 .checkbox {
213   position: relative;
214   display: block;
215   margin-top: 10px;
216   margin-bottom: 10px;
217
218   label {
219         min-height: $line-height-computed; // Ensure the input doesn't jump when there is no text
220         padding-left: 20px;
221         margin-bottom: 0;
222         font-weight: normal;
223         cursor: pointer;
224   }
225 }
226
227 .radio input[type="radio"],
228 .radio-inline input[type="radio"],
229 .checkbox input[type="checkbox"],
230 .checkbox-inline input[type="checkbox"] {
231   position: absolute;
232   margin-left: -20px;
233   margin-top: 4px \9;
234 }
235
236 .radio + .radio,
237 .checkbox + .checkbox {
238   margin-top: -5px; // Move up sibling radios or checkboxes for tighter spacing
239 }
240
241 // Radios and checkboxes on same line
242 .radio-inline,
243 .checkbox-inline {
244   position: relative;
245   display: inline-block;
246   padding-left: 20px;
247   margin-bottom: 0;
248   vertical-align: middle;
249   font-weight: normal;
250   cursor: pointer;
251 }
252
253 .radio-inline + .radio-inline,
254 .checkbox-inline + .checkbox-inline {
255   margin-top: 0;
256   margin-left: 10px; // space out consecutive inline controls
257 }
258
259 // Apply same disabled cursor tweak as for inputs
260 // Some special care is needed because <label>s don't inherit their parent's `cursor`.
261 //
262 // Note: Neither radios nor checkboxes can be readonly.
263 input[type="radio"],
264 input[type="checkbox"] {
265   &[disabled],
266   &.disabled,
267   fieldset[disabled] & {
268         cursor: $cursor-disabled;
269   }
270 }
271
272 // These classes are used directly on <label>s
273 .radio-inline,
274 .checkbox-inline {
275   &.disabled,
276   fieldset[disabled] & {
277         cursor: $cursor-disabled;
278   }
279 }
280
281 // These classes are used on elements with <label> descendants
282 .radio,
283 .checkbox {
284   &.disabled,
285   fieldset[disabled] & {
286         label {
287           cursor: $cursor-disabled;
288         }
289   }
290 }
291
292 // Static form control text
293 //
294 // Apply class to a `p` element to make any string of text align with labels in
295 // a horizontal form layout.
296
297 .form-control-static {
298   // Size it appropriately next to real form controls
299   padding-top: ($padding-base-vertical + 1);
300   padding-bottom: ($padding-base-vertical + 1);
301   // Remove default margin from `p`
302   margin-bottom: 0;
303   min-height: ($line-height-computed + $font-size-base);
304
305   &.input-lg,
306   &.input-sm {
307         padding-left: 0;
308         padding-right: 0;
309   }
310 }
311
312 // Form control sizing
313 //
314 // Build on `.form-control` with modifier classes to decrease or increase the
315 // height and font-size of form controls.
316 //
317 // The `.form-group-* form-control` variations are sadly duplicated to avoid the
318 // issue documented in https://github.com/twbs/bootstrap/issues/15074.
319
320 @include input-size('.input-sm', $input-height-small, $padding-small-vertical, $padding-small-horizontal, $font-size-small, $line-height-small, $input-border-radius-small);
321 .form-group-sm {
322   .form-control {
323         height: $input-height-small;
324         padding: $padding-small-vertical $padding-small-horizontal;
325         font-size: $font-size-small;
326         line-height: $line-height-small;
327         border-radius: $input-border-radius-small;
328   }
329   select.form-control {
330         height: $input-height-small;
331         line-height: $input-height-small;
332   }
333   textarea.form-control,
334   select[multiple].form-control {
335         height: auto;
336   }
337   .form-control-static {
338         height: $input-height-small;
339         min-height: ($line-height-computed + $font-size-small);
340         padding: ($padding-small-vertical + 1) $padding-small-horizontal;
341         font-size: $font-size-small;
342         line-height: $line-height-small;
343   }
344 }
345
346 @include input-size('.input-lg', $input-height-large, $padding-large-vertical, $padding-large-horizontal, $font-size-large, $line-height-large, $input-border-radius-large);
347 .form-group-lg {
348   .form-control {
349         height: $input-height-large;
350         padding: $padding-large-vertical $padding-large-horizontal;
351         font-size: $font-size-large;
352         line-height: $line-height-large;
353         border-radius: $input-border-radius-large;
354   }
355   select.form-control {
356         height: $input-height-large;
357         line-height: $input-height-large;
358   }
359   textarea.form-control,
360   select[multiple].form-control {
361         height: auto;
362   }
363   .form-control-static {
364         height: $input-height-large;
365         min-height: ($line-height-computed + $font-size-large);
366         padding: ($padding-large-vertical + 1) $padding-large-horizontal;
367         font-size: $font-size-large;
368         line-height: $line-height-large;
369   }
370 }
371
372 // Form control feedback states
373 //
374 // Apply contextual and semantic states to individual form controls.
375
376 .has-feedback {
377   // Enable absolute positioning
378   position: relative;
379
380   // Ensure icons don't overlap text
381   .form-control {
382         padding-right: ($input-height-base * 1.25);
383   }
384 }
385
386 // Feedback icon (requires .glyphicon classes)
387 .form-control-feedback {
388   position: absolute;
389   top: 0;
390   right: 0;
391   z-index: 2; // Ensure icon is above input groups
392   display: block;
393   width: $input-height-base;
394   height: $input-height-base;
395   line-height: $input-height-base;
396   text-align: center;
397   pointer-events: none;
398 }
399
400 .input-lg + .form-control-feedback,
401 .input-group-lg + .form-control-feedback,
402 .form-group-lg .form-control + .form-control-feedback {
403   width: $input-height-large;
404   height: $input-height-large;
405   line-height: $input-height-large;
406 }
407
408 .input-sm + .form-control-feedback,
409 .input-group-sm + .form-control-feedback,
410 .form-group-sm .form-control + .form-control-feedback {
411   width: $input-height-small;
412   height: $input-height-small;
413   line-height: $input-height-small;
414 }
415
416 // Feedback states
417 .has-success {
418   @include form-control-validation($state-success-text, $state-success-text, $state-success-bg);
419 }
420
421 .has-warning {
422   @include form-control-validation($state-warning-text, $state-warning-text, $state-warning-bg);
423 }
424
425 .has-error {
426   @include form-control-validation($state-danger-text, $state-danger-text, $state-danger-bg);
427 }
428
429 // Reposition feedback icon if input has visible label above
430 .has-feedback label {
431
432   & ~ .form-control-feedback {
433         top: ($line-height-computed + 5); // Height of the `label` and its margin
434   }
435   &.sr-only ~ .form-control-feedback {
436         top: 0;
437   }
438 }
439
440 // Help text
441 //
442 // Apply to any element you wish to create light text for placement immediately
443 // below a form control. Use for general help, formatting, or instructional text.
444
445 .help-block {
446   display: block; // account for any element using help-block
447   margin-top: 5px;
448   margin-bottom: 10px;
449   color: lighten($text-color, 25%); // lighten the text some for contrast
450 }
451
452 // Inline forms
453 //
454 // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
455 // forms begin stacked on extra small (mobile) devices and then go inline when
456 // viewports reach <768px.
457 //
458 // Requires wrapping inputs and labels with `.form-group` for proper display of
459 // default HTML form controls and our custom form controls (e.g., input groups).
460 //
461 // Heads up! This is mixin-ed into `.navbar-form` in navbars.less.
462
463 // [converter] extracted from `.form-inline` for libsass compatibility
464 @mixin form-inline {
465
466   // Kick in the inline
467   @media (min-width: $screen-sm-min) {
468         // Inline-block all the things for "inline"
469         .form-group {
470           display: inline-block;
471           margin-bottom: 0;
472           vertical-align: middle;
473         }
474
475         // In navbar-form, allow folks to *not* use `.form-group`
476         .form-control {
477           display: inline-block;
478           width: auto; // Prevent labels from stacking above inputs in `.form-group`
479           vertical-align: middle;
480         }
481
482         // Make static controls behave like regular ones
483         .form-control-static {
484           display: inline-block;
485         }
486
487         .input-group {
488           display: inline-table;
489           vertical-align: middle;
490
491           .input-group-addon,
492           .input-group-btn,
493           .form-control {
494                 width: auto;
495           }
496         }
497
498         // Input groups need that 100% width though
499         .input-group > .form-control {
500           width: 100%;
501         }
502
503         .control-label {
504           margin-bottom: 0;
505           vertical-align: middle;
506         }
507
508         // Remove default margin on radios/checkboxes that were used for stacking, and
509         // then undo the floating of radios and checkboxes to match.
510         .radio,
511         .checkbox {
512           display: inline-block;
513           margin-top: 0;
514           margin-bottom: 0;
515           vertical-align: middle;
516
517           label {
518                 padding-left: 0;
519           }
520         }
521         .radio input[type="radio"],
522         .checkbox input[type="checkbox"] {
523           position: relative;
524           margin-left: 0;
525         }
526
527         // Re-override the feedback icon.
528         .has-feedback .form-control-feedback {
529           top: 0;
530         }
531   }
532 }
533
534 // [converter] extracted as `@mixin form-inline` for libsass compatibility
535 .form-inline {
536   @include form-inline;
537 }
538
539 // Horizontal forms
540 //
541 // Horizontal forms are built on grid classes and allow you to create forms with
542 // labels on the left and inputs on the right.
543
544 .form-horizontal {
545
546   // Consistent vertical alignment of radios and checkboxes
547   //
548   // Labels also get some reset styles, but that is scoped to a media query below.
549   .radio,
550   .checkbox,
551   .radio-inline,
552   .checkbox-inline {
553         margin-top: 0;
554         margin-bottom: 0;
555         padding-top: ($padding-base-vertical + 1); // Default padding plus a border
556   }
557   // Account for padding we're adding to ensure the alignment and of help text
558   // and other content below items
559   .radio,
560   .checkbox {
561         min-height: ($line-height-computed + ($padding-base-vertical + 1));
562   }
563
564   // Make form groups behave like rows
565   .form-group {
566         @include make-row;
567   }
568
569   // Reset spacing and right align labels, but scope to media queries so that
570   // labels on narrow viewports stack the same as a default form example.
571   @media (min-width: $screen-sm-min) {
572         .control-label {
573           text-align: right;
574           margin-bottom: 0;
575           padding-top: ($padding-base-vertical + 1); // Default padding plus a border
576         }
577   }
578
579   // Validation states
580   //
581   // Reposition the icon because it's now within a grid column and columns have
582   // `position: relative;` on them. Also accounts for the grid gutter padding.
583   .has-feedback .form-control-feedback {
584         right: floor(($grid-gutter-width / 2));
585   }
586
587   // Form group sizes
588   //
589   // Quick utility class for applying `.input-lg` and `.input-sm` styles to the
590   // inputs and labels within a `.form-group`.
591   .form-group-lg {
592         @media (min-width: $screen-sm-min) {
593           .control-label {
594                 padding-top: (($padding-large-vertical * $line-height-large) + 1);
595                 font-size: $font-size-large;
596           }
597         }
598   }
599   .form-group-sm {
600         @media (min-width: $screen-sm-min) {
601           .control-label {
602                 padding-top: ($padding-small-vertical + 1);
603                 font-size: $font-size-small;
604           }
605         }
606   }
607 }