Grayscale function behaves differently when given a number
This commit is contained in:
parent
96d29f45b8
commit
ca0e2d47cb
@ -2,6 +2,7 @@ use std::collections::BTreeMap;
|
||||
|
||||
use super::Builtin;
|
||||
use crate::color::Color;
|
||||
use crate::common::QuoteKind;
|
||||
use crate::units::Unit;
|
||||
use crate::value::{Number, Value};
|
||||
|
||||
@ -133,6 +134,7 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
|
||||
max_args!(args, 1);
|
||||
let color = match arg!(args, 0, "color").eval() {
|
||||
Value::Color(c) => c,
|
||||
Value::Dimension(n, u) => return Ok(Value::Ident(format!("grayscale({}{})", n, u), QuoteKind::None)),
|
||||
v => return Err(format!("$color: {} is not a color.", v).into()),
|
||||
};
|
||||
Ok(Value::Color(color.desaturate(Number::from(1))))
|
||||
|
@ -391,6 +391,14 @@ test!(
|
||||
"a {\n color: grayscale(red);\n}\n",
|
||||
"a {\n color: gray;\n}\n"
|
||||
);
|
||||
test!(
|
||||
grayscale_number,
|
||||
"a {\n color: grayscale(15%);\n}\n"
|
||||
);
|
||||
// test!(
|
||||
// grayscale_number_casing,
|
||||
// "a {\n color: grAyscaLe(15%);\n}\n"
|
||||
// );
|
||||
test!(
|
||||
complement,
|
||||
"a {\n color: complement(red);\n}\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user