@@ -30,11 +30,12 @@ const _specialCommaSpaces = {ColorSpace.rgb, ColorSpace.hsl};
3030/// The global definitions of Sass color functions.
3131final global = UnmodifiableListView ([
3232 // ### RGB
33- _channelFunction ("red" , (color) => color.red, global: true )
33+ _channelFunction ("red" , ColorSpace .rgb, (color) => color.red, global: true )
3434 .withDeprecationWarning ("color" ),
35- _channelFunction ("green" , (color) => color.green, global: true )
35+ _channelFunction ("green" , ColorSpace .rgb, (color) => color.green,
36+ global: true )
3637 .withDeprecationWarning ("color" ),
37- _channelFunction ("blue" , (color) => color.blue, global: true )
38+ _channelFunction ("blue" , ColorSpace .rgb, (color) => color.blue, global: true )
3839 .withDeprecationWarning ("color" ),
3940 _mix.withDeprecationWarning ("color" ),
4041
@@ -59,12 +60,13 @@ final global = UnmodifiableListView([
5960 .withDeprecationWarning ("color" ),
6061
6162 // ### HSL
62- _channelFunction ("hue" , (color) => color.hue, unit: 'deg' , global: true )
63+ _channelFunction ("hue" , ColorSpace .hsl, (color) => color.hue,
64+ unit: 'deg' , global: true )
6365 .withDeprecationWarning ("color" ),
64- _channelFunction ("saturation" , (color) => color.saturation,
66+ _channelFunction ("saturation" , ColorSpace .hsl, (color) => color.saturation,
6567 unit: '%' , global: true )
6668 .withDeprecationWarning ("color" ),
67- _channelFunction ("lightness" , (color) => color.lightness,
69+ _channelFunction ("lightness" , ColorSpace .hsl, (color) => color.lightness,
6870 unit: '%' , global: true )
6971 .withDeprecationWarning ("color" ),
7072
@@ -346,9 +348,9 @@ final global = UnmodifiableListView([
346348/// The Sass color module.
347349final module = BuiltInModule ("color" , functions: < Callable > [
348350 // ### RGB
349- _channelFunction ("red" , (color) => color.red),
350- _channelFunction ("green" , (color) => color.green),
351- _channelFunction ("blue" , (color) => color.blue),
351+ _channelFunction ("red" , ColorSpace .rgb, (color) => color.red),
352+ _channelFunction ("green" , ColorSpace .rgb, (color) => color.green),
353+ _channelFunction ("blue" , ColorSpace .rgb, (color) => color.blue),
352354 _mix,
353355
354356 _function ("invert" , r"$color, $weight: 100%, $space: null" , (arguments) {
@@ -365,9 +367,11 @@ final module = BuiltInModule("color", functions: <Callable>[
365367 }),
366368
367369 // ### HSL
368- _channelFunction ("hue" , (color) => color.hue, unit: 'deg' ),
369- _channelFunction ("saturation" , (color) => color.saturation, unit: '%' ),
370- _channelFunction ("lightness" , (color) => color.lightness, unit: '%' ),
370+ _channelFunction ("hue" , ColorSpace .hsl, (color) => color.hue, unit: 'deg' ),
371+ _channelFunction ("saturation" , ColorSpace .hsl, (color) => color.saturation,
372+ unit: '%' ),
373+ _channelFunction ("lightness" , ColorSpace .hsl, (color) => color.lightness,
374+ unit: '%' ),
371375 _removedColorFunction ("adjust-hue" , "hue" ),
372376 _removedColorFunction ("lighten" , "lightness" ),
373377 _removedColorFunction ("darken" , "lightness" , negative: true ),
@@ -403,8 +407,10 @@ final module = BuiltInModule("color", functions: <Callable>[
403407 space: ColorSpace .hwb, name: 'channels' )
404408 }),
405409
406- _channelFunction ("whiteness" , (color) => color.whiteness, unit: '%' ),
407- _channelFunction ("blackness" , (color) => color.blackness, unit: '%' ),
410+ _channelFunction ("whiteness" , ColorSpace .hwb, (color) => color.whiteness,
411+ unit: '%' ),
412+ _channelFunction ("blackness" , ColorSpace .hwb, (color) => color.blackness,
413+ unit: '%' ),
408414
409415 // ### Opacity
410416 _removedColorFunction ("opacify" , "alpha" ),
@@ -1593,15 +1599,15 @@ bool _isNone(Value value) =>
15931599/// If [unit] is passed, the channel is returned with that unit. The [global]
15941600/// parameter indicates whether this was called using the legacy global syntax.
15951601BuiltInCallable _channelFunction (
1596- String name, num Function (SassColor color) getter,
1602+ String name, ColorSpace space, num Function (SassColor color) getter,
15971603 {String ? unit, bool global = false }) {
15981604 return _function (name, r"$color" , (arguments) {
15991605 var result = SassNumber (getter (arguments.first.assertColor ("color" )), unit);
16001606
16011607 warnForDeprecation (
16021608 "${global ? '' : 'color.' }$name () is deprecated. Suggestion:\n "
16031609 "\n "
1604- 'color.channel(\$ color, $name )\n '
1610+ 'color.channel(\$ color, $name , \$ space: $ space )\n '
16051611 "\n "
16061612 "More info: https://sass-lang.com/d/color-functions" ,
16071613 Deprecation .colorFunctions);
0 commit comments