22//
33// Utility mixins and functions for evaluating source code across our variables, maps, and mixins.
44
5+ @use ' sass:meta' ;
6+ @use ' sass:color' ;
7+ @use ' sass:math' ;
8+
59// Ascending
610// Used to evaluate Sass maps like our grid breakpoints.
711@mixin _assert-ascending ($map , $map-name ) {
3438
3539// Colors
3640@function to-rgb ($value ) {
37- @return red ($value ), green ($value ), blue ($value );
41+ @return color . channel ($value , ' red ' , $space : rgb ), color . channel ($value , ' green ' , $space : rgb ), color . channel ($value , ' blue ' , $space : rgb );
3842}
3943
4044// stylelint-disable scss/dollar-variable-pattern
@@ -209,9 +213,9 @@ $_luminance-list: 0.0008 0.001 0.0011 0.0013 0.0015 0.0017 0.002 0.0022 0.0025 0
209213// See https://www.w3.org/TR/WCAG/#dfn-contrast-ratio
210214@function luminance ($color ) {
211215 $rgb : (
212- ' r' : red ( $color ),
213- ' g' : green ( $color ),
214- ' b' : blue ( $color ),
216+ ' r' : math . round ( color . channel ( $color , ' red ' , $space : rgb ) ),
217+ ' g' : math . round ( color . channel ( $color , ' green ' , $space : rgb ) ),
218+ ' b' : math . round ( color . channel ( $color , ' blue ' , $space : rgb ) ),
215219 );
216220
217221 @each $name , $value in $rgb {
@@ -230,18 +234,18 @@ $_luminance-list: 0.0008 0.001 0.0011 0.0013 0.0015 0.0017 0.002 0.0022 0.0025 0
230234// Return opaque color
231235// opaque(#fff, rgba(0, 0, 0, .5)) => #808080
232236@function opaque ($background , $foreground ) {
233- @return mix (rgba ($foreground , 1 ), $background , opacity ($foreground ) * 100% );
237+ @return color . mix (rgba ($foreground , 1 ), $background , opacity ($foreground ) * 100% );
234238}
235239
236240// scss-docs-start color-functions
237241// Tint a color: mix a color with white
238242@function tint-color ($color , $weight ) {
239- @return mix (white , $color , $weight );
243+ @return color . mix (white , $color , $weight );
240244}
241245
242246// Shade a color: mix a color with black
243247@function shade-color ($color , $weight ) {
244- @return mix (black , $color , $weight );
248+ @return color . mix (black , $color , $weight );
245249}
246250
247251// Shade the color if the weight is positive, else tint it
@@ -260,7 +264,7 @@ $_luminance-list: 0.0008 0.001 0.0011 0.0013 0.0015 0.0017 0.002 0.0022 0.0025 0
260264 @return $value1 ;
261265 }
262266
263- @if type-of ($value1 ) == number and type-of ($value2 ) == number and comparable ($value1 , $value2 ) {
267+ @if meta . type-of ($value1 ) == number and meta . type-of ($value2 ) == number and math . compatible ($value1 , $value2 ) {
264268 @return $value1 + $value2 ;
265269 }
266270
@@ -280,11 +284,11 @@ $_luminance-list: 0.0008 0.001 0.0011 0.0013 0.0015 0.0017 0.002 0.0022 0.0025 0
280284 @return $value1 ;
281285 }
282286
283- @if type-of ($value1 ) == number and type-of ($value2 ) == number and comparable ($value1 , $value2 ) {
287+ @if meta . type-of ($value1 ) == number and meta . type-of ($value2 ) == number and math . compatible ($value1 , $value2 ) {
284288 @return $value1 - $value2 ;
285289 }
286290
287- @if type-of ($value2 ) != number {
291+ @if meta . type-of ($value2 ) != number {
288292 $value2 : unquote (' (' ) + $value2 + unquote (' )' );
289293 }
290294
0 commit comments