| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 1 | @use "sass:math"; |
| 2 | |
| Yoshie Muranaka | 1f4eaa1 | 2020-08-10 11:17:12 -0700 | [diff] [blame] | 3 | // This function is usually used to get a lighter |
| 4 | // theme variant color to use as a background color |
| 5 | @function theme-color-light($variant) { |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 6 | @return shift-color(map-get($theme-colors, $variant), -90.4%); |
| Sukanya Pandey | fde429e | 2020-09-14 20:48:39 +0530 | [diff] [blame] | 7 | } |
| 8 | |
| 9 | @function theme-color-dark($variant) { |
| jason westover | d36ac8a | 2025-11-03 20:58:59 -0600 | [diff] [blame^] | 10 | @return shift-color(map-get($theme-colors, $variant), 16%); |
| 11 | } |
| 12 | |
| 13 | // Bootstrap 5 no longer provides theme-color(); define a compatible helper |
| 14 | @function theme-color($variant) { |
| 15 | @return map-get($theme-colors, $variant); |
| 16 | } |
| 17 | |
| 18 | // Bootstrap 4 compatibility: theme-color-level() function |
| 19 | // Positive levels darken (mix with black), negative levels lighten (mix with white) |
| 20 | // Each level is 8% change, matching Bootstrap 4 behavior |
| 21 | @function theme-color-level($variant, $level: 0) { |
| 22 | $color: map-get($theme-colors, $variant); |
| 23 | $weight: $level * 8%; |
| 24 | |
| 25 | @if $level > 0 { |
| 26 | @return shade-color($color, $weight); |
| 27 | } @else if $level < 0 { |
| 28 | @return tint-color($color, math.abs($weight)); |
| 29 | } @else { |
| 30 | @return $color; |
| 31 | } |
| Yoshie Muranaka | 1f4eaa1 | 2020-08-10 11:17:12 -0700 | [diff] [blame] | 32 | } |