administrate-bootstrap-theme 0.1.0 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -11
  3. data/Rakefile +10 -14
  4. data/app/assets/config/administrate-bootstrap-theme_manifest.js +1 -0
  5. data/app/assets/javascripts/administrate-bootstrap-theme/theme.js +2 -0
  6. data/app/assets/stylesheets/administrate-bootstrap-theme/_base.scss +17 -1
  7. data/app/assets/stylesheets/administrate-bootstrap-theme/components/_content_body.scss +17 -3
  8. data/app/assets/stylesheets/administrate-bootstrap-theme/components/_form.scss +52 -16
  9. data/app/assets/stylesheets/administrate-bootstrap-theme/theme.scss +12 -0
  10. data/lib/administrate-bootstrap-theme/engine.rb +2 -0
  11. data/lib/administrate-bootstrap-theme/version.rb +1 -1
  12. data/node_modules/bootstrap/js/src/alert.js +141 -0
  13. data/node_modules/bootstrap/js/src/base-component.js +46 -0
  14. data/node_modules/bootstrap/js/src/button.js +95 -0
  15. data/node_modules/bootstrap/js/src/carousel.js +624 -0
  16. data/node_modules/bootstrap/js/src/collapse.js +410 -0
  17. data/node_modules/bootstrap/js/src/dom/data.js +57 -0
  18. data/node_modules/bootstrap/js/src/dom/event-handler.js +331 -0
  19. data/node_modules/bootstrap/js/src/dom/manipulator.js +80 -0
  20. data/node_modules/bootstrap/js/src/dom/selector-engine.js +75 -0
  21. data/node_modules/bootstrap/js/src/dropdown.js +543 -0
  22. data/node_modules/bootstrap/js/src/modal.js +582 -0
  23. data/node_modules/bootstrap/js/src/offcanvas.js +279 -0
  24. data/node_modules/bootstrap/js/src/popover.js +171 -0
  25. data/node_modules/bootstrap/js/src/scrollspy.js +319 -0
  26. data/node_modules/bootstrap/js/src/tab.js +220 -0
  27. data/node_modules/bootstrap/js/src/toast.js +219 -0
  28. data/node_modules/bootstrap/js/src/tooltip.js +802 -0
  29. data/node_modules/bootstrap/js/src/util/index.js +253 -0
  30. data/node_modules/bootstrap/js/src/util/sanitizer.js +127 -0
  31. data/node_modules/bootstrap/js/src/util/scrollbar.js +70 -0
  32. data/node_modules/bootstrap/scss/_accordion.scss +116 -0
  33. data/node_modules/bootstrap/scss/_alert.scss +57 -0
  34. data/node_modules/bootstrap/scss/_badge.scss +29 -0
  35. data/node_modules/bootstrap/scss/_breadcrumb.scss +28 -0
  36. data/node_modules/bootstrap/scss/_button-group.scss +139 -0
  37. data/node_modules/bootstrap/scss/_buttons.scss +111 -0
  38. data/node_modules/bootstrap/scss/_card.scss +215 -0
  39. data/node_modules/bootstrap/scss/_carousel.scss +229 -0
  40. data/node_modules/bootstrap/scss/_close.scss +40 -0
  41. data/node_modules/bootstrap/scss/_containers.scss +41 -0
  42. data/node_modules/bootstrap/scss/_dropdown.scss +246 -0
  43. data/node_modules/bootstrap/scss/_forms.scss +9 -0
  44. data/node_modules/bootstrap/scss/_functions.scss +205 -0
  45. data/node_modules/bootstrap/scss/_grid.scss +22 -0
  46. data/node_modules/bootstrap/scss/_helpers.scss +7 -0
  47. data/node_modules/bootstrap/scss/_images.scss +42 -0
  48. data/node_modules/bootstrap/scss/_list-group.scss +174 -0
  49. data/node_modules/bootstrap/scss/_mixins.scss +41 -0
  50. data/node_modules/bootstrap/scss/_modal.scss +237 -0
  51. data/node_modules/bootstrap/scss/_nav.scss +139 -0
  52. data/node_modules/bootstrap/scss/_navbar.scss +306 -0
  53. data/node_modules/bootstrap/scss/_offcanvas.scss +77 -0
  54. data/node_modules/bootstrap/scss/_pagination.scss +64 -0
  55. data/node_modules/bootstrap/scss/_popover.scss +158 -0
  56. data/node_modules/bootstrap/scss/_progress.scss +48 -0
  57. data/node_modules/bootstrap/scss/_reboot.scss +621 -0
  58. data/node_modules/bootstrap/scss/_root.scss +16 -0
  59. data/node_modules/bootstrap/scss/_spinners.scss +69 -0
  60. data/node_modules/bootstrap/scss/_tables.scss +150 -0
  61. data/node_modules/bootstrap/scss/_toasts.scss +51 -0
  62. data/node_modules/bootstrap/scss/_tooltip.scss +115 -0
  63. data/node_modules/bootstrap/scss/_transitions.scss +21 -0
  64. data/node_modules/bootstrap/scss/_type.scss +104 -0
  65. data/node_modules/bootstrap/scss/_utilities.scss +594 -0
  66. data/node_modules/bootstrap/scss/_variables.scss +1464 -0
  67. data/node_modules/bootstrap/scss/bootstrap-grid.scss +65 -0
  68. data/node_modules/bootstrap/scss/bootstrap-reboot.scss +15 -0
  69. data/node_modules/bootstrap/scss/bootstrap-utilities.scss +18 -0
  70. data/node_modules/bootstrap/scss/bootstrap.scss +52 -0
  71. data/node_modules/bootstrap/scss/forms/_floating-labels.scss +61 -0
  72. data/node_modules/bootstrap/scss/forms/_form-check.scss +152 -0
  73. data/node_modules/bootstrap/scss/forms/_form-control.scss +219 -0
  74. data/node_modules/bootstrap/scss/forms/_form-range.scss +91 -0
  75. data/node_modules/bootstrap/scss/forms/_form-select.scss +67 -0
  76. data/node_modules/bootstrap/scss/forms/_form-text.scss +11 -0
  77. data/node_modules/bootstrap/scss/forms/_input-group.scss +121 -0
  78. data/node_modules/bootstrap/scss/forms/_labels.scss +36 -0
  79. data/node_modules/bootstrap/scss/forms/_validation.scss +12 -0
  80. data/node_modules/bootstrap/scss/helpers/_clearfix.scss +3 -0
  81. data/node_modules/bootstrap/scss/helpers/_colored-links.scss +12 -0
  82. data/node_modules/bootstrap/scss/helpers/_position.scss +30 -0
  83. data/node_modules/bootstrap/scss/helpers/_ratio.scss +26 -0
  84. data/node_modules/bootstrap/scss/helpers/_stretched-link.scss +15 -0
  85. data/node_modules/bootstrap/scss/helpers/_text-truncation.scss +7 -0
  86. data/node_modules/bootstrap/scss/helpers/_visually-hidden.scss +8 -0
  87. data/node_modules/bootstrap/scss/mixins/_alert.scss +11 -0
  88. data/node_modules/bootstrap/scss/mixins/_border-radius.scss +78 -0
  89. data/node_modules/bootstrap/scss/mixins/_box-shadow.scss +18 -0
  90. data/node_modules/bootstrap/scss/mixins/_breakpoints.scss +127 -0
  91. data/node_modules/bootstrap/scss/mixins/_buttons.scss +133 -0
  92. data/node_modules/bootstrap/scss/mixins/_caret.scss +64 -0
  93. data/node_modules/bootstrap/scss/mixins/_clearfix.scss +9 -0
  94. data/node_modules/bootstrap/scss/mixins/_container.scss +9 -0
  95. data/node_modules/bootstrap/scss/mixins/_deprecate.scss +10 -0
  96. data/node_modules/bootstrap/scss/mixins/_forms.scss +134 -0
  97. data/node_modules/bootstrap/scss/mixins/_gradients.scss +47 -0
  98. data/node_modules/bootstrap/scss/mixins/_grid.scss +120 -0
  99. data/node_modules/bootstrap/scss/mixins/_image.scss +16 -0
  100. data/node_modules/bootstrap/scss/mixins/_list-group.scss +24 -0
  101. data/node_modules/bootstrap/scss/mixins/_lists.scss +7 -0
  102. data/node_modules/bootstrap/scss/mixins/_pagination.scss +31 -0
  103. data/node_modules/bootstrap/scss/mixins/_reset-text.scss +17 -0
  104. data/node_modules/bootstrap/scss/mixins/_resize.scss +6 -0
  105. data/node_modules/bootstrap/scss/mixins/_table-variants.scss +21 -0
  106. data/node_modules/bootstrap/scss/mixins/_text-truncate.scss +8 -0
  107. data/node_modules/bootstrap/scss/mixins/_transition.scss +26 -0
  108. data/node_modules/bootstrap/scss/mixins/_utilities.scss +68 -0
  109. data/node_modules/bootstrap/scss/mixins/_visually-hidden.scss +29 -0
  110. data/node_modules/bootstrap/scss/utilities/_api.scss +47 -0
  111. data/node_modules/bootstrap/scss/vendor/_rfs.scss +312 -0
  112. metadata +106 -19
@@ -0,0 +1,41 @@
1
+ // Container widths
2
+ //
3
+ // Set the container width, and override it for fixed navbars in media queries.
4
+
5
+ @if $enable-grid-classes {
6
+ // Single container class with breakpoint max-widths
7
+ .container,
8
+ // 100% wide container at all breakpoints
9
+ .container-fluid {
10
+ @include make-container();
11
+ }
12
+
13
+ // Responsive containers that are 100% wide until a breakpoint
14
+ @each $breakpoint, $container-max-width in $container-max-widths {
15
+ .container-#{$breakpoint} {
16
+ @extend .container-fluid;
17
+ }
18
+
19
+ @include media-breakpoint-up($breakpoint, $grid-breakpoints) {
20
+ %responsive-container-#{$breakpoint} {
21
+ max-width: $container-max-width;
22
+ }
23
+
24
+ // Extend each breakpoint which is smaller or equal to the current breakpoint
25
+ $extend-breakpoint: true;
26
+
27
+ @each $name, $width in $grid-breakpoints {
28
+ @if ($extend-breakpoint) {
29
+ .container#{breakpoint-infix($name, $grid-breakpoints)} {
30
+ @extend %responsive-container-#{$breakpoint};
31
+ }
32
+
33
+ // Once the current breakpoint is reached, stop extending
34
+ @if ($breakpoint == $name) {
35
+ $extend-breakpoint: false;
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,246 @@
1
+ // The dropdown wrapper (`<div>`)
2
+ .dropup,
3
+ .dropend,
4
+ .dropdown,
5
+ .dropstart {
6
+ position: relative;
7
+ }
8
+
9
+ .dropdown-toggle {
10
+ white-space: nowrap;
11
+
12
+ // Generate the caret automatically
13
+ @include caret();
14
+ }
15
+
16
+ // The dropdown menu
17
+ .dropdown-menu {
18
+ position: absolute;
19
+ top: 100%;
20
+ z-index: $zindex-dropdown;
21
+ display: none; // none by default, but block on "open" of the menu
22
+ min-width: $dropdown-min-width;
23
+ padding: $dropdown-padding-y $dropdown-padding-x;
24
+ margin: 0; // Override default margin of ul
25
+ @include font-size($dropdown-font-size);
26
+ color: $dropdown-color;
27
+ text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
28
+ list-style: none;
29
+ background-color: $dropdown-bg;
30
+ background-clip: padding-box;
31
+ border: $dropdown-border-width solid $dropdown-border-color;
32
+ @include border-radius($dropdown-border-radius);
33
+ @include box-shadow($dropdown-box-shadow);
34
+
35
+ &[data-bs-popper] {
36
+ left: 0;
37
+ margin-top: $dropdown-spacer;
38
+ }
39
+ }
40
+
41
+ // scss-docs-start responsive-breakpoints
42
+ // We deliberately hardcode the `bs-` prefix because we check
43
+ // this custom property in JS to determine Popper's positioning
44
+
45
+ @each $breakpoint in map-keys($grid-breakpoints) {
46
+ @include media-breakpoint-up($breakpoint) {
47
+ $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
48
+
49
+ .dropdown-menu#{$infix}-start {
50
+ --bs-position: start;
51
+
52
+ &[data-bs-popper] {
53
+ right: auto #{"/* rtl:ignore */"};
54
+ left: 0 #{"/* rtl:ignore */"};
55
+ }
56
+ }
57
+
58
+ .dropdown-menu#{$infix}-end {
59
+ --bs-position: end;
60
+
61
+ &[data-bs-popper] {
62
+ right: 0 #{"/* rtl:ignore */"};
63
+ left: auto #{"/* rtl:ignore */"};
64
+ }
65
+ }
66
+ }
67
+ }
68
+ // scss-docs-end responsive-breakpoints
69
+
70
+ // Allow for dropdowns to go bottom up (aka, dropup-menu)
71
+ // Just add .dropup after the standard .dropdown class and you're set.
72
+ .dropup {
73
+ .dropdown-menu[data-bs-popper] {
74
+ top: auto;
75
+ bottom: 100%;
76
+ margin-top: 0;
77
+ margin-bottom: $dropdown-spacer;
78
+ }
79
+
80
+ .dropdown-toggle {
81
+ @include caret(up);
82
+ }
83
+ }
84
+
85
+ .dropend {
86
+ .dropdown-menu {
87
+ top: 0;
88
+ right: auto;
89
+ left: 100%;
90
+
91
+ &[data-bs-popper] {
92
+ margin-top: 0;
93
+ margin-left: $dropdown-spacer;
94
+ }
95
+ }
96
+
97
+ .dropdown-toggle {
98
+ @include caret(end);
99
+ &::after {
100
+ vertical-align: 0;
101
+ }
102
+ }
103
+ }
104
+
105
+ .dropstart {
106
+ .dropdown-menu {
107
+ top: 0;
108
+ right: 100%;
109
+ left: auto;
110
+
111
+ &[data-bs-popper] {
112
+ margin-top: 0;
113
+ margin-right: $dropdown-spacer;
114
+ }
115
+ }
116
+
117
+ .dropdown-toggle {
118
+ @include caret(start);
119
+ &::before {
120
+ vertical-align: 0;
121
+ }
122
+ }
123
+ }
124
+
125
+
126
+ // Dividers (basically an `<hr>`) within the dropdown
127
+ .dropdown-divider {
128
+ height: 0;
129
+ margin: $dropdown-divider-margin-y 0;
130
+ overflow: hidden;
131
+ border-top: 1px solid $dropdown-divider-bg;
132
+ }
133
+
134
+ // Links, buttons, and more within the dropdown menu
135
+ //
136
+ // `<button>`-specific styles are denoted with `// For <button>s`
137
+ .dropdown-item {
138
+ display: block;
139
+ width: 100%; // For `<button>`s
140
+ padding: $dropdown-item-padding-y $dropdown-item-padding-x;
141
+ clear: both;
142
+ font-weight: $font-weight-normal;
143
+ color: $dropdown-link-color;
144
+ text-align: inherit; // For `<button>`s
145
+ text-decoration: if($link-decoration == none, null, none);
146
+ white-space: nowrap; // prevent links from randomly breaking onto new lines
147
+ background-color: transparent; // For `<button>`s
148
+ border: 0; // For `<button>`s
149
+
150
+ // Prevent dropdown overflow if there's no padding
151
+ // See https://github.com/twbs/bootstrap/pull/27703
152
+ @if $dropdown-padding-y == 0 {
153
+ &:first-child {
154
+ @include border-top-radius($dropdown-inner-border-radius);
155
+ }
156
+
157
+ &:last-child {
158
+ @include border-bottom-radius($dropdown-inner-border-radius);
159
+ }
160
+ }
161
+
162
+ &:hover,
163
+ &:focus {
164
+ color: $dropdown-link-hover-color;
165
+ text-decoration: if($link-hover-decoration == underline, none, null);
166
+ @include gradient-bg($dropdown-link-hover-bg);
167
+ }
168
+
169
+ &.active,
170
+ &:active {
171
+ color: $dropdown-link-active-color;
172
+ text-decoration: none;
173
+ @include gradient-bg($dropdown-link-active-bg);
174
+ }
175
+
176
+ &.disabled,
177
+ &:disabled {
178
+ color: $dropdown-link-disabled-color;
179
+ pointer-events: none;
180
+ background-color: transparent;
181
+ // Remove CSS gradients if they're enabled
182
+ background-image: if($enable-gradients, none, null);
183
+ }
184
+ }
185
+
186
+ .dropdown-menu.show {
187
+ display: block;
188
+ }
189
+
190
+ // Dropdown section headers
191
+ .dropdown-header {
192
+ display: block;
193
+ padding: $dropdown-header-padding;
194
+ margin-bottom: 0; // for use with heading elements
195
+ @include font-size($font-size-sm);
196
+ color: $dropdown-header-color;
197
+ white-space: nowrap; // as with > li > a
198
+ }
199
+
200
+ // Dropdown text
201
+ .dropdown-item-text {
202
+ display: block;
203
+ padding: $dropdown-item-padding-y $dropdown-item-padding-x;
204
+ color: $dropdown-link-color;
205
+ }
206
+
207
+ // Dark dropdowns
208
+ .dropdown-menu-dark {
209
+ color: $dropdown-dark-color;
210
+ background-color: $dropdown-dark-bg;
211
+ border-color: $dropdown-dark-border-color;
212
+ @include box-shadow($dropdown-dark-box-shadow);
213
+
214
+ .dropdown-item {
215
+ color: $dropdown-dark-link-color;
216
+
217
+ &:hover,
218
+ &:focus {
219
+ color: $dropdown-dark-link-hover-color;
220
+ @include gradient-bg($dropdown-dark-link-hover-bg);
221
+ }
222
+
223
+ &.active,
224
+ &:active {
225
+ color: $dropdown-dark-link-active-color;
226
+ @include gradient-bg($dropdown-dark-link-active-bg);
227
+ }
228
+
229
+ &.disabled,
230
+ &:disabled {
231
+ color: $dropdown-dark-link-disabled-color;
232
+ }
233
+ }
234
+
235
+ .dropdown-divider {
236
+ border-color: $dropdown-dark-divider-bg;
237
+ }
238
+
239
+ .dropdown-item-text {
240
+ color: $dropdown-dark-link-color;
241
+ }
242
+
243
+ .dropdown-header {
244
+ color: $dropdown-dark-header-color;
245
+ }
246
+ }
@@ -0,0 +1,9 @@
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";
@@ -0,0 +1,205 @@
1
+ // Bootstrap functions
2
+ //
3
+ // Utility mixins and functions for evaluating source code across our variables, maps, and mixins.
4
+
5
+ // Ascending
6
+ // Used to evaluate Sass maps like our grid breakpoints.
7
+ @mixin _assert-ascending($map, $map-name) {
8
+ $prev-key: null;
9
+ $prev-num: null;
10
+ @each $key, $num in $map {
11
+ @if $prev-num == null or unit($num) == "%" or unit($prev-num) == "%" {
12
+ // Do nothing
13
+ } @else if not comparable($prev-num, $num) {
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}' !";
15
+ } @else if $prev-num >= $num {
16
+ @warn "Invalid value for #{$map-name}: This map must be in ascending order, but key '#{$key}' has value #{$num} which isn't greater than #{$prev-num}, the value of the previous key '#{$prev-key}' !";
17
+ }
18
+ $prev-key: $key;
19
+ $prev-num: $num;
20
+ }
21
+ }
22
+
23
+ // Starts at zero
24
+ // Used to ensure the min-width of the lowest breakpoint starts at 0.
25
+ @mixin _assert-starts-at-zero($map, $map-name: "$grid-breakpoints") {
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
+ }
54
+ }
55
+ @return $result;
56
+ }
57
+
58
+ // Replace `$search` with `$replace` in `$string`
59
+ // Used on our SVG icon backgrounds for custom forms.
60
+ //
61
+ // @author Hugo Giraudel
62
+ // @param {String} $string - Initial string
63
+ // @param {String} $search - Substring to replace
64
+ // @param {String} $replace ('') - New value
65
+ // @return {String} - Updated string
66
+ @function str-replace($string, $search, $replace: "") {
67
+ $index: str-index($string, $search);
68
+
69
+ @if $index {
70
+ @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
71
+ }
72
+
73
+ @return $string;
74
+ }
75
+
76
+ // See https://codepen.io/kevinweber/pen/dXWoRw
77
+ //
78
+ // Requires the use of quotes around data URIs.
79
+
80
+ @function escape-svg($string) {
81
+ @if str-index($string, "data:image/svg+xml") {
82
+ @each $char, $encoded in $escaped-characters {
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
+ }
89
+ }
90
+ }
91
+
92
+ @return $string;
93
+ }
94
+
95
+ // Color contrast
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
+ }
116
+
117
+ @warn "Found no color leading to #{$min-contrast-ratio}:1 contrast ratio against #{$background}...";
118
+
119
+ @return $max-ratio-color;
120
+ }
121
+
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));
127
+ }
128
+
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);
145
+ }
146
+
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);
151
+ }
152
+
153
+ // scss-docs-start color-functions
154
+ // Tint a color: mix a color with white
155
+ @function tint-color($color, $weight) {
156
+ @return mix(white, $color, $weight);
157
+ }
158
+
159
+ // Shade a color: mix a color with black
160
+ @function shade-color($color, $weight) {
161
+ @return mix(black, $color, $weight);
162
+ }
163
+
164
+ // Shade the color if the weight is positive, else tint it
165
+ @function shift-color($color, $weight) {
166
+ @return if($weight > 0, shade-color($color, $weight), tint-color($color, -$weight));
167
+ }
168
+ // scss-docs-end color-functions
169
+
170
+ // Return valid calc
171
+ @function add($value1, $value2, $return-calc: true) {
172
+ @if $value1 == null {
173
+ @return $value2;
174
+ }
175
+
176
+ @if $value2 == null {
177
+ @return $value1;
178
+ }
179
+
180
+ @if type-of($value1) == number and type-of($value2) == number and comparable($value1, $value2) {
181
+ @return $value1 + $value2;
182
+ }
183
+
184
+ @return if($return-calc == true, calc(#{$value1} + #{$value2}), $value1 + unquote(" + ") + $value2);
185
+ }
186
+
187
+ @function subtract($value1, $value2, $return-calc: true) {
188
+ @if $value1 == null and $value2 == null {
189
+ @return null;
190
+ }
191
+
192
+ @if $value1 == null {
193
+ @return -$value2;
194
+ }
195
+
196
+ @if $value2 == null {
197
+ @return $value1;
198
+ }
199
+
200
+ @if type-of($value1) == number and type-of($value2) == number and comparable($value1, $value2) {
201
+ @return $value1 - $value2;
202
+ }
203
+
204
+ @return if($return-calc == true, calc(#{$value1} - #{$value2}), $value1 + unquote(" - ") + $value2);
205
+ }