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 super::Builtin;
|
||||||
use crate::color::Color;
|
use crate::color::Color;
|
||||||
|
use crate::common::QuoteKind;
|
||||||
use crate::units::Unit;
|
use crate::units::Unit;
|
||||||
use crate::value::{Number, Value};
|
use crate::value::{Number, Value};
|
||||||
|
|
||||||
@ -133,6 +134,7 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
|
|||||||
max_args!(args, 1);
|
max_args!(args, 1);
|
||||||
let color = match arg!(args, 0, "color").eval() {
|
let color = match arg!(args, 0, "color").eval() {
|
||||||
Value::Color(c) => c,
|
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()),
|
v => return Err(format!("$color: {} is not a color.", v).into()),
|
||||||
};
|
};
|
||||||
Ok(Value::Color(color.desaturate(Number::from(1))))
|
Ok(Value::Color(color.desaturate(Number::from(1))))
|
||||||
|
@ -391,6 +391,14 @@ test!(
|
|||||||
"a {\n color: grayscale(red);\n}\n",
|
"a {\n color: grayscale(red);\n}\n",
|
||||||
"a {\n color: gray;\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!(
|
test!(
|
||||||
complement,
|
complement,
|
||||||
"a {\n color: complement(red);\n}\n",
|
"a {\n color: complement(red);\n}\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user