Allow 3 arguments in rgba()
This commit is contained in:
parent
46e4ccd5f9
commit
4702461fe7
@ -93,10 +93,10 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
|
||||
Value::Dimension(n, Unit::Percent) => (n / Number::from(100)) * Number::from(255),
|
||||
_ => todo!("expected either unitless or % number for alpha"),
|
||||
};
|
||||
let alpha = match arg!(args, 3, "alpha").eval() {
|
||||
let alpha = match arg!(args, 3, "alpha"=Value::Dimension(Number::from(1), Unit::None)).eval() {
|
||||
Value::Dimension(n, Unit::None) => n,
|
||||
Value::Dimension(n, Unit::Percent) => n / Number::from(100),
|
||||
_ => todo!("expected either unitless or % number for alpha"),
|
||||
_ => todo!("expected either unitless or % number for alpha")
|
||||
};
|
||||
Some(Value::Color(Color::from_rgba(red, green, blue, alpha)))
|
||||
}
|
||||
|
@ -113,6 +113,11 @@ test!(
|
||||
"a {\n color: rgba(1, 2, 3, 50%);\n}\n",
|
||||
"a {\n color: rgba(1, 2, 3, 0.5);\n}\n"
|
||||
);
|
||||
test!(
|
||||
rgba_3_args,
|
||||
"a {\n color: rgba(7.1%, 20.4%, 33.9%);\n}\n",
|
||||
"a {\n color: #123456;\n}\n"
|
||||
);
|
||||
test!(
|
||||
hsl_basic,
|
||||
"a {\n color: hsl(193, 67%, 99);\n}\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user