bootstrap 4.4.1 → 5.0.0.alpha2

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 (136) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +12 -2
  3. data/README.md +1 -1
  4. data/assets/javascripts/bootstrap-sprockets.js +12 -8
  5. data/assets/javascripts/bootstrap.js +2094 -1562
  6. data/assets/javascripts/bootstrap.min.js +4 -4
  7. data/assets/javascripts/bootstrap/alert.js +145 -83
  8. data/assets/javascripts/bootstrap/button.js +66 -152
  9. data/assets/javascripts/bootstrap/carousel.js +307 -241
  10. data/assets/javascripts/bootstrap/collapse.js +287 -183
  11. data/assets/javascripts/bootstrap/dom/data.js +81 -0
  12. data/assets/javascripts/bootstrap/dom/event-handler.js +315 -0
  13. data/assets/javascripts/bootstrap/dom/manipulator.js +96 -0
  14. data/assets/javascripts/bootstrap/dom/polyfill.js +110 -0
  15. data/assets/javascripts/bootstrap/dom/selector-engine.js +98 -0
  16. data/assets/javascripts/bootstrap/dropdown.js +255 -261
  17. data/assets/javascripts/bootstrap/modal.js +364 -270
  18. data/assets/javascripts/bootstrap/popover.js +72 -113
  19. data/assets/javascripts/bootstrap/scrollspy.js +162 -147
  20. data/assets/javascripts/bootstrap/tab.js +176 -108
  21. data/assets/javascripts/bootstrap/toast.js +179 -139
  22. data/assets/javascripts/bootstrap/tooltip.js +369 -259
  23. data/assets/stylesheets/_bootstrap-grid.scss +54 -18
  24. data/assets/stylesheets/_bootstrap-reboot.scss +7 -4
  25. data/assets/stylesheets/_bootstrap.scss +17 -11
  26. data/assets/stylesheets/bootstrap/_alert.scss +6 -7
  27. data/assets/stylesheets/bootstrap/_badge.scss +2 -27
  28. data/assets/stylesheets/bootstrap/_breadcrumb.scss +5 -17
  29. data/assets/stylesheets/bootstrap/_button-group.scss +16 -38
  30. data/assets/stylesheets/bootstrap/_buttons.scss +25 -40
  31. data/assets/stylesheets/bootstrap/_card.scss +43 -79
  32. data/assets/stylesheets/bootstrap/_carousel.scss +30 -15
  33. data/assets/stylesheets/bootstrap/_close.scss +31 -31
  34. data/assets/stylesheets/bootstrap/_containers.scss +41 -0
  35. data/assets/stylesheets/bootstrap/_dropdown.scss +54 -9
  36. data/assets/stylesheets/bootstrap/_forms.scss +9 -338
  37. data/assets/stylesheets/bootstrap/_functions.scss +97 -25
  38. data/assets/stylesheets/bootstrap/_grid.scss +3 -50
  39. data/assets/stylesheets/bootstrap/_helpers.scss +7 -0
  40. data/assets/stylesheets/bootstrap/_list-group.scss +16 -17
  41. data/assets/stylesheets/bootstrap/_mixins.scss +7 -13
  42. data/assets/stylesheets/bootstrap/_modal.scss +41 -45
  43. data/assets/stylesheets/bootstrap/_nav.scss +16 -9
  44. data/assets/stylesheets/bootstrap/_navbar.scss +43 -74
  45. data/assets/stylesheets/bootstrap/_pagination.scss +11 -20
  46. data/assets/stylesheets/bootstrap/_popover.scss +5 -5
  47. data/assets/stylesheets/bootstrap/_progress.scss +2 -3
  48. data/assets/stylesheets/bootstrap/_reboot.scss +310 -175
  49. data/assets/stylesheets/bootstrap/_root.scss +5 -9
  50. data/assets/stylesheets/bootstrap/_spinners.scss +5 -4
  51. data/assets/stylesheets/bootstrap/_tables.scss +80 -114
  52. data/assets/stylesheets/bootstrap/_toasts.scss +6 -2
  53. data/assets/stylesheets/bootstrap/_tooltip.scss +5 -5
  54. data/assets/stylesheets/bootstrap/_transitions.scss +0 -1
  55. data/assets/stylesheets/bootstrap/_type.scss +38 -59
  56. data/assets/stylesheets/bootstrap/_utilities.scss +531 -17
  57. data/assets/stylesheets/bootstrap/_variables.scss +609 -444
  58. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +18 -0
  59. data/assets/stylesheets/bootstrap/forms/_form-check.scss +142 -0
  60. data/assets/stylesheets/bootstrap/forms/_form-control.scss +116 -0
  61. data/assets/stylesheets/bootstrap/forms/_form-file.scss +91 -0
  62. data/assets/stylesheets/bootstrap/forms/_form-range.scss +136 -0
  63. data/assets/stylesheets/bootstrap/forms/_form-select.scss +82 -0
  64. data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
  65. data/assets/stylesheets/bootstrap/forms/_input-group.scss +140 -0
  66. data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
  67. data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
  68. data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
  69. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +12 -0
  70. data/assets/stylesheets/bootstrap/helpers/_position.scss +30 -0
  71. data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
  72. data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
  73. data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
  74. data/assets/stylesheets/bootstrap/helpers/_visually-hidden.scss +8 -0
  75. data/assets/stylesheets/bootstrap/mixins/_alert.scss +0 -4
  76. data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +35 -22
  77. data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +7 -9
  78. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +14 -10
  79. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +69 -51
  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 +11 -0
  83. data/assets/stylesheets/bootstrap/mixins/_forms.scss +22 -66
  84. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +9 -11
  85. data/assets/stylesheets/bootstrap/mixins/_grid.scss +84 -33
  86. data/assets/stylesheets/bootstrap/mixins/_image.scss +1 -21
  87. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +2 -1
  88. data/assets/stylesheets/bootstrap/mixins/_lists.scss +1 -1
  89. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +15 -8
  90. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +2 -2
  91. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
  92. data/assets/stylesheets/bootstrap/mixins/_transition.scss +18 -8
  93. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +49 -0
  94. data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +28 -0
  95. data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
  96. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +234 -126
  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/gemfiles/rails_6_0.gemfile +7 -0
  101. metadata +36 -41
  102. data/assets/javascripts/bootstrap/util.js +0 -188
  103. data/assets/stylesheets/bootstrap/_code.scss +0 -48
  104. data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -521
  105. data/assets/stylesheets/bootstrap/_input-group.scss +0 -191
  106. data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
  107. data/assets/stylesheets/bootstrap/_media.scss +0 -8
  108. data/assets/stylesheets/bootstrap/_print.scss +0 -141
  109. data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -22
  110. data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
  111. data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
  112. data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -71
  113. data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
  114. data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -11
  115. data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +0 -34
  116. data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
  117. data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
  118. data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -17
  119. data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
  120. data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
  121. data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
  122. data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
  123. data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
  124. data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
  125. data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
  126. data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
  127. data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
  128. data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
  129. data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
  130. data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
  131. data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
  132. data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
  133. data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
  134. data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
  135. data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
  136. data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
@@ -1,338 +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
- // Remove select outline from select box in FF
34
- &:-moz-focusring {
35
- color: transparent;
36
- text-shadow: 0 0 0 $input-color;
37
- }
38
-
39
- // Customize the `:focus` state to imitate native WebKit styles.
40
- @include form-control-focus($ignore-warning: true);
41
-
42
- // Placeholder
43
- &::placeholder {
44
- color: $input-placeholder-color;
45
- // Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526.
46
- opacity: 1;
47
- }
48
-
49
- // Disabled and read-only inputs
50
- //
51
- // HTML5 says that controls under a fieldset > legend:first-child won't be
52
- // disabled if the fieldset is disabled. Due to implementation difficulty, we
53
- // don't honor that edge case; we style them as disabled anyway.
54
- &:disabled,
55
- &[readonly] {
56
- background-color: $input-disabled-bg;
57
- // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
58
- opacity: 1;
59
- }
60
- }
61
-
62
- select.form-control {
63
- &:focus::-ms-value {
64
- // Suppress the nested default white text on blue background highlight given to
65
- // the selected option text when the (still closed) <select> receives focus
66
- // in IE and (under certain conditions) Edge, as it looks bad and cannot be made to
67
- // match the appearance of the native widget.
68
- // See https://github.com/twbs/bootstrap/issues/19398.
69
- color: $input-color;
70
- background-color: $input-bg;
71
- }
72
- }
73
-
74
- // Make file inputs better match text inputs by forcing them to new lines.
75
- .form-control-file,
76
- .form-control-range {
77
- display: block;
78
- width: 100%;
79
- }
80
-
81
-
82
- //
83
- // Labels
84
- //
85
-
86
- // For use with horizontal and inline forms, when you need the label (or legend)
87
- // text to align with the form controls.
88
- .col-form-label {
89
- padding-top: add($input-padding-y, $input-border-width);
90
- padding-bottom: add($input-padding-y, $input-border-width);
91
- margin-bottom: 0; // Override the `<label>/<legend>` default
92
- @include font-size(inherit); // Override the `<legend>` default
93
- line-height: $input-line-height;
94
- }
95
-
96
- .col-form-label-lg {
97
- padding-top: add($input-padding-y-lg, $input-border-width);
98
- padding-bottom: add($input-padding-y-lg, $input-border-width);
99
- @include font-size($input-font-size-lg);
100
- line-height: $input-line-height-lg;
101
- }
102
-
103
- .col-form-label-sm {
104
- padding-top: add($input-padding-y-sm, $input-border-width);
105
- padding-bottom: add($input-padding-y-sm, $input-border-width);
106
- @include font-size($input-font-size-sm);
107
- line-height: $input-line-height-sm;
108
- }
109
-
110
-
111
- // Readonly controls as plain text
112
- //
113
- // Apply class to a readonly input to make it appear like regular plain
114
- // text (without any border, background color, focus indicator)
115
-
116
- .form-control-plaintext {
117
- display: block;
118
- width: 100%;
119
- padding: $input-padding-y 0;
120
- margin-bottom: 0; // match inputs if this class comes on inputs with default margins
121
- @include font-size($input-font-size);
122
- line-height: $input-line-height;
123
- color: $input-plaintext-color;
124
- background-color: transparent;
125
- border: solid transparent;
126
- border-width: $input-border-width 0;
127
-
128
- &.form-control-sm,
129
- &.form-control-lg {
130
- padding-right: 0;
131
- padding-left: 0;
132
- }
133
- }
134
-
135
-
136
- // Form control sizing
137
- //
138
- // Build on `.form-control` with modifier classes to decrease or increase the
139
- // height and font-size of form controls.
140
- //
141
- // Repeated in `_input_group.scss` to avoid Sass extend issues.
142
-
143
- .form-control-sm {
144
- height: $input-height-sm;
145
- padding: $input-padding-y-sm $input-padding-x-sm;
146
- @include font-size($input-font-size-sm);
147
- line-height: $input-line-height-sm;
148
- @include border-radius($input-border-radius-sm);
149
- }
150
-
151
- .form-control-lg {
152
- height: $input-height-lg;
153
- padding: $input-padding-y-lg $input-padding-x-lg;
154
- @include font-size($input-font-size-lg);
155
- line-height: $input-line-height-lg;
156
- @include border-radius($input-border-radius-lg);
157
- }
158
-
159
- // stylelint-disable-next-line no-duplicate-selectors
160
- select.form-control {
161
- &[size],
162
- &[multiple] {
163
- height: auto;
164
- }
165
- }
166
-
167
- textarea.form-control {
168
- height: auto;
169
- }
170
-
171
- // Form groups
172
- //
173
- // Designed to help with the organization and spacing of vertical forms. For
174
- // horizontal forms, use the predefined grid classes.
175
-
176
- .form-group {
177
- margin-bottom: $form-group-margin-bottom;
178
- }
179
-
180
- .form-text {
181
- display: block;
182
- margin-top: $form-text-margin-top;
183
- }
184
-
185
-
186
- // Form grid
187
- //
188
- // Special replacement for our grid system's `.row` for tighter form layouts.
189
-
190
- .form-row {
191
- display: flex;
192
- flex-wrap: wrap;
193
- margin-right: -$form-grid-gutter-width / 2;
194
- margin-left: -$form-grid-gutter-width / 2;
195
-
196
- > .col,
197
- > [class*="col-"] {
198
- padding-right: $form-grid-gutter-width / 2;
199
- padding-left: $form-grid-gutter-width / 2;
200
- }
201
- }
202
-
203
-
204
- // Checkboxes and radios
205
- //
206
- // Indent the labels to position radios/checkboxes as hanging controls.
207
-
208
- .form-check {
209
- position: relative;
210
- display: block;
211
- padding-left: $form-check-input-gutter;
212
- }
213
-
214
- .form-check-input {
215
- position: absolute;
216
- margin-top: $form-check-input-margin-y;
217
- margin-left: -$form-check-input-gutter;
218
-
219
- // Use [disabled] and :disabled for workaround https://github.com/twbs/bootstrap/issues/28247
220
- &[disabled] ~ .form-check-label,
221
- &:disabled ~ .form-check-label {
222
- color: $text-muted;
223
- }
224
- }
225
-
226
- .form-check-label {
227
- margin-bottom: 0; // Override default `<label>` bottom margin
228
- }
229
-
230
- .form-check-inline {
231
- display: inline-flex;
232
- align-items: center;
233
- padding-left: 0; // Override base .form-check
234
- margin-right: $form-check-inline-margin-x;
235
-
236
- // Undo .form-check-input defaults and add some `margin-right`.
237
- .form-check-input {
238
- position: static;
239
- margin-top: 0;
240
- margin-right: $form-check-inline-input-margin-x;
241
- margin-left: 0;
242
- }
243
- }
244
-
245
-
246
- // Form validation
247
- //
248
- // Provide feedback to users when form field values are valid or invalid. Works
249
- // primarily for client-side validation via scoped `:invalid` and `:valid`
250
- // pseudo-classes but also includes `.is-invalid` and `.is-valid` classes for
251
- // server side validation.
252
-
253
- @each $state, $data in $form-validation-states {
254
- @include form-validation-state($state, map-get($data, color), map-get($data, icon));
255
- }
256
-
257
- // Inline forms
258
- //
259
- // Make forms appear inline(-block) by adding the `.form-inline` class. Inline
260
- // forms begin stacked on extra small (mobile) devices and then go inline when
261
- // viewports reach <768px.
262
- //
263
- // Requires wrapping inputs and labels with `.form-group` for proper display of
264
- // default HTML form controls and our custom form controls (e.g., input groups).
265
-
266
- .form-inline {
267
- display: flex;
268
- flex-flow: row wrap;
269
- align-items: center; // Prevent shorter elements from growing to same height as others (e.g., small buttons growing to normal sized button height)
270
-
271
- // Because we use flex, the initial sizing of checkboxes is collapsed and
272
- // doesn't occupy the full-width (which is what we want for xs grid tier),
273
- // so we force that here.
274
- .form-check {
275
- width: 100%;
276
- }
277
-
278
- // Kick in the inline
279
- @include media-breakpoint-up(sm) {
280
- label {
281
- display: flex;
282
- align-items: center;
283
- justify-content: center;
284
- margin-bottom: 0;
285
- }
286
-
287
- // Inline-block all the things for "inline"
288
- .form-group {
289
- display: flex;
290
- flex: 0 0 auto;
291
- flex-flow: row wrap;
292
- align-items: center;
293
- margin-bottom: 0;
294
- }
295
-
296
- // Allow folks to *not* use `.form-group`
297
- .form-control {
298
- display: inline-block;
299
- width: auto; // Prevent labels from stacking above inputs in `.form-group`
300
- vertical-align: middle;
301
- }
302
-
303
- // Make static controls behave like regular ones
304
- .form-control-plaintext {
305
- display: inline-block;
306
- }
307
-
308
- .input-group,
309
- .custom-select {
310
- width: auto;
311
- }
312
-
313
- // Remove default margin on radios/checkboxes that were used for stacking, and
314
- // then undo the floating of radios and checkboxes to match.
315
- .form-check {
316
- display: flex;
317
- align-items: center;
318
- justify-content: center;
319
- width: auto;
320
- padding-left: 0;
321
- }
322
- .form-check-input {
323
- position: relative;
324
- flex-shrink: 0;
325
- margin-top: 0;
326
- margin-right: $form-check-input-margin-x;
327
- margin-left: 0;
328
- }
329
-
330
- .custom-control {
331
- align-items: center;
332
- justify-content: center;
333
- }
334
- .custom-control-label {
335
- margin-bottom: 0;
336
- }
337
- }
338
- }
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";
@@ -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
+ }
30
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
+ }
54
+ }
55
+ @return $result;
31
56
  }
32
57
 
33
58
  // Replace `$search` with `$replace` in `$string`
@@ -49,10 +74,18 @@
49
74
  }
50
75
 
51
76
  // See https://codepen.io/kevinweber/pen/dXWoRw
77
+ //
78
+ // Requires the use of quotes around data URIs.
79
+
52
80
  @function escape-svg($string) {
53
81
  @if str-index($string, "data:image/svg+xml") {
54
82
  @each $char, $encoded in $escaped-characters {
55
- $string: str-replace($string, $char, $encoded);
83
+ // Do not escape the url brackets
84
+ @if str-index($string, "url(") == 1 {
85
+ $string: url("#{str-replace(str-slice($string, 6, -3), $char, $encoded)}");
86
+ } @else {
87
+ $string: str-replace($string, $char, $encoded);
88
+ }
56
89
  }
57
90
  }
58
91
 
@@ -60,41 +93,80 @@
60
93
  }
61
94
 
62
95
  // Color contrast
63
- @function color-yiq($color, $dark: $yiq-text-dark, $light: $yiq-text-light) {
64
- $r: red($color);
65
- $g: green($color);
66
- $b: blue($color);
96
+ // See https://github.com/twbs/bootstrap/pull/30168
97
+
98
+ // A list of pre-calculated numbers of pow(($value / 255 + .055) / 1.055, 2.4). (from 0 to 255)
99
+ // stylelint-disable-next-line scss/dollar-variable-default, scss/dollar-variable-pattern
100
+ $_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;
101
+
102
+ @function color-contrast($background, $color-contrast-dark: $color-contrast-dark, $color-contrast-light: $color-contrast-light, $min-contrast-ratio: $min-contrast-ratio) {
103
+ $foregrounds: $color-contrast-light, $color-contrast-dark, $white, $black;
104
+ $max-ratio: 0;
105
+ $max-ratio-color: null;
106
+
107
+ @each $color in $foregrounds {
108
+ $contrast-ratio: contrast-ratio($background, $color);
109
+ @if $contrast-ratio > $min-contrast-ratio {
110
+ @return $color;
111
+ } @else if $contrast-ratio > $max-ratio {
112
+ $max-ratio: $contrast-ratio;
113
+ $max-ratio-color: $color;
114
+ }
115
+ }
67
116
 
68
- $yiq: (($r * 299) + ($g * 587) + ($b * 114)) / 1000;
117
+ @warn "Found no color leading to #{$min-contrast-ratio}:1 contrast ratio against #{$background}...";
69
118
 
70
- @if ($yiq >= $yiq-contrasted-threshold) {
71
- @return $dark;
72
- } @else {
73
- @return $light;
74
- }
119
+ @return $max-ratio-color;
75
120
  }
76
121
 
77
- // Retrieve color Sass maps
78
- @function color($key: "blue") {
79
- @return map-get($colors, $key);
122
+ @function contrast-ratio($background, $foreground: $color-contrast-light) {
123
+ $l1: luminance($background);
124
+ $l2: luminance(opaque($background, $foreground));
125
+
126
+ @return if($l1 > $l2, ($l1 + .05) / ($l2 + .05), ($l2 + .05) / ($l1 + .05));
80
127
  }
81
128
 
82
- @function theme-color($key: "primary") {
83
- @return map-get($theme-colors, $key);
129
+ // Return WCAG2.0 relative luminance
130
+ // See https://www.w3.org/WAI/GL/wiki/Relative_luminance
131
+ // See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests
132
+ @function luminance($color) {
133
+ $rgb: (
134
+ "r": red($color),
135
+ "g": green($color),
136
+ "b": blue($color)
137
+ );
138
+
139
+ @each $name, $value in $rgb {
140
+ $value: if($value / 255 < .03928, $value / 255 / 12.92, nth($_luminance-list, $value + 1));
141
+ $rgb: map-merge($rgb, ($name: $value));
142
+ }
143
+
144
+ @return (map-get($rgb, "r") * .2126) + (map-get($rgb, "g") * .7152) + (map-get($rgb, "b") * .0722);
84
145
  }
85
146
 
86
- @function gray($key: "100") {
87
- @return map-get($grays, $key);
147
+ // Return opaque color
148
+ // opaque(#fff, rgba(0, 0, 0, .5)) => #808080
149
+ @function opaque($background, $foreground) {
150
+ @return mix(rgba($foreground, 1), $background, opacity($foreground) * 100);
88
151
  }
89
152
 
90
- // Request a theme color level
91
- @function theme-color-level($color-name: "primary", $level: 0) {
92
- $color: theme-color($color-name);
153
+ // Request a color level
154
+ // scss-docs-start color-level
155
+ @function color-level($color: $primary, $level: 0) {
93
156
  $color-base: if($level > 0, $black, $white);
94
157
  $level: abs($level);
95
158
 
96
159
  @return mix($color-base, $color, $level * $theme-color-interval);
97
160
  }
161
+ // scss-docs-end color-level
162
+
163
+ @function tint-color($color, $level) {
164
+ @return mix(white, $color, $level * $theme-color-interval);
165
+ }
166
+
167
+ @function shade-color($color, $level) {
168
+ @return mix(black, $color, $level * $theme-color-interval);
169
+ }
98
170
 
99
171
  // Return valid calc
100
172
  @function add($value1, $value2, $return-calc: true) {