bootstrap 4.3.0 → 5.0.0.alpha1

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 (139) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +15 -1
  3. data/CHANGELOG.md +2 -14
  4. data/README.md +1 -1
  5. data/assets/javascripts/bootstrap-sprockets.js +5 -1
  6. data/assets/javascripts/bootstrap.js +2292 -1514
  7. data/assets/javascripts/bootstrap.min.js +4 -4
  8. data/assets/javascripts/bootstrap/alert.js +148 -85
  9. data/assets/javascripts/bootstrap/button.js +69 -110
  10. data/assets/javascripts/bootstrap/carousel.js +320 -239
  11. data/assets/javascripts/bootstrap/collapse.js +300 -177
  12. data/assets/javascripts/bootstrap/dom/data.js +81 -0
  13. data/assets/javascripts/bootstrap/dom/event-handler.js +311 -0
  14. data/assets/javascripts/bootstrap/dom/manipulator.js +100 -0
  15. data/assets/javascripts/bootstrap/dom/polyfill.js +110 -0
  16. data/assets/javascripts/bootstrap/dom/selector-engine.js +98 -0
  17. data/assets/javascripts/bootstrap/dropdown.js +282 -265
  18. data/assets/javascripts/bootstrap/modal.js +348 -231
  19. data/assets/javascripts/bootstrap/popover.js +80 -105
  20. data/assets/javascripts/bootstrap/scrollspy.js +173 -138
  21. data/assets/javascripts/bootstrap/tab.js +180 -115
  22. data/assets/javascripts/bootstrap/toast.js +188 -132
  23. data/assets/javascripts/bootstrap/tooltip.js +508 -230
  24. data/assets/stylesheets/_bootstrap-grid.scss +54 -18
  25. data/assets/stylesheets/_bootstrap-reboot.scss +7 -4
  26. data/assets/stylesheets/_bootstrap.scss +17 -11
  27. data/assets/stylesheets/bootstrap/_alert.scss +3 -3
  28. data/assets/stylesheets/bootstrap/_badge.scss +2 -27
  29. data/assets/stylesheets/bootstrap/_breadcrumb.scss +7 -18
  30. data/assets/stylesheets/bootstrap/_button-group.scss +16 -38
  31. data/assets/stylesheets/bootstrap/_buttons.scss +26 -39
  32. data/assets/stylesheets/bootstrap/_card.scss +48 -97
  33. data/assets/stylesheets/bootstrap/_carousel.scss +16 -18
  34. data/assets/stylesheets/bootstrap/_close.scss +9 -14
  35. data/assets/stylesheets/bootstrap/_containers.scss +41 -0
  36. data/assets/stylesheets/bootstrap/_dropdown.scss +13 -9
  37. data/assets/stylesheets/bootstrap/_forms.scss +9 -330
  38. data/assets/stylesheets/bootstrap/_functions.scss +141 -24
  39. data/assets/stylesheets/bootstrap/_grid.scss +4 -34
  40. data/assets/stylesheets/bootstrap/_helpers.scss +7 -0
  41. data/assets/stylesheets/bootstrap/_images.scss +2 -2
  42. data/assets/stylesheets/bootstrap/_list-group.scss +41 -33
  43. data/assets/stylesheets/bootstrap/_mixins.scss +9 -15
  44. data/assets/stylesheets/bootstrap/_modal.scss +54 -48
  45. data/assets/stylesheets/bootstrap/_nav.scss +12 -9
  46. data/assets/stylesheets/bootstrap/_navbar.scss +54 -56
  47. data/assets/stylesheets/bootstrap/_pagination.scss +10 -22
  48. data/assets/stylesheets/bootstrap/_popover.scss +13 -14
  49. data/assets/stylesheets/bootstrap/_progress.scss +6 -4
  50. data/assets/stylesheets/bootstrap/_reboot.scss +318 -185
  51. data/assets/stylesheets/bootstrap/_root.scss +5 -8
  52. data/assets/stylesheets/bootstrap/_spinners.scss +3 -2
  53. data/assets/stylesheets/bootstrap/_tables.scss +80 -114
  54. data/assets/stylesheets/bootstrap/_tooltip.scss +5 -5
  55. data/assets/stylesheets/bootstrap/_transitions.scss +0 -1
  56. data/assets/stylesheets/bootstrap/_type.scss +40 -61
  57. data/assets/stylesheets/bootstrap/_utilities.scss +503 -17
  58. data/assets/stylesheets/bootstrap/_variables.scss +567 -430
  59. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +18 -0
  60. data/assets/stylesheets/bootstrap/forms/_form-check.scss +142 -0
  61. data/assets/stylesheets/bootstrap/forms/_form-control.scss +116 -0
  62. data/assets/stylesheets/bootstrap/forms/_form-file.scss +91 -0
  63. data/assets/stylesheets/bootstrap/forms/_form-range.scss +136 -0
  64. data/assets/stylesheets/bootstrap/forms/_form-select.scss +82 -0
  65. data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
  66. data/assets/stylesheets/bootstrap/forms/_input-group.scss +140 -0
  67. data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
  68. data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
  69. data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
  70. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +12 -0
  71. data/assets/stylesheets/bootstrap/helpers/_embed.scss +31 -0
  72. data/assets/stylesheets/bootstrap/helpers/_position.scss +30 -0
  73. data/assets/stylesheets/bootstrap/helpers/_screenreaders.scss +8 -0
  74. data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
  75. data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
  76. data/assets/stylesheets/bootstrap/mixins/_alert.scss +0 -4
  77. data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +26 -13
  78. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +11 -8
  79. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +68 -50
  80. data/assets/stylesheets/bootstrap/mixins/_caret.scss +4 -4
  81. data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
  82. data/assets/stylesheets/bootstrap/mixins/_container.scss +9 -0
  83. data/assets/stylesheets/bootstrap/mixins/_forms.scss +47 -106
  84. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +9 -11
  85. data/assets/stylesheets/bootstrap/mixins/_grid.scss +99 -29
  86. data/assets/stylesheets/bootstrap/mixins/_image.scss +0 -20
  87. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +2 -1
  88. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +15 -8
  89. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +1 -1
  90. data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +14 -19
  91. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
  92. data/assets/stylesheets/bootstrap/mixins/_transition.scss +17 -7
  93. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +49 -0
  94. data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
  95. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +230 -130
  96. data/bootstrap.gemspec +1 -1
  97. data/lib/bootstrap/version.rb +2 -2
  98. data/tasks/updater/js.rb +3 -3
  99. data/tasks/updater/network.rb +2 -2
  100. data/test/dummy_rails/app/assets/config/manifest.js +3 -0
  101. data/test/dummy_rails/app/assets/stylesheets/.browserslistrc +1 -0
  102. data/test/gemfiles/rails_6_0.gemfile +7 -0
  103. data/test/support/dummy_rails_integration.rb +3 -1
  104. data/test/test_helper.rb +18 -13
  105. metadata +40 -42
  106. data/assets/javascripts/bootstrap/util.js +0 -171
  107. data/assets/stylesheets/bootstrap/_code.scss +0 -48
  108. data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -507
  109. data/assets/stylesheets/bootstrap/_input-group.scss +0 -193
  110. data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
  111. data/assets/stylesheets/bootstrap/_media.scss +0 -8
  112. data/assets/stylesheets/bootstrap/_print.scss +0 -141
  113. data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -21
  114. data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
  115. data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
  116. data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -66
  117. data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
  118. data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -10
  119. data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
  120. data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
  121. data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -16
  122. data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
  123. data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
  124. data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
  125. data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
  126. data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
  127. data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
  128. data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
  129. data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
  130. data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
  131. data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
  132. data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
  133. data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
  134. data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
  135. data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
  136. data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
  137. data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
  138. data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
  139. data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
@@ -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-file";
7
+ @import "forms/form-range";
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,36 @@
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
+ // Internal Bootstrap function to turn maps into its negative variant.
36
+ // It prefixes the keys with `n` and makes the value negative.
37
+ @function negativify-map($map) {
38
+ $result: ();
39
+ @each $key, $value in $map {
40
+ @if $key != 0 {
41
+ $result: map-merge($result, ("n" + $key: (-$value)));
42
+ }
43
+ }
44
+ @return $result;
45
+ }
46
+
47
+ // Get multiple keys from a sass map
48
+ @function map-get-multiple($map, $values) {
49
+ $result: ();
50
+ @each $key, $value in $map {
51
+ @if (index($values, $key) != null) {
52
+ $result: map-merge($result, ($key: $value));
53
+ }
30
54
  }
55
+ @return $result;
31
56
  }
32
57
 
33
58
  // Replace `$search` with `$replace` in `$string`
@@ -48,39 +73,131 @@
48
73
  @return $string;
49
74
  }
50
75
 
76
+ // See https://codepen.io/kevinweber/pen/dXWoRw
77
+ @function escape-svg($string) {
78
+ @if str-index($string, "data:image/svg+xml") {
79
+ @each $char, $encoded in $escaped-characters {
80
+ // Do not escape the url brackets
81
+ @if str-index($string, "url(") == 1 {
82
+ $string: url("#{str-replace(str-slice($string, 6, -3), $char, $encoded)}");
83
+ } @else {
84
+ $string: str-replace($string, $char, $encoded);
85
+ }
86
+ }
87
+ }
88
+
89
+ @return $string;
90
+ }
91
+
51
92
  // 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);
93
+ // See https://github.com/twbs/bootstrap/pull/30168
56
94
 
57
- $yiq: (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
95
+ // A list of pre-calculated numbers of pow(($value / 255 + .055) / 1.055, 2.4). (from 0 to 255)
96
+ // stylelint-disable-next-line scss/dollar-variable-default, scss/dollar-variable-pattern
97
+ $_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;
58
98
 
59
- @if ($yiq >= $yiq-contrasted-threshold) {
60
- @return $dark;
61
- } @else {
62
- @return $light;
99
+ @function color-contrast($background, $color-contrast-dark: $color-contrast-dark, $color-contrast-light: $color-contrast-light, $min-contrast-ratio: $min-contrast-ratio) {
100
+ $foregrounds: $color-contrast-light, $color-contrast-dark, $white, $black;
101
+ $max-ratio: 0;
102
+ $max-ratio-color: null;
103
+
104
+ @each $color in $foregrounds {
105
+ $contrast-ratio: contrast-ratio($background, $color);
106
+ @if $contrast-ratio > $min-contrast-ratio {
107
+ @return $color;
108
+ } @else if $contrast-ratio > $max-ratio {
109
+ $max-ratio: $contrast-ratio;
110
+ $max-ratio-color: $color;
111
+ }
63
112
  }
113
+
114
+ @warn "Found no color leading to #{$min-contrast-ratio}:1 contrast ratio against #{$background}…";
115
+
116
+ @return $max-ratio-color;
64
117
  }
65
118
 
66
- // Retrieve color Sass maps
67
- @function color($key: "blue") {
68
- @return map-get($colors, $key);
119
+ @function contrast-ratio($background, $foreground: $color-contrast-light) {
120
+ $l1: luminance($background);
121
+ $l2: luminance(opaque($background, $foreground));
122
+
123
+ @return if($l1 > $l2, ($l1 + .05) / ($l2 + .05), ($l2 + .05) / ($l1 + .05));
69
124
  }
70
125
 
71
- @function theme-color($key: "primary") {
72
- @return map-get($theme-colors, $key);
126
+ // Return WCAG2.0 relative luminance
127
+ // See https://www.w3.org/WAI/GL/wiki/Relative_luminance
128
+ // See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
129
+ @function luminance($color) {
130
+ $rgb: (
131
+ "r": red($color),
132
+ "g": green($color),
133
+ "b": blue($color)
134
+ );
135
+
136
+ @each $name, $value in $rgb {
137
+ $value: if($value / 255 < .03928, $value / 255 / 12.92, nth($_luminance-list, $value + 1));
138
+ $rgb: map-merge($rgb, ($name: $value));
139
+ }
140
+
141
+ @return (map-get($rgb, "r") * .2126) + (map-get($rgb, "g") * .7152) + (map-get($rgb, "b") * .0722);
73
142
  }
74
143
 
75
- @function gray($key: "100") {
76
- @return map-get($grays, $key);
144
+ // Return opaque color
145
+ // opaque(#fff, rgba(0, 0, 0, .5)) => #808080
146
+ @function opaque($background, $foreground) {
147
+ @return mix(rgba($foreground, 1), $background, opacity($foreground) * 100);
77
148
  }
78
149
 
79
- // Request a theme color level
80
- @function theme-color-level($color-name: "primary", $level: 0) {
81
- $color: theme-color($color-name);
150
+ // Request a color level
151
+ // scss-docs-start color-level
152
+ @function color-level($color: $primary, $level: 0) {
82
153
  $color-base: if($level > 0, $black, $white);
83
154
  $level: abs($level);
84
155
 
85
156
  @return mix($color-base, $color, $level * $theme-color-interval);
86
157
  }
158
+ // scss-docs-end color-level
159
+
160
+ @function tint-color($color, $level) {
161
+ @return mix(white, $color, $level * $theme-color-interval);
162
+ }
163
+
164
+ @function shade-color($color, $level) {
165
+ @return mix(black, $color, $level * $theme-color-interval);
166
+ }
167
+
168
+ // Return valid calc
169
+ @function add($value1, $value2, $return-calc: true) {
170
+ @if $value1 == null {
171
+ @return $value2;
172
+ }
173
+
174
+ @if $value2 == null {
175
+ @return $value1;
176
+ }
177
+
178
+ @if type-of($value1) == number and type-of($value2) == number and comparable($value1, $value2) {
179
+ @return $value1 + $value2;
180
+ }
181
+
182
+ @return if($return-calc == true, calc(#{$value1} + #{$value2}), $value1 + unquote(" + ") + $value2);
183
+ }
184
+
185
+ @function subtract($value1, $value2, $return-calc: true) {
186
+ @if $value1 == null and $value2 == null {
187
+ @return null;
188
+ }
189
+
190
+ @if $value1 == null {
191
+ @return -$value2;
192
+ }
193
+
194
+ @if $value2 == null {
195
+ @return $value1;
196
+ }
197
+
198
+ @if type-of($value1) == number and type-of($value2) == number and comparable($value1, $value2) {
199
+ @return $value1 - $value2;
200
+ }
201
+
202
+ @return if($return-calc == true, calc(#{$value1} - #{$value2}), $value1 + unquote(" - ") + $value2);
203
+ }