Skip to content

Commit 7c3f5e2

Browse files
authored
Add a $space parameter to the channel function deprecation (#2354)
Closes #2353
1 parent 5fa04d3 commit 7c3f5e2

File tree

7 files changed

+40
-20
lines changed

7 files changed

+40
-20
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 1.79.2
2+
3+
* Add a `$space` parameter to the suggested replacement for `color.red()`,
4+
`color.green()`, `color.blue()`, `color.hue()`, `color.saturation()`,
5+
`color.lightness()`, `color.whiteness()`, and `color.blackness()`.
6+
17
## 1.79.1
28

39
* No user-visible changes.

lib/src/functions/color.dart

+22-16
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ const _specialCommaSpaces = {ColorSpace.rgb, ColorSpace.hsl};
3030
/// The global definitions of Sass color functions.
3131
final 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.
347349
final 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.
15951601
BuiltInCallable _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);

pkg/sass-parser/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.1
2+
3+
* No user-visible changes.
4+
15
## 0.2.0
26

37
* Initial unstable release.

pkg/sass-parser/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sass-parser",
3-
"version": "0.2.0",
3+
"version": "0.2.1-dev",
44
"description": "A PostCSS-compatible wrapper of the official Sass parser",
55
"repository": "sass/sass",
66
"author": "Google Inc.",

pkg/sass_api/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 12.0.2
2+
3+
* No user-visible changes.
4+
15
## 12.0.1
26

37
* No user-visible changes.

pkg/sass_api/pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ name: sass_api
22
# Note: Every time we add a new Sass AST node, we need to bump the *major*
33
# version because it's a breaking change for anyone who's implementing the
44
# visitor interface(s).
5-
version: 12.0.1
5+
version: 12.0.2
66
description: Additional APIs for Dart Sass.
77
homepage: https://github.com/sass/dart-sass
88

99
environment:
1010
sdk: ">=3.0.0 <4.0.0"
1111

1212
dependencies:
13-
sass: 1.79.1
13+
sass: 1.79.2
1414

1515
dev_dependencies:
1616
dartdoc: ^8.0.14

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.79.1
2+
version: 1.79.2-dev
33
description: A Sass implementation in Dart.
44
homepage: https://github.com/sass/dart-sass
55

0 commit comments

Comments
 (0)