]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Replace `green()`, `red()`, and `blue()` by `color.channel`
authorJulien Déramond <juderamond@gmail.com>
Thu, 19 Dec 2024 09:25:21 +0000 (10:25 +0100)
committerJulien Déramond <juderamond@gmail.com>
Tue, 15 Apr 2025 19:52:11 +0000 (21:52 +0200)
scss/_functions.scss
scss/tests/mixins/_color-modes.test.scss
scss/tests/sass-true/runner.js

index e04b5c61b39f7ae55145cbea0974d784e33e4851..eda2f2f04b039f84542683b7b47c9a1e6c774d9c 100644 (file)
@@ -1,3 +1,6 @@
+@use "sass:color";
+@use "sass:math";
+
 // Bootstrap functions
 //
 // Utility mixins and functions for evaluating source code across our variables, maps, and mixins.
@@ -34,7 +37,7 @@
 
 // Colors
 @function to-rgb($value) {
-  @return red($value), green($value), blue($value);
+  @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));
 }
 
 // stylelint-disable scss/dollar-variable-pattern
@@ -182,9 +185,9 @@ $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003
 // See https://www.w3.org/TR/WCAG/#dfn-contrast-ratio
 @function luminance($color) {
   $rgb: (
-    "r": red($color),
-    "g": green($color),
-    "b": blue($color)
+    "r": math.round(color.channel($color, "red", $space: rgb)), // stylelint-disable-line scss/at-function-named-arguments
+    "g": math.round(color.channel($color, "green", $space: rgb)), // stylelint-disable-line scss/at-function-named-arguments
+    "b": math.round(color.channel($color, "blue", $space: rgb)) // stylelint-disable-line scss/at-function-named-arguments
   );
 
   @each $name, $value in $rgb {
index 9ecc628deabe78e69dbd78d1babdadafa7101de9..eb604cc15e9c2661ae7be5aabfd9058111af551c 100644 (file)
@@ -17,7 +17,7 @@
           }
         }
         @include color-mode(dark, true) {
-          --custom-color: #{mix($indigo, $blue, 50%)};
+          --custom-color: #{$indigo};
         }
       }
       @include expect() {
@@ -26,7 +26,7 @@
           background-color: var(--bs-primary-bg-subtle);
         }
         [data-bs-theme=dark] {
-          --custom-color: #3a3ff8;
+          --custom-color: #6610f2;
         }
       }
     }
@@ -46,7 +46,7 @@
           }
         }
         @include color-mode(dark, true) {
-          --custom-color: #{mix($indigo, $blue, 50%)};
+          --custom-color: #{$indigo}
         }
       }
       @include expect() {
@@ -58,7 +58,7 @@
         }
         @media (prefers-color-scheme: dark) {
           :root {
-            --custom-color: #3a3ff8;
+            --custom-color: #6610f2;
           }
         }
       }
index bef870ac6b1383450a178428c59432026b9db940..edf9ac43043aaef4057e4dece72c24e46165b998 100644 (file)
@@ -6,7 +6,7 @@ const { runSass } = require('sass-true')
 
 module.exports = (filename, { describe, it }) => {
   const data = fs.readFileSync(filename, 'utf8')
-  const TRUE_SETUP = '$true-terminal-output: false; @import "true";'
+  const TRUE_SETUP = '$true-terminal-output: false; @use "true" as *;'
   const sassString = TRUE_SETUP + data
 
   runSass(