Make sign up form styling more similar to how Bootstrap 3 used to be
[ndcode_site.git] / css / bootstrap / _forms.scss
1 // stylelint-disable selector-no-qualifying-type
2
3 //
4 // Textual form controls
5 //
6
7 .form-control {
8   display: block;
9   width: 100%;
10   height: $input-height;
11   padding: $input-padding-y $input-padding-x;
12   font-family: $input-font-family;
13   @include font-size($input-font-size);
14   font-weight: $input-font-weight;
15   line-height: $input-line-height;
16   color: $input-color;
17   background-color: $input-bg;
18   background-clip: padding-box;
19   border: $input-border-width solid $input-border-color;
20
21   // Note: This has no effect on <select>s in some browsers, due to the limited stylability of `<select>`s in CSS.
22   @include border-radius($input-border-radius, 0);
23
24   @include box-shadow($input-box-shadow);
25   @include transition($input-transition);
26
27   // Unstyle the caret on `<select>`s in IE10+.
28   &::-ms-expand {
29     background-color: transparent;
30     border: 0;
31   }
32
33   // Customize the `:focus` state to imitate native WebKit styles.
34   @include form-control-focus($ignore-warning: true);
35
36   // Placeholder
37   &::placeholder {
38     color: $input-placeholder-color;
39     // Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526.
40     opacity: 1;
41   }
42
43   // Disabled and read-only inputs
44   //
45   // HTML5 says that controls under a fieldset > legend:first-child won't be
46   // disabled if the fieldset is disabled. Due to implementation difficulty, we
47   // don't honor that edge case; we style them as disabled anyway.
48   &:disabled,
49   &[readonly] {
50     background-color: $input-disabled-bg;
51     // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
52     opacity: 1;
53   }
54 }
55
56 input[type="date"],
57 input[type="time"],
58 input[type="datetime-local"],
59 input[type="month"] {
60   &.form-control {
61     appearance: none; // Fix appearance for date inputs in Safari
62   }
63 }
64
65 select.form-control {
66   // Remove select outline from select box in FF
67   &:-moz-focusring {
68     color: transparent;
69     text-shadow: 0 0 0 $input-color;
70   }
71
72   &:focus::-ms-value {
73     // Suppress the nested default white text on blue background highlight given to
74     // the selected option text when the (still closed) <select> receives focus
75     // in IE and (under certain conditions) Edge, as it looks bad and cannot be made to
76     // match the appearance of the native widget.
77     // See https://github.com/twbs/bootstrap/issues/19398.
78     color: $input-color;
79     background-color: $input-bg;
80   }
81 }
82
83 // Make file inputs better match text inputs by forcing them to new lines.
84 .form-control-file,
85 .form-control-range {
86   display: block;
87   width: 100%;
88 }
89
90
91 //
92 // Labels
93 //
94
95 // Nick
96 .form-label {
97   font-weight: $label-font-weight;
98 }
99  
100 // For use with horizontal and inline forms, when you need the label (or legend)
101 // text to align with the form controls.
102 .col-form-label {
103   padding-top: add($input-padding-y, $input-border-width);
104   padding-bottom: add($input-padding-y, $input-border-width);
105   margin-bottom: 0; // Override the `<label>/<legend>` default
106   @include font-size(inherit); // Override the `<legend>` default
107   line-height: $input-line-height;
108 }
109
110 .col-form-label-lg {
111   padding-top: add($input-padding-y-lg, $input-border-width);
112   padding-bottom: add($input-padding-y-lg, $input-border-width);
113   @include font-size($input-font-size-lg);
114   line-height: $input-line-height-lg;
115 }
116
117 .col-form-label-sm {
118   padding-top: add($input-padding-y-sm, $input-border-width);
119   padding-bottom: add($input-padding-y-sm, $input-border-width);
120   @include font-size($input-font-size-sm);
121   line-height: $input-line-height-sm;
122 }
123
124
125 // Readonly controls as plain text
126 //
127 // Apply class to a readonly input to make it appear like regular plain
128 // text (without any border, background color, focus indicator)
129
130 .form-control-plaintext {
131   display: block;
132   width: 100%;
133   padding: $input-padding-y 0;
134   margin-bottom: 0; // match inputs if this class comes on inputs with default margins
135   @include font-size($input-font-size);
136   line-height: $input-line-height;
137   color: $input-plaintext-color;
138   background-color: transparent;
139   border: solid transparent;
140   border-width: $input-border-width 0;
141
142   &.form-control-sm,
143   &.form-control-lg {
144     padding-right: 0;
145     padding-left: 0;
146   }
147 }
148
149
150 // Form control sizing
151 //
152 // Build on `.form-control` with modifier classes to decrease or increase the
153 // height and font-size of form controls.
154 //
155 // Repeated in `_input_group.scss` to avoid Sass extend issues.
156
157 .form-control-sm {
158   height: $input-height-sm;
159   padding: $input-padding-y-sm $input-padding-x-sm;
160   @include font-size($input-font-size-sm);
161   line-height: $input-line-height-sm;
162   @include border-radius($input-border-radius-sm);
163 }
164
165 .form-control-lg {
166   height: $input-height-lg;
167   padding: $input-padding-y-lg $input-padding-x-lg;
168   @include font-size($input-font-size-lg);
169   line-height: $input-line-height-lg;
170   @include border-radius($input-border-radius-lg);
171 }
172
173 // stylelint-disable-next-line no-duplicate-selectors
174 select.form-control {
175   &[size],
176   &[multiple] {
177     height: auto;
178   }
179 }
180
181 textarea.form-control {
182   height: auto;
183 }
184
185 // Form groups
186 //
187 // Designed to help with the organization and spacing of vertical forms. For
188 // horizontal forms, use the predefined grid classes.
189
190 .form-group {
191   margin-bottom: $form-group-margin-bottom;
192 }
193
194 .form-text {
195   display: block;
196   margin-top: $form-text-margin-top;
197 }
198
199
200 // Form grid
201 //
202 // Special replacement for our grid system's `.row` for tighter form layouts.
203
204 .form-row {
205   display: flex;
206   flex-wrap: wrap;
207   margin-right: -$form-grid-gutter-width * .5;
208   margin-left: -$form-grid-gutter-width * .5;
209
210   > .col,
211   > [class*="col-"] {
212     padding-right: $form-grid-gutter-width * .5;
213     padding-left: $form-grid-gutter-width * .5;
214   }
215 }
216
217
218 // Checkboxes and radios
219 //
220 // Indent the labels to position radios/checkboxes as hanging controls.
221
222 .form-check {
223   position: relative;
224   display: block;
225   padding-left: $form-check-input-gutter;
226 }
227
228 .form-check-input {
229   position: absolute;
230   margin-top: $form-check-input-margin-y;
231   margin-left: -$form-check-input-gutter;
232
233   // Use [disabled] and :disabled for workaround https://github.com/twbs/bootstrap/issues/28247
234   &[disabled] ~ .form-check-label,
235   &:disabled ~ .form-check-label {
236     color: $text-muted;
237   }
238 }
239
240 .form-check-label {
241   font-weight: $label-font-weight; // Nick
242   margin-bottom: 0; // Override default `<label>` bottom margin
243 }
244
245 .form-check-inline {
246   display: inline-flex;
247   align-items: center;
248   padding-left: 0; // Override base .form-check
249   margin-right: $form-check-inline-margin-x;
250
251   // Undo .form-check-input defaults and add some `margin-right`.
252   .form-check-input {
253     position: static;
254     margin-top: 0;
255     margin-right: $form-check-inline-input-margin-x;
256     margin-left: 0;
257   }
258 }
259
260
261 // Form validation
262 //
263 // Provide feedback to users when form field values are valid or invalid. Works
264 // primarily for client-side validation via scoped `:invalid` and `:valid`
265 // pseudo-classes but also includes `.is-invalid` and `.is-valid` classes for
266 // server side validation.
267
268 @each $state, $data in $form-validation-states {
269   @include form-validation-state($state, map-get($data, color), map-get($data, icon));
270 }
271
272 // Inline forms
273 //
274 // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
275 // forms begin stacked on extra small (mobile) devices and then go inline when
276 // viewports reach <768px.
277 //
278 // Requires wrapping inputs and labels with `.form-group` for proper display of
279 // default HTML form controls and our custom form controls (e.g., input groups).
280
281 .form-inline {
282   display: flex;
283   flex-flow: row wrap;
284   align-items: center; // Prevent shorter elements from growing to same height as others (e.g., small buttons growing to normal sized button height)
285
286   // Because we use flex, the initial sizing of checkboxes is collapsed and
287   // doesn't occupy the full-width (which is what we want for xs grid tier),
288   // so we force that here.
289   .form-check {
290     width: 100%;
291   }
292
293   // Kick in the inline
294   @include media-breakpoint-up(sm) {
295     label {
296       display: flex;
297       align-items: center;
298       justify-content: center;
299       margin-bottom: 0;
300     }
301
302     // Inline-block all the things for "inline"
303     .form-group {
304       display: flex;
305       flex: 0 0 auto;
306       flex-flow: row wrap;
307       align-items: center;
308       margin-bottom: 0;
309     }
310
311     // Allow folks to *not* use `.form-group`
312     .form-control {
313       display: inline-block;
314       width: auto; // Prevent labels from stacking above inputs in `.form-group`
315       vertical-align: middle;
316     }
317
318     // Make static controls behave like regular ones
319     .form-control-plaintext {
320       display: inline-block;
321     }
322
323     .input-group,
324     .custom-select {
325       width: auto;
326     }
327
328     // Remove default margin on radios/checkboxes that were used for stacking, and
329     // then undo the floating of radios and checkboxes to match.
330     .form-check {
331       display: flex;
332       align-items: center;
333       justify-content: center;
334       width: auto;
335       padding-left: 0;
336     }
337     .form-check-input {
338       position: relative;
339       flex-shrink: 0;
340       margin-top: 0;
341       margin-right: $form-check-input-margin-x;
342       margin-left: 0;
343     }
344
345     .custom-control {
346       align-items: center;
347       justify-content: center;
348     }
349     .custom-control-label {
350       margin-bottom: 0;
351     }
352   }
353 }