Allow saturate($number). (#61)

This commit is contained in:
Natalie Weizenbaum 2016-12-09 16:41:47 -08:00 committed by GitHub
parent 9a7d2c879f
commit 5d96a2af20
2 changed files with 18 additions and 7 deletions

View File

@ -5,6 +5,8 @@
* Fix a bug with `@extend` superselector calculations.
* Allow a single number to be passed to `saturate()` for use in filter contexts.
* Fix a bug where `**/` would fail to close a loud comment.
## 1.0.0-alpha.4

View File

@ -185,13 +185,22 @@ void defineCoreFunctions(Environment environment) {
.clamp(0, 100));
});
environment.defineFunction("saturate", r"$color, $amount", (arguments) {
var color = arguments[0].assertColor("color");
var amount = arguments[1].assertNumber("amount");
return color.changeHsl(
saturation: (color.saturation + amount.valueInRange(0, 100, "amount"))
.clamp(0, 100));
});
environment.setFunction(new BuiltInCallable.overloaded("saturate", [
r"$number",
r"$color, $amount",
], [
(arguments) {
var number = arguments[0].assertNumber("number");
return new SassString("saturate(${number.toCssString()})");
},
(arguments) {
var color = arguments[0].assertColor("color");
var amount = arguments[1].assertNumber("amount");
return color.changeHsl(
saturation: (color.saturation + amount.valueInRange(0, 100, "amount"))
.clamp(0, 100));
}
]));
environment.defineFunction("desaturate", r"$color, $amount", (arguments) {
var color = arguments[0].assertColor("color");