From 7ba5128423b1437ac0aa59a3a443cd8960b524da Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Wed, 14 Oct 2020 16:15:46 -0700 Subject: [PATCH] Add color.whiteness() and color.blackness() functions (#1110) See sass/sass#2834 See #1089 --- CHANGELOG.md | 11 +++++++++++ lib/src/functions/color.dart | 12 ++++++++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5162f63..3fcaa0cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ ## 1.28.0 +* Add a [`color.hwb()`] function to `sass:color` that can express colors in [HWB] format. + +[`color.hwb()`]: https://sass-lang.com/documentation/modules/color#hwb +[HWB]: https://en.wikipedia.org/wiki/HWB_color_model + +* Add [`color.whiteness()`] and [`color.blackness()`] functions to `sass:color` + to get a color's [HWB] whiteness and blackness components. + +[`color.whiteness()`]: https://sass-lang.com/documentation/modules/color#whiteness +[`color.blackness()`]: https://sass-lang.com/documentation/modules/color#blackness + ### Dart API * Add [HWB] support to the `SassColor` class, including a `SassColor.hwb()` diff --git a/lib/src/functions/color.dart b/lib/src/functions/color.dart index faa8ba53..99153fa7 100644 --- a/lib/src/functions/color.dart +++ b/lib/src/functions/color.dart @@ -281,6 +281,18 @@ final module = BuiltInModule("color", functions: [ } }), + _function( + "whiteness", + r"$color", + (arguments) => + SassNumber(arguments.first.assertColor("color").whiteness, "%")), + + _function( + "blackness", + r"$color", + (arguments) => + SassNumber(arguments.first.assertColor("color").blackness, "%")), + // ### Opacity _removedColorFunction("opacify", "alpha"), _removedColorFunction("fade-in", "alpha"),