|
2 | 2 | * Miscellaneous color functions and mixins |
3 | 3 | **/ |
4 | 4 |
|
5 | | -// loading the math module |
| 5 | +@use "sass:list"; |
| 6 | +@use "sass:map"; |
| 7 | +@use "sass:meta"; |
6 | 8 | @use "sass:math"; |
| 9 | +@use "sass:string"; |
7 | 10 |
|
8 | 11 | // We must add ::before pseudo-element to some theme components (such as admonitions) |
9 | 12 | // because users were instructed to customize the background color this way. |
10 | 13 | @mixin legacy-backdrop-placeholder { |
11 | | - &:before { |
| 14 | + &::before { |
12 | 15 | content: ""; |
13 | 16 | width: 100%; |
14 | 17 | height: 100%; |
15 | 18 | position: absolute; |
16 | 19 | left: 0; |
17 | 20 | top: 0; |
18 | 21 | z-index: -1; |
| 22 | + |
19 | 23 | // So that hovering over the text within background is still possible. |
20 | 24 | // Otherwise the background overlays the text and you cannot click or select easily. |
21 | 25 | // ref: https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events |
|
31 | 35 | // @return {*} |
32 | 36 | @function map-deep-get($map, $keys...) { |
33 | 37 | @each $key in $keys { |
34 | | - $map: map-get($map, $key); |
| 38 | + $map: map.get($map, $key); |
35 | 39 | } |
| 40 | + |
36 | 41 | @return $map; |
37 | 42 | } |
38 | 43 |
|
|
44 | 49 | // @param {String/Color} $color - Color definition from map |
45 | 50 | // @return {Color} - Color type (in hex) |
46 | 51 | @function check-color($color) { |
47 | | - @if type-of($color) == string { |
| 52 | + @if meta.type-of($color) == string { |
48 | 53 | $color: from-hex($color); |
49 | 54 | } |
| 55 | + |
50 | 56 | @return $color; |
51 | 57 | } |
52 | 58 |
|
|
55 | 61 | */ |
56 | 62 | // @param {String} $string - String representation of a color |
57 | 63 | @function from-hex($string) { |
58 | | - $string-lower: to-lower-case($string); |
| 64 | + $string-lower: string.to-lower-case($string); |
59 | 65 | $r: ""; |
60 | 66 | $g: ""; |
61 | 67 | $b: ""; |
62 | 68 | $hex: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f"; |
63 | | - $length: str-length($string); |
| 69 | + $length: string.length($string); |
64 | 70 | $max: if($length == 4, 1, 2); |
65 | 71 |
|
66 | 72 | // Check for length accuracy |
|
70 | 76 |
|
71 | 77 | // Loop from the second character (omitting #) |
72 | 78 | @for $i from 2 through $length { |
73 | | - $c: str-slice($string-lower, $i, $i); |
| 79 | + $c: string.slice($string-lower, $i, $i); |
74 | 80 |
|
75 | 81 | // If wrong character, return |
76 | | - @if index($hex, $c) == null { |
| 82 | + @if not list.index($hex, $c) { |
77 | 83 | @return $string; |
78 | 84 | } |
79 | 85 |
|
80 | | - @if str-length($r) < $max { |
| 86 | + @if string.length($r) < $max { |
81 | 87 | $r: $r + $c; |
82 | | - } @else if str-length($g) < $max { |
| 88 | + } @else if string.length($g) < $max { |
83 | 89 | $g: $g + $c; |
84 | | - } @else if str-length($b) < $max { |
| 90 | + } @else if string.length($b) < $max { |
85 | 91 | $b: $b + $c; |
86 | 92 | } |
87 | 93 | } |
|
92 | 98 | $b: $b + $b; |
93 | 99 | } |
94 | 100 |
|
95 | | - @return rgb(_hex-to-dec($r), _hex-to-dec($g), _hex-to-dec($b)); |
| 101 | + @return rgb(hex-to-dec($r), hex-to-dec($g), hex-to-dec($b)); |
96 | 102 | } |
97 | 103 |
|
98 | | -@function _hex-to-dec($string) { |
| 104 | +@function hex-to-dec($string) { |
99 | 105 | $hex: "0" "1" "2" "3" "4" "5" "6" "7" "8" "9" "a" "b" "c" "d" "e" "f"; |
100 | | - $string: to-lower-case($string); |
101 | | - $length: str-length($string); |
102 | | - |
| 106 | + $string: string.to-lower-case($string); |
| 107 | + $length: string.length($string); |
103 | 108 | $dec: 0; |
| 109 | + |
104 | 110 | @for $i from 1 through $length { |
105 | 111 | $factor: 1 + (15 * ($length - $i)); |
106 | | - $index: index($hex, str-slice($string, $i, $i)); |
| 112 | + $index: list.index($hex, string.slice($string, $i, $i)); |
107 | 113 | $dec: $dec + $factor * ($index - 1); |
108 | 114 | } |
109 | 115 |
|
|
0 commit comments