Skip to content

Commit b22f08f

Browse files
committed
Compatibility with SASS version 2.
Fixing deprecation warnings for usage of red, green and blue functions and using color.channel instead. Fixes: twbs#40849
1 parent 523493d commit b22f08f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
"rollup": "^4.21.2",
149149
"rollup-plugin-istanbul": "^5.0.0",
150150
"rtlcss": "^4.3.0",
151-
"sass": "^1.77.8",
151+
"sass": "^1.79.3",
152152
"sass-true": "^8.0.0",
153153
"shelljs": "^0.8.5",
154154
"stylelint": "^16.8.1",

scss/_functions.scss

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
//
33
// Utility mixins and functions for evaluating source code across our variables, maps, and mixins.
44

5+
@use "sass:color";
6+
@use "sass:math";
7+
58
// Ascending
69
// Used to evaluate Sass maps like our grid breakpoints.
710
@mixin _assert-ascending($map, $map-name) {
@@ -34,7 +37,12 @@
3437

3538
// Colors
3639
@function to-rgb($value) {
37-
@return red($value), green($value), blue($value);
40+
$red: math.round(color.channel($value, "red", rgb));
41+
$green: math.round(color.channel($value, "green", rgb));
42+
$blue: math.round(color.channel($value, "blue", rgb));
43+
44+
@return $red, $green, $blue;
45+
3846
}
3947

4048
// stylelint-disable scss/dollar-variable-pattern
@@ -182,9 +190,9 @@ $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003
182190
// See https://www.w3.org/TR/WCAG/#dfn-contrast-ratio
183191
@function luminance($color) {
184192
$rgb: (
185-
"r": red($color),
186-
"g": green($color),
187-
"b": blue($color)
193+
"r": math.round(color.channel($color, "red", rgb)),
194+
"g": math.round(color.channel($color, "green", rgb)),
195+
"b": math.round(color.channel($color, "blue", rgb))
188196
);
189197

190198
@each $name, $value in $rgb {

0 commit comments

Comments
 (0)