Skip to content

Commit 78b0615

Browse files
committed
Fix for color function compatibility with older versions of sass
1 parent 8475144 commit 78b0615

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/utils/color.scss

+18-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
/// @param {*} $as-float [false] If true, return the value as a float between 0 and 1
1313

1414
@function rgb-red($color, $as-float: false) {
15-
$v: color.channel($color, 'red', $space: rgb);
15+
$v: null;
16+
@if (function-exists('color.channel')) {
17+
$v: color.channel($color, 'red', $space: rgb);
18+
} @else {
19+
$v: color.red($color);
20+
}
1621
@return if($as-float, divide($v, 255), $v);
1722
}
1823

@@ -21,7 +26,12 @@
2126
/// @param {*} $as-float [false] If true, return the value as a float between 0 and 1
2227

2328
@function rgb-green($color, $as-float: false) {
24-
$v: color.channel($color, 'green', $space: rgb);
29+
$v: null;
30+
@if (function-exists('color.channel')) {
31+
$v: color.channel($color, 'green', $space: rgb);
32+
} @else {
33+
$v: color.green($color);
34+
}
2535
@return if($as-float, divide($v, 255), $v);
2636
}
2737

@@ -30,7 +40,12 @@
3040
/// @param {*} $as-float [false] If true, return the value as a float between 0 and 1
3141

3242
@function rgb-blue($color, $as-float: false) {
33-
$v: color.channel($color, 'blue', $space: rgb);
43+
$v: null;
44+
@if (function-exists('color.channel')) {
45+
$v: color.channel($color, 'blue', $space: rgb);
46+
} @else {
47+
$v: color.blue($color);
48+
}
3449
@return if($as-float, divide($v, 255), $v);
3550
}
3651

0 commit comments

Comments
 (0)