From 7c3f5e2489598eeebe1acb4587e4c30415038f26 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 19 Sep 2024 01:20:06 +0000 Subject: [PATCH] Add a `$space` parameter to the channel function deprecation (#2354) Closes sass/dart-sass#2353 --- CHANGELOG.md | 6 ++++++ lib/src/functions/color.dart | 38 +++++++++++++++++++++--------------- pkg/sass-parser/CHANGELOG.md | 4 ++++ pkg/sass-parser/package.json | 2 +- pkg/sass_api/CHANGELOG.md | 4 ++++ pkg/sass_api/pubspec.yaml | 4 ++-- pubspec.yaml | 2 +- 7 files changed, 40 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88a8ddd95..28c5d93de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.79.2 + +* Add a `$space` parameter to the suggested replacement for `color.red()`, + `color.green()`, `color.blue()`, `color.hue()`, `color.saturation()`, + `color.lightness()`, `color.whiteness()`, and `color.blackness()`. + ## 1.79.1 * No user-visible changes. diff --git a/lib/src/functions/color.dart b/lib/src/functions/color.dart index 3745f3f72..6248a171d 100644 --- a/lib/src/functions/color.dart +++ b/lib/src/functions/color.dart @@ -30,11 +30,12 @@ const _specialCommaSpaces = {ColorSpace.rgb, ColorSpace.hsl}; /// The global definitions of Sass color functions. final global = UnmodifiableListView([ // ### RGB - _channelFunction("red", (color) => color.red, global: true) + _channelFunction("red", ColorSpace.rgb, (color) => color.red, global: true) .withDeprecationWarning("color"), - _channelFunction("green", (color) => color.green, global: true) + _channelFunction("green", ColorSpace.rgb, (color) => color.green, + global: true) .withDeprecationWarning("color"), - _channelFunction("blue", (color) => color.blue, global: true) + _channelFunction("blue", ColorSpace.rgb, (color) => color.blue, global: true) .withDeprecationWarning("color"), _mix.withDeprecationWarning("color"), @@ -59,12 +60,13 @@ final global = UnmodifiableListView([ .withDeprecationWarning("color"), // ### HSL - _channelFunction("hue", (color) => color.hue, unit: 'deg', global: true) + _channelFunction("hue", ColorSpace.hsl, (color) => color.hue, + unit: 'deg', global: true) .withDeprecationWarning("color"), - _channelFunction("saturation", (color) => color.saturation, + _channelFunction("saturation", ColorSpace.hsl, (color) => color.saturation, unit: '%', global: true) .withDeprecationWarning("color"), - _channelFunction("lightness", (color) => color.lightness, + _channelFunction("lightness", ColorSpace.hsl, (color) => color.lightness, unit: '%', global: true) .withDeprecationWarning("color"), @@ -346,9 +348,9 @@ final global = UnmodifiableListView([ /// The Sass color module. final module = BuiltInModule("color", functions: [ // ### RGB - _channelFunction("red", (color) => color.red), - _channelFunction("green", (color) => color.green), - _channelFunction("blue", (color) => color.blue), + _channelFunction("red", ColorSpace.rgb, (color) => color.red), + _channelFunction("green", ColorSpace.rgb, (color) => color.green), + _channelFunction("blue", ColorSpace.rgb, (color) => color.blue), _mix, _function("invert", r"$color, $weight: 100%, $space: null", (arguments) { @@ -365,9 +367,11 @@ final module = BuiltInModule("color", functions: [ }), // ### HSL - _channelFunction("hue", (color) => color.hue, unit: 'deg'), - _channelFunction("saturation", (color) => color.saturation, unit: '%'), - _channelFunction("lightness", (color) => color.lightness, unit: '%'), + _channelFunction("hue", ColorSpace.hsl, (color) => color.hue, unit: 'deg'), + _channelFunction("saturation", ColorSpace.hsl, (color) => color.saturation, + unit: '%'), + _channelFunction("lightness", ColorSpace.hsl, (color) => color.lightness, + unit: '%'), _removedColorFunction("adjust-hue", "hue"), _removedColorFunction("lighten", "lightness"), _removedColorFunction("darken", "lightness", negative: true), @@ -403,8 +407,10 @@ final module = BuiltInModule("color", functions: [ space: ColorSpace.hwb, name: 'channels') }), - _channelFunction("whiteness", (color) => color.whiteness, unit: '%'), - _channelFunction("blackness", (color) => color.blackness, unit: '%'), + _channelFunction("whiteness", ColorSpace.hwb, (color) => color.whiteness, + unit: '%'), + _channelFunction("blackness", ColorSpace.hwb, (color) => color.blackness, + unit: '%'), // ### Opacity _removedColorFunction("opacify", "alpha"), @@ -1593,7 +1599,7 @@ bool _isNone(Value value) => /// If [unit] is passed, the channel is returned with that unit. The [global] /// parameter indicates whether this was called using the legacy global syntax. BuiltInCallable _channelFunction( - String name, num Function(SassColor color) getter, + String name, ColorSpace space, num Function(SassColor color) getter, {String? unit, bool global = false}) { return _function(name, r"$color", (arguments) { var result = SassNumber(getter(arguments.first.assertColor("color")), unit); @@ -1601,7 +1607,7 @@ BuiltInCallable _channelFunction( warnForDeprecation( "${global ? '' : 'color.'}$name() is deprecated. Suggestion:\n" "\n" - 'color.channel(\$color, $name)\n' + 'color.channel(\$color, $name, \$space: $space)\n' "\n" "More info: https://sass-lang.com/d/color-functions", Deprecation.colorFunctions); diff --git a/pkg/sass-parser/CHANGELOG.md b/pkg/sass-parser/CHANGELOG.md index 924d79f86..0cf7905c5 100644 --- a/pkg/sass-parser/CHANGELOG.md +++ b/pkg/sass-parser/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.2.1 + +* No user-visible changes. + ## 0.2.0 * Initial unstable release. diff --git a/pkg/sass-parser/package.json b/pkg/sass-parser/package.json index 99e280a7f..fcb6bc998 100644 --- a/pkg/sass-parser/package.json +++ b/pkg/sass-parser/package.json @@ -1,6 +1,6 @@ { "name": "sass-parser", - "version": "0.2.0", + "version": "0.2.1-dev", "description": "A PostCSS-compatible wrapper of the official Sass parser", "repository": "sass/sass", "author": "Google Inc.", diff --git a/pkg/sass_api/CHANGELOG.md b/pkg/sass_api/CHANGELOG.md index 84995eba6..5fdc5b1ff 100644 --- a/pkg/sass_api/CHANGELOG.md +++ b/pkg/sass_api/CHANGELOG.md @@ -1,3 +1,7 @@ +## 12.0.2 + +* No user-visible changes. + ## 12.0.1 * No user-visible changes. diff --git a/pkg/sass_api/pubspec.yaml b/pkg/sass_api/pubspec.yaml index 19deb9668..78d93db09 100644 --- a/pkg/sass_api/pubspec.yaml +++ b/pkg/sass_api/pubspec.yaml @@ -2,7 +2,7 @@ name: sass_api # Note: Every time we add a new Sass AST node, we need to bump the *major* # version because it's a breaking change for anyone who's implementing the # visitor interface(s). -version: 12.0.1 +version: 12.0.2 description: Additional APIs for Dart Sass. homepage: https://github.com/sass/dart-sass @@ -10,7 +10,7 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - sass: 1.79.1 + sass: 1.79.2 dev_dependencies: dartdoc: ^8.0.14 diff --git a/pubspec.yaml b/pubspec.yaml index 238fa6ef2..af25ccf65 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.79.1 +version: 1.79.2-dev description: A Sass implementation in Dart. homepage: https://github.com/sass/dart-sass