From 4702461fe74ff559f8aeb21b6a0be85a669811d1 Mon Sep 17 00:00:00 2001 From: ConnorSkees <39542938+ConnorSkees@users.noreply.github.com> Date: Sat, 15 Feb 2020 07:00:24 -0500 Subject: [PATCH] Allow 3 arguments in `rgba()` --- src/builtin/color/rgb.rs | 4 ++-- tests/color.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/builtin/color/rgb.rs b/src/builtin/color/rgb.rs index e7d103c..cc0bd1a 100644 --- a/src/builtin/color/rgb.rs +++ b/src/builtin/color/rgb.rs @@ -93,10 +93,10 @@ pub(crate) fn register(f: &mut BTreeMap) { 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))) } diff --git a/tests/color.rs b/tests/color.rs index 135815e..786607e 100644 --- a/tests/color.rs +++ b/tests/color.rs @@ -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",