@@ -30,11 +30,12 @@ const _specialCommaSpaces = {ColorSpace.rgb, ColorSpace.hsl};
30
30
/// The global definitions of Sass color functions.
31
31
final global = UnmodifiableListView ([
32
32
// ### RGB
33
- _channelFunction ("red" , (color) => color.red, global: true )
33
+ _channelFunction ("red" , ColorSpace .rgb, (color) => color.red, global: true )
34
34
.withDeprecationWarning ("color" ),
35
- _channelFunction ("green" , (color) => color.green, global: true )
35
+ _channelFunction ("green" , ColorSpace .rgb, (color) => color.green,
36
+ global: true )
36
37
.withDeprecationWarning ("color" ),
37
- _channelFunction ("blue" , (color) => color.blue, global: true )
38
+ _channelFunction ("blue" , ColorSpace .rgb, (color) => color.blue, global: true )
38
39
.withDeprecationWarning ("color" ),
39
40
_mix.withDeprecationWarning ("color" ),
40
41
@@ -59,12 +60,13 @@ final global = UnmodifiableListView([
59
60
.withDeprecationWarning ("color" ),
60
61
61
62
// ### HSL
62
- _channelFunction ("hue" , (color) => color.hue, unit: 'deg' , global: true )
63
+ _channelFunction ("hue" , ColorSpace .hsl, (color) => color.hue,
64
+ unit: 'deg' , global: true )
63
65
.withDeprecationWarning ("color" ),
64
- _channelFunction ("saturation" , (color) => color.saturation,
66
+ _channelFunction ("saturation" , ColorSpace .hsl, (color) => color.saturation,
65
67
unit: '%' , global: true )
66
68
.withDeprecationWarning ("color" ),
67
- _channelFunction ("lightness" , (color) => color.lightness,
69
+ _channelFunction ("lightness" , ColorSpace .hsl, (color) => color.lightness,
68
70
unit: '%' , global: true )
69
71
.withDeprecationWarning ("color" ),
70
72
@@ -346,9 +348,9 @@ final global = UnmodifiableListView([
346
348
/// The Sass color module.
347
349
final module = BuiltInModule ("color" , functions: < Callable > [
348
350
// ### 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),
352
354
_mix,
353
355
354
356
_function ("invert" , r"$color, $weight: 100%, $space: null" , (arguments) {
@@ -365,9 +367,11 @@ final module = BuiltInModule("color", functions: <Callable>[
365
367
}),
366
368
367
369
// ### 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: '%' ),
371
375
_removedColorFunction ("adjust-hue" , "hue" ),
372
376
_removedColorFunction ("lighten" , "lightness" ),
373
377
_removedColorFunction ("darken" , "lightness" , negative: true ),
@@ -403,8 +407,10 @@ final module = BuiltInModule("color", functions: <Callable>[
403
407
space: ColorSpace .hwb, name: 'channels' )
404
408
}),
405
409
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: '%' ),
408
414
409
415
// ### Opacity
410
416
_removedColorFunction ("opacify" , "alpha" ),
@@ -1593,15 +1599,15 @@ bool _isNone(Value value) =>
1593
1599
/// If [unit] is passed, the channel is returned with that unit. The [global]
1594
1600
/// parameter indicates whether this was called using the legacy global syntax.
1595
1601
BuiltInCallable _channelFunction (
1596
- String name, num Function (SassColor color) getter,
1602
+ String name, ColorSpace space, num Function (SassColor color) getter,
1597
1603
{String ? unit, bool global = false }) {
1598
1604
return _function (name, r"$color" , (arguments) {
1599
1605
var result = SassNumber (getter (arguments.first.assertColor ("color" )), unit);
1600
1606
1601
1607
warnForDeprecation (
1602
1608
"${global ? '' : 'color.' }$name () is deprecated. Suggestion:\n "
1603
1609
"\n "
1604
- 'color.channel(\$ color, $name )\n '
1610
+ 'color.channel(\$ color, $name , \$ space: $ space )\n '
1605
1611
"\n "
1606
1612
"More info: https://sass-lang.com/d/color-functions" ,
1607
1613
Deprecation .colorFunctions);
0 commit comments