mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-22 05:41:14 +01:00
Allow saturate($number). (#61)
This commit is contained in:
parent
9a7d2c879f
commit
5d96a2af20
@ -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
|
||||
|
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user