Skip to content

Commit f232df5

Browse files
Replace green(), red(), and blue() by color.channel
1 parent 0e48a45 commit f232df5

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

scss/_functions.scss

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
@use "sass:color";
2+
@use "sass:math";
3+
14
// Bootstrap functions
25
//
36
// Utility mixins and functions for evaluating source code across our variables, maps, and mixins.
@@ -34,7 +37,7 @@
3437

3538
// Colors
3639
@function to-rgb($value) {
37-
@return red($value), green($value), blue($value);
40+
@return math.round(color.channel($value, "red", $space: rgb)), math.round(color.channel($value, "green", $space: rgb)), math.round(color.channel($value, "blue", $space: rgb));
3841
}
3942

4043
// stylelint-disable scss/dollar-variable-pattern
@@ -182,9 +185,9 @@ $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003
182185
// See https://www.w3.org/TR/WCAG/#dfn-contrast-ratio
183186
@function luminance($color) {
184187
$rgb: (
185-
"r": red($color),
186-
"g": green($color),
187-
"b": blue($color)
188+
"r": math.round(color.channel($color, "red", $space: rgb)), // stylelint-disable-line scss/at-function-named-arguments
189+
"g": math.round(color.channel($color, "green", $space: rgb)), // stylelint-disable-line scss/at-function-named-arguments
190+
"b": math.round(color.channel($color, "blue", $space: rgb)) // stylelint-disable-line scss/at-function-named-arguments
188191
);
189192

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

scss/tests/mixins/_color-modes.test.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818
}
1919
@include color-mode(dark, true) {
20-
--custom-color: #{mix($indigo, $blue, 50%)};
20+
--custom-color: #{$indigo};
2121
}
2222
}
2323
@include expect() {
@@ -26,7 +26,7 @@
2626
background-color: var(--bs-primary-bg-subtle);
2727
}
2828
[data-bs-theme=dark] {
29-
--custom-color: #3a3ff8;
29+
--custom-color: #6610f2;
3030
}
3131
}
3232
}
@@ -46,7 +46,7 @@
4646
}
4747
}
4848
@include color-mode(dark, true) {
49-
--custom-color: #{mix($indigo, $blue, 50%)};
49+
--custom-color: #{$indigo}
5050
}
5151
}
5252
@include expect() {
@@ -58,7 +58,7 @@
5858
}
5959
@media (prefers-color-scheme: dark) {
6060
:root {
61-
--custom-color: #3a3ff8;
61+
--custom-color: #6610f2;
6262
}
6363
}
6464
}

scss/tests/sass-true/runner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { runSass } = require('sass-true')
66

77
module.exports = (filename, { describe, it }) => {
88
const data = fs.readFileSync(filename, 'utf8')
9-
const TRUE_SETUP = '$true-terminal-output: false; @import "true";'
9+
const TRUE_SETUP = '$true-terminal-output: false; @use "true" as *;'
1010
const sassString = TRUE_SETUP + data
1111

1212
runSass(

0 commit comments

Comments
 (0)