bootstrap 4.3.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +17 -2
  3. data/CHANGELOG.md +2 -14
  4. data/README.md +7 -4
  5. data/assets/javascripts/bootstrap/alert.js +173 -137
  6. data/assets/javascripts/bootstrap/base-component.js +182 -0
  7. data/assets/javascripts/bootstrap/button.js +102 -143
  8. data/assets/javascripts/bootstrap/carousel.js +481 -410
  9. data/assets/javascripts/bootstrap/collapse.js +340 -274
  10. data/assets/javascripts/bootstrap/dom/data.js +68 -0
  11. data/assets/javascripts/bootstrap/dom/event-handler.js +322 -0
  12. data/assets/javascripts/bootstrap/dom/manipulator.js +88 -0
  13. data/assets/javascripts/bootstrap/dom/selector-engine.js +127 -0
  14. data/assets/javascripts/bootstrap/dropdown.js +494 -400
  15. data/assets/javascripts/bootstrap/modal.js +834 -450
  16. data/assets/javascripts/bootstrap/offcanvas.js +866 -0
  17. data/assets/javascripts/bootstrap/popover.js +122 -199
  18. data/assets/javascripts/bootstrap/scrollspy.js +257 -241
  19. data/assets/javascripts/bootstrap/tab.js +219 -155
  20. data/assets/javascripts/bootstrap/toast.js +330 -190
  21. data/assets/javascripts/bootstrap/tooltip.js +710 -472
  22. data/assets/javascripts/bootstrap-global-this-define.js +6 -0
  23. data/assets/javascripts/bootstrap-global-this-undefine.js +2 -0
  24. data/assets/javascripts/bootstrap-sprockets.js +8 -1
  25. data/assets/javascripts/bootstrap.js +3547 -2809
  26. data/assets/javascripts/bootstrap.min.js +4 -4
  27. data/assets/stylesheets/_bootstrap-grid.scss +54 -18
  28. data/assets/stylesheets/_bootstrap-reboot.scss +7 -4
  29. data/assets/stylesheets/_bootstrap.scss +20 -11
  30. data/assets/stylesheets/bootstrap/_accordion.scss +118 -0
  31. data/assets/stylesheets/bootstrap/_alert.scss +15 -9
  32. data/assets/stylesheets/bootstrap/_badge.scss +2 -27
  33. data/assets/stylesheets/bootstrap/_breadcrumb.scss +5 -18
  34. data/assets/stylesheets/bootstrap/_button-group.scss +21 -45
  35. data/assets/stylesheets/bootstrap/_buttons.scss +28 -54
  36. data/assets/stylesheets/bootstrap/_card.scss +52 -125
  37. data/assets/stylesheets/bootstrap/_carousel.scss +70 -38
  38. data/assets/stylesheets/bootstrap/_close.scss +30 -31
  39. data/assets/stylesheets/bootstrap/_containers.scss +41 -0
  40. data/assets/stylesheets/bootstrap/_dropdown.scss +88 -39
  41. data/assets/stylesheets/bootstrap/_forms.scss +9 -330
  42. data/assets/stylesheets/bootstrap/_functions.scss +237 -27
  43. data/assets/stylesheets/bootstrap/_grid.scss +14 -33
  44. data/assets/stylesheets/bootstrap/_helpers.scss +9 -0
  45. data/assets/stylesheets/bootstrap/_images.scss +3 -3
  46. data/assets/stylesheets/bootstrap/_list-group.scss +61 -36
  47. data/assets/stylesheets/bootstrap/_mixins.scss +12 -16
  48. data/assets/stylesheets/bootstrap/_modal.scss +64 -84
  49. data/assets/stylesheets/bootstrap/_nav.scss +29 -10
  50. data/assets/stylesheets/bootstrap/_navbar.scss +93 -52
  51. data/assets/stylesheets/bootstrap/_offcanvas.scss +83 -0
  52. data/assets/stylesheets/bootstrap/_pagination.scss +13 -22
  53. data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
  54. data/assets/stylesheets/bootstrap/_popover.scss +29 -42
  55. data/assets/stylesheets/bootstrap/_progress.scss +10 -5
  56. data/assets/stylesheets/bootstrap/_reboot.scss +350 -208
  57. data/assets/stylesheets/bootstrap/_root.scss +42 -8
  58. data/assets/stylesheets/bootstrap/_spinners.scss +21 -7
  59. data/assets/stylesheets/bootstrap/_tables.scss +80 -114
  60. data/assets/stylesheets/bootstrap/_toasts.scss +21 -14
  61. data/assets/stylesheets/bootstrap/_tooltip.scss +21 -21
  62. data/assets/stylesheets/bootstrap/_transitions.scss +8 -1
  63. data/assets/stylesheets/bootstrap/_type.scss +40 -61
  64. data/assets/stylesheets/bootstrap/_utilities.scss +630 -17
  65. data/assets/stylesheets/bootstrap/_variables.scss +993 -487
  66. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +18 -0
  67. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +63 -0
  68. data/assets/stylesheets/bootstrap/forms/_form-check.scss +152 -0
  69. data/assets/stylesheets/bootstrap/forms/_form-control.scss +219 -0
  70. data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
  71. data/assets/stylesheets/bootstrap/forms/_form-select.scss +70 -0
  72. data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
  73. data/assets/stylesheets/bootstrap/forms/_input-group.scss +121 -0
  74. data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
  75. data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
  76. data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
  77. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +12 -0
  78. data/assets/stylesheets/bootstrap/helpers/_position.scss +30 -0
  79. data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
  80. data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
  81. data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
  82. data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
  83. data/assets/stylesheets/bootstrap/helpers/_visually-hidden.scss +8 -0
  84. data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
  85. data/assets/stylesheets/bootstrap/mixins/_alert.scss +3 -5
  86. data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
  87. data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +37 -22
  88. data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +7 -9
  89. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +14 -10
  90. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +77 -51
  91. data/assets/stylesheets/bootstrap/mixins/_caret.scss +10 -8
  92. data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
  93. data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
  94. data/assets/stylesheets/bootstrap/mixins/_container.scss +9 -0
  95. data/assets/stylesheets/bootstrap/mixins/_forms.scss +67 -115
  96. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +13 -11
  97. data/assets/stylesheets/bootstrap/mixins/_grid.scss +131 -32
  98. data/assets/stylesheets/bootstrap/mixins/_image.scss +0 -20
  99. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +5 -2
  100. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +17 -8
  101. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +1 -1
  102. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
  103. data/assets/stylesheets/bootstrap/mixins/_transition.scss +18 -8
  104. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +89 -0
  105. data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +29 -0
  106. data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
  107. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +274 -132
  108. data/bootstrap.gemspec +4 -6
  109. data/lib/bootstrap/version.rb +2 -2
  110. data/tasks/updater/js.rb +25 -6
  111. data/tasks/updater/network.rb +8 -2
  112. data/test/dummy_rails/app/assets/config/manifest.js +3 -0
  113. data/test/dummy_rails/app/assets/javascripts/application.js +4 -3
  114. data/test/dummy_rails/app/assets/stylesheets/.browserslistrc +1 -0
  115. data/test/dummy_rails/app/views/layouts/application.html.erb +3 -1
  116. data/test/dummy_rails/app/views/pages/root.html +89 -0
  117. data/test/dummy_rails/config/application.rb +0 -3
  118. data/test/gemfiles/rails_6_0.gemfile +7 -0
  119. data/test/gemfiles/rails_6_1.gemfile +7 -0
  120. data/test/support/dummy_rails_integration.rb +3 -1
  121. data/test/test_helper.rb +18 -13
  122. metadata +61 -79
  123. data/assets/javascripts/bootstrap/util.js +0 -171
  124. data/assets/stylesheets/bootstrap/_code.scss +0 -48
  125. data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -507
  126. data/assets/stylesheets/bootstrap/_input-group.scss +0 -193
  127. data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
  128. data/assets/stylesheets/bootstrap/_media.scss +0 -8
  129. data/assets/stylesheets/bootstrap/_print.scss +0 -141
  130. data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -21
  131. data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
  132. data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
  133. data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -66
  134. data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
  135. data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -10
  136. data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +0 -33
  137. data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
  138. data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
  139. data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -16
  140. data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
  141. data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
  142. data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
  143. data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
  144. data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
  145. data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
  146. data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
  147. data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
  148. data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
  149. data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
  150. data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
  151. data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
  152. data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
  153. data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
  154. data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
  155. data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
  156. data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
  157. data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
  158. data/test/dummy_rails/app/views/pages/root.html.slim +0 -58
@@ -1,330 +1,9 @@
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();
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
- select.form-control {
57
- &:focus::-ms-value {
58
- // Suppress the nested default white text on blue background highlight given to
59
- // the selected option text when the (still closed) <select> receives focus
60
- // in IE and (under certain conditions) Edge, as it looks bad and cannot be made to
61
- // match the appearance of the native widget.
62
- // See https://github.com/twbs/bootstrap/issues/19398.
63
- color: $input-color;
64
- background-color: $input-bg;
65
- }
66
- }
67
-
68
- // Make file inputs better match text inputs by forcing them to new lines.
69
- .form-control-file,
70
- .form-control-range {
71
- display: block;
72
- width: 100%;
73
- }
74
-
75
-
76
- //
77
- // Labels
78
- //
79
-
80
- // For use with horizontal and inline forms, when you need the label (or legend)
81
- // text to align with the form controls.
82
- .col-form-label {
83
- padding-top: calc(#{$input-padding-y} + #{$input-border-width});
84
- padding-bottom: calc(#{$input-padding-y} + #{$input-border-width});
85
- margin-bottom: 0; // Override the `<label>/<legend>` default
86
- @include font-size(inherit); // Override the `<legend>` default
87
- line-height: $input-line-height;
88
- }
89
-
90
- .col-form-label-lg {
91
- padding-top: calc(#{$input-padding-y-lg} + #{$input-border-width});
92
- padding-bottom: calc(#{$input-padding-y-lg} + #{$input-border-width});
93
- @include font-size($input-font-size-lg);
94
- line-height: $input-line-height-lg;
95
- }
96
-
97
- .col-form-label-sm {
98
- padding-top: calc(#{$input-padding-y-sm} + #{$input-border-width});
99
- padding-bottom: calc(#{$input-padding-y-sm} + #{$input-border-width});
100
- @include font-size($input-font-size-sm);
101
- line-height: $input-line-height-sm;
102
- }
103
-
104
-
105
- // Readonly controls as plain text
106
- //
107
- // Apply class to a readonly input to make it appear like regular plain
108
- // text (without any border, background color, focus indicator)
109
-
110
- .form-control-plaintext {
111
- display: block;
112
- width: 100%;
113
- padding-top: $input-padding-y;
114
- padding-bottom: $input-padding-y;
115
- margin-bottom: 0; // match inputs if this class comes on inputs with default margins
116
- line-height: $input-line-height;
117
- color: $input-plaintext-color;
118
- background-color: transparent;
119
- border: solid transparent;
120
- border-width: $input-border-width 0;
121
-
122
- &.form-control-sm,
123
- &.form-control-lg {
124
- padding-right: 0;
125
- padding-left: 0;
126
- }
127
- }
128
-
129
-
130
- // Form control sizing
131
- //
132
- // Build on `.form-control` with modifier classes to decrease or increase the
133
- // height and font-size of form controls.
134
- //
135
- // Repeated in `_input_group.scss` to avoid Sass extend issues.
136
-
137
- .form-control-sm {
138
- height: $input-height-sm;
139
- padding: $input-padding-y-sm $input-padding-x-sm;
140
- @include font-size($input-font-size-sm);
141
- line-height: $input-line-height-sm;
142
- @include border-radius($input-border-radius-sm);
143
- }
144
-
145
- .form-control-lg {
146
- height: $input-height-lg;
147
- padding: $input-padding-y-lg $input-padding-x-lg;
148
- @include font-size($input-font-size-lg);
149
- line-height: $input-line-height-lg;
150
- @include border-radius($input-border-radius-lg);
151
- }
152
-
153
- // stylelint-disable-next-line no-duplicate-selectors
154
- select.form-control {
155
- &[size],
156
- &[multiple] {
157
- height: auto;
158
- }
159
- }
160
-
161
- textarea.form-control {
162
- height: auto;
163
- }
164
-
165
- // Form groups
166
- //
167
- // Designed to help with the organization and spacing of vertical forms. For
168
- // horizontal forms, use the predefined grid classes.
169
-
170
- .form-group {
171
- margin-bottom: $form-group-margin-bottom;
172
- }
173
-
174
- .form-text {
175
- display: block;
176
- margin-top: $form-text-margin-top;
177
- }
178
-
179
-
180
- // Form grid
181
- //
182
- // Special replacement for our grid system's `.row` for tighter form layouts.
183
-
184
- .form-row {
185
- display: flex;
186
- flex-wrap: wrap;
187
- margin-right: -$form-grid-gutter-width / 2;
188
- margin-left: -$form-grid-gutter-width / 2;
189
-
190
- > .col,
191
- > [class*="col-"] {
192
- padding-right: $form-grid-gutter-width / 2;
193
- padding-left: $form-grid-gutter-width / 2;
194
- }
195
- }
196
-
197
-
198
- // Checkboxes and radios
199
- //
200
- // Indent the labels to position radios/checkboxes as hanging controls.
201
-
202
- .form-check {
203
- position: relative;
204
- display: block;
205
- padding-left: $form-check-input-gutter;
206
- }
207
-
208
- .form-check-input {
209
- position: absolute;
210
- margin-top: $form-check-input-margin-y;
211
- margin-left: -$form-check-input-gutter;
212
-
213
- &:disabled ~ .form-check-label {
214
- color: $text-muted;
215
- }
216
- }
217
-
218
- .form-check-label {
219
- margin-bottom: 0; // Override default `<label>` bottom margin
220
- }
221
-
222
- .form-check-inline {
223
- display: inline-flex;
224
- align-items: center;
225
- padding-left: 0; // Override base .form-check
226
- margin-right: $form-check-inline-margin-x;
227
-
228
- // Undo .form-check-input defaults and add some `margin-right`.
229
- .form-check-input {
230
- position: static;
231
- margin-top: 0;
232
- margin-right: $form-check-inline-input-margin-x;
233
- margin-left: 0;
234
- }
235
- }
236
-
237
-
238
- // Form validation
239
- //
240
- // Provide feedback to users when form field values are valid or invalid. Works
241
- // primarily for client-side validation via scoped `:invalid` and `:valid`
242
- // pseudo-classes but also includes `.is-invalid` and `.is-valid` classes for
243
- // server side validation.
244
-
245
- @each $state, $data in $form-validation-states {
246
- @include form-validation-state($state, map-get($data, color), map-get($data, icon));
247
- }
248
-
249
- // Inline forms
250
- //
251
- // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
252
- // forms begin stacked on extra small (mobile) devices and then go inline when
253
- // viewports reach <768px.
254
- //
255
- // Requires wrapping inputs and labels with `.form-group` for proper display of
256
- // default HTML form controls and our custom form controls (e.g., input groups).
257
-
258
- .form-inline {
259
- display: flex;
260
- flex-flow: row wrap;
261
- align-items: center; // Prevent shorter elements from growing to same height as others (e.g., small buttons growing to normal sized button height)
262
-
263
- // Because we use flex, the initial sizing of checkboxes is collapsed and
264
- // doesn't occupy the full-width (which is what we want for xs grid tier),
265
- // so we force that here.
266
- .form-check {
267
- width: 100%;
268
- }
269
-
270
- // Kick in the inline
271
- @include media-breakpoint-up(sm) {
272
- label {
273
- display: flex;
274
- align-items: center;
275
- justify-content: center;
276
- margin-bottom: 0;
277
- }
278
-
279
- // Inline-block all the things for "inline"
280
- .form-group {
281
- display: flex;
282
- flex: 0 0 auto;
283
- flex-flow: row wrap;
284
- align-items: center;
285
- margin-bottom: 0;
286
- }
287
-
288
- // Allow folks to *not* use `.form-group`
289
- .form-control {
290
- display: inline-block;
291
- width: auto; // Prevent labels from stacking above inputs in `.form-group`
292
- vertical-align: middle;
293
- }
294
-
295
- // Make static controls behave like regular ones
296
- .form-control-plaintext {
297
- display: inline-block;
298
- }
299
-
300
- .input-group,
301
- .custom-select {
302
- width: auto;
303
- }
304
-
305
- // Remove default margin on radios/checkboxes that were used for stacking, and
306
- // then undo the floating of radios and checkboxes to match.
307
- .form-check {
308
- display: flex;
309
- align-items: center;
310
- justify-content: center;
311
- width: auto;
312
- padding-left: 0;
313
- }
314
- .form-check-input {
315
- position: relative;
316
- flex-shrink: 0;
317
- margin-top: 0;
318
- margin-right: $form-check-input-margin-x;
319
- margin-left: 0;
320
- }
321
-
322
- .custom-control {
323
- align-items: center;
324
- justify-content: center;
325
- }
326
- .custom-control-label {
327
- margin-bottom: 0;
328
- }
329
- }
330
- }
1
+ @import "forms/labels";
2
+ @import "forms/form-text";
3
+ @import "forms/form-control";
4
+ @import "forms/form-select";
5
+ @import "forms/form-check";
6
+ @import "forms/form-range";
7
+ @import "forms/floating-labels";
8
+ @import "forms/input-group";
9
+ @import "forms/validation";
@@ -8,7 +8,7 @@
8
8
  $prev-key: null;
9
9
  $prev-num: null;
10
10
  @each $key, $num in $map {
11
- @if $prev-num == null or unit($num) == "%" {
11
+ @if $prev-num == null or unit($num) == "%" or unit($prev-num) == "%" {
12
12
  // Do nothing
13
13
  } @else if not comparable($prev-num, $num) {
14
14
  @warn "Potentially invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} whose unit makes it incomparable to #{$prev-num}, the value of the previous key '#{$prev-key}' !";
@@ -23,11 +23,81 @@
23
23
  // Starts at zero
24
24
  // Used to ensure the min-width of the lowest breakpoint starts at 0.
25
25
  @mixin _assert-starts-at-zero($map, $map-name: "$grid-breakpoints") {
26
- $values: map-values($map);
27
- $first-value: nth($values, 1);
28
- @if $first-value != 0 {
29
- @warn "First breakpoint in #{$map-name} must start at 0, but starts at #{$first-value}.";
26
+ @if length($map) > 0 {
27
+ $values: map-values($map);
28
+ $first-value: nth($values, 1);
29
+ @if $first-value != 0 {
30
+ @warn "First breakpoint in #{$map-name} must start at 0, but starts at #{$first-value}.";
31
+ }
32
+ }
33
+ }
34
+
35
+ // Colors
36
+ @function to-rgb($value) {
37
+ @return red($value), green($value), blue($value);
38
+ }
39
+
40
+ @function rgba-css-var($identifier, $target) {
41
+ @return rgba(var(--#{$variable-prefix}#{$identifier}-rgb), var(--#{$variable-prefix}#{$target}-opacity));
42
+ }
43
+
44
+ // stylelint-disable scss/dollar-variable-pattern
45
+ @function map-loop($map, $func, $args...) {
46
+ $_map: ();
47
+
48
+ @each $key, $value in $map {
49
+ // allow to pass the $key and $value of the map as an function argument
50
+ $_args: ();
51
+ @each $arg in $args {
52
+ $_args: append($_args, if($arg == "$key", $key, if($arg == "$value", $value, $arg)));
53
+ }
54
+
55
+ $_map: map-merge($_map, ($key: call(get-function($func), $_args...)));
56
+ }
57
+
58
+ @return $_map;
59
+ }
60
+ // stylelint-enable scss/dollar-variable-pattern
61
+
62
+ @function varify($list) {
63
+ $result: null;
64
+ @each $entry in $list {
65
+ $result: append($result, var(--#{$variable-prefix}#{$entry}), space);
66
+ }
67
+ @return $result;
68
+ }
69
+
70
+ // Internal Bootstrap function to turn maps into its negative variant.
71
+ // It prefixes the keys with `n` and makes the value negative.
72
+ @function negativify-map($map) {
73
+ $result: ();
74
+ @each $key, $value in $map {
75
+ @if $key != 0 {
76
+ $result: map-merge($result, ("n" + $key: (-$value)));
77
+ }
30
78
  }
79
+ @return $result;
80
+ }
81
+
82
+ // Get multiple keys from a sass map
83
+ @function map-get-multiple($map, $values) {
84
+ $result: ();
85
+ @each $key, $value in $map {
86
+ @if (index($values, $key) != null) {
87
+ $result: map-merge($result, ($key: $value));
88
+ }
89
+ }
90
+ @return $result;
91
+ }
92
+
93
+ // Merge multiple maps
94
+ @function map-merge-multiple($maps...) {
95
+ $merged-maps: ();
96
+
97
+ @each $map in $maps {
98
+ $merged-maps: map-merge($merged-maps, $map);
99
+ }
100
+ @return $merged-maps;
31
101
  }
32
102
 
33
103
  // Replace `$search` with `$replace` in `$string`
@@ -48,39 +118,179 @@
48
118
  @return $string;
49
119
  }
50
120
 
121
+ // See https://codepen.io/kevinweber/pen/dXWoRw
122
+ //
123
+ // Requires the use of quotes around data URIs.
124
+
125
+ @function escape-svg($string) {
126
+ @if str-index($string, "data:image/svg+xml") {
127
+ @each $char, $encoded in $escaped-characters {
128
+ // Do not escape the url brackets
129
+ @if str-index($string, "url(") == 1 {
130
+ $string: url("#{str-replace(str-slice($string, 6, -3), $char, $encoded)}");
131
+ } @else {
132
+ $string: str-replace($string, $char, $encoded);
133
+ }
134
+ }
135
+ }
136
+
137
+ @return $string;
138
+ }
139
+
51
140
  // Color contrast
52
- @function color-yiq($color, $dark: $yiq-text-dark, $light: $yiq-text-light) {
53
- $r: red($color);
54
- $g: green($color);
55
- $b: blue($color);
141
+ // See https://github.com/twbs/bootstrap/pull/30168
142
+
143
+ // A list of pre-calculated numbers of pow(divide((divide($value, 255) + .055), 1.055), 2.4). (from 0 to 255)
144
+ // stylelint-disable-next-line scss/dollar-variable-default, scss/dollar-variable-pattern
145
+ $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003 .0033 .0037 .004 .0044 .0048 .0052 .0056 .006 .0065 .007 .0075 .008 .0086 .0091 .0097 .0103 .011 .0116 .0123 .013 .0137 .0144 .0152 .016 .0168 .0176 .0185 .0194 .0203 .0212 .0222 .0232 .0242 .0252 .0262 .0273 .0284 .0296 .0307 .0319 .0331 .0343 .0356 .0369 .0382 .0395 .0409 .0423 .0437 .0452 .0467 .0482 .0497 .0513 .0529 .0545 .0561 .0578 .0595 .0612 .063 .0648 .0666 .0685 .0704 .0723 .0742 .0762 .0782 .0802 .0823 .0844 .0865 .0887 .0908 .0931 .0953 .0976 .0999 .1022 .1046 .107 .1095 .1119 .1144 .117 .1195 .1221 .1248 .1274 .1301 .1329 .1356 .1384 .1413 .1441 .147 .15 .1529 .1559 .159 .162 .1651 .1683 .1714 .1746 .1779 .1812 .1845 .1878 .1912 .1946 .1981 .2016 .2051 .2086 .2122 .2159 .2195 .2232 .227 .2307 .2346 .2384 .2423 .2462 .2502 .2542 .2582 .2623 .2664 .2705 .2747 .2789 .2831 .2874 .2918 .2961 .3005 .305 .3095 .314 .3185 .3231 .3278 .3325 .3372 .3419 .3467 .3515 .3564 .3613 .3663 .3712 .3763 .3813 .3864 .3916 .3968 .402 .4072 .4125 .4179 .4233 .4287 .4342 .4397 .4452 .4508 .4564 .4621 .4678 .4735 .4793 .4851 .491 .4969 .5029 .5089 .5149 .521 .5271 .5333 .5395 .5457 .552 .5583 .5647 .5711 .5776 .5841 .5906 .5972 .6038 .6105 .6172 .624 .6308 .6376 .6445 .6514 .6584 .6654 .6724 .6795 .6867 .6939 .7011 .7084 .7157 .7231 .7305 .7379 .7454 .7529 .7605 .7682 .7758 .7835 .7913 .7991 .807 .8148 .8228 .8308 .8388 .8469 .855 .8632 .8714 .8796 .8879 .8963 .9047 .9131 .9216 .9301 .9387 .9473 .956 .9647 .9734 .9823 .9911 1;
146
+
147
+ @function color-contrast($background, $color-contrast-dark: $color-contrast-dark, $color-contrast-light: $color-contrast-light, $min-contrast-ratio: $min-contrast-ratio) {
148
+ $foregrounds: $color-contrast-light, $color-contrast-dark, $white, $black;
149
+ $max-ratio: 0;
150
+ $max-ratio-color: null;
56
151
 
57
- $yiq: (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
152
+ @each $color in $foregrounds {
153
+ $contrast-ratio: contrast-ratio($background, $color);
154
+ @if $contrast-ratio > $min-contrast-ratio {
155
+ @return $color;
156
+ } @else if $contrast-ratio > $max-ratio {
157
+ $max-ratio: $contrast-ratio;
158
+ $max-ratio-color: $color;
159
+ }
160
+ }
161
+
162
+ @warn "Found no color leading to #{$min-contrast-ratio}:1 contrast ratio against #{$background}...";
163
+
164
+ @return $max-ratio-color;
165
+ }
58
166
 
59
- @if ($yiq >= $yiq-contrasted-threshold) {
60
- @return $dark;
61
- } @else {
62
- @return $light;
167
+ @function contrast-ratio($background, $foreground: $color-contrast-light) {
168
+ $l1: luminance($background);
169
+ $l2: luminance(opaque($background, $foreground));
170
+
171
+ @return if($l1 > $l2, divide($l1 + .05, $l2 + .05), divide($l2 + .05, $l1 + .05));
172
+ }
173
+
174
+ // Return WCAG2.0 relative luminance
175
+ // See https://www.w3.org/WAI/GL/wiki/Relative_luminance
176
+ // See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
177
+ @function luminance($color) {
178
+ $rgb: (
179
+ "r": red($color),
180
+ "g": green($color),
181
+ "b": blue($color)
182
+ );
183
+
184
+ @each $name, $value in $rgb {
185
+ $value: if(divide($value, 255) < .03928, divide(divide($value, 255), 12.92), nth($_luminance-list, $value + 1));
186
+ $rgb: map-merge($rgb, ($name: $value));
63
187
  }
188
+
189
+ @return (map-get($rgb, "r") * .2126) + (map-get($rgb, "g") * .7152) + (map-get($rgb, "b") * .0722);
64
190
  }
65
191
 
66
- // Retrieve color Sass maps
67
- @function color($key: "blue") {
68
- @return map-get($colors, $key);
192
+ // Return opaque color
193
+ // opaque(#fff, rgba(0, 0, 0, .5)) => #808080
194
+ @function opaque($background, $foreground) {
195
+ @return mix(rgba($foreground, 1), $background, opacity($foreground) * 100);
69
196
  }
70
197
 
71
- @function theme-color($key: "primary") {
72
- @return map-get($theme-colors, $key);
198
+ // scss-docs-start color-functions
199
+ // Tint a color: mix a color with white
200
+ @function tint-color($color, $weight) {
201
+ @return mix(white, $color, $weight);
73
202
  }
74
203
 
75
- @function gray($key: "100") {
76
- @return map-get($grays, $key);
204
+ // Shade a color: mix a color with black
205
+ @function shade-color($color, $weight) {
206
+ @return mix(black, $color, $weight);
77
207
  }
78
208
 
79
- // Request a theme color level
80
- @function theme-color-level($color-name: "primary", $level: 0) {
81
- $color: theme-color($color-name);
82
- $color-base: if($level > 0, $black, $white);
83
- $level: abs($level);
209
+ // Shade the color if the weight is positive, else tint it
210
+ @function shift-color($color, $weight) {
211
+ @return if($weight > 0, shade-color($color, $weight), tint-color($color, -$weight));
212
+ }
213
+ // scss-docs-end color-functions
214
+
215
+ // Return valid calc
216
+ @function add($value1, $value2, $return-calc: true) {
217
+ @if $value1 == null {
218
+ @return $value2;
219
+ }
220
+
221
+ @if $value2 == null {
222
+ @return $value1;
223
+ }
224
+
225
+ @if type-of($value1) == number and type-of($value2) == number and comparable($value1, $value2) {
226
+ @return $value1 + $value2;
227
+ }
228
+
229
+ @return if($return-calc == true, calc(#{$value1} + #{$value2}), $value1 + unquote(" + ") + $value2);
230
+ }
84
231
 
85
- @return mix($color-base, $color, $level * $theme-color-interval);
232
+ @function subtract($value1, $value2, $return-calc: true) {
233
+ @if $value1 == null and $value2 == null {
234
+ @return null;
235
+ }
236
+
237
+ @if $value1 == null {
238
+ @return -$value2;
239
+ }
240
+
241
+ @if $value2 == null {
242
+ @return $value1;
243
+ }
244
+
245
+ @if type-of($value1) == number and type-of($value2) == number and comparable($value1, $value2) {
246
+ @return $value1 - $value2;
247
+ }
248
+
249
+ @if type-of($value2) != number {
250
+ $value2: unquote("(") + $value2 + unquote(")");
251
+ }
252
+
253
+ @return if($return-calc == true, calc(#{$value1} - #{$value2}), $value1 + unquote(" - ") + $value2);
254
+ }
255
+
256
+ @function divide($dividend, $divisor, $precision: 10) {
257
+ $sign: if($dividend > 0 and $divisor > 0 or $dividend < 0 and $divisor < 0, 1, -1);
258
+ $dividend: abs($dividend);
259
+ $divisor: abs($divisor);
260
+ @if $dividend == 0 {
261
+ @return 0;
262
+ }
263
+ @if $divisor == 0 {
264
+ @error "Cannot divide by 0";
265
+ }
266
+ $remainder: $dividend;
267
+ $result: 0;
268
+ $factor: 10;
269
+ @while ($remainder > 0 and $precision >= 0) {
270
+ $quotient: 0;
271
+ @while ($remainder >= $divisor) {
272
+ $remainder: $remainder - $divisor;
273
+ $quotient: $quotient + 1;
274
+ }
275
+ $result: $result * 10 + $quotient;
276
+ $factor: $factor * .1;
277
+ $remainder: $remainder * 10;
278
+ $precision: $precision - 1;
279
+ @if ($precision < 0 and $remainder >= $divisor * 5) {
280
+ $result: $result + 1;
281
+ }
282
+ }
283
+ $result: $result * $factor * $sign;
284
+ $dividend-unit: unit($dividend);
285
+ $divisor-unit: unit($divisor);
286
+ $unit-map: (
287
+ "px": 1px,
288
+ "rem": 1rem,
289
+ "em": 1em,
290
+ "%": 1%
291
+ );
292
+ @if ($dividend-unit != $divisor-unit and map-has-key($unit-map, $dividend-unit)) {
293
+ $result: $result * map-get($unit-map, $dividend-unit);
294
+ }
295
+ @return $result;
86
296
  }