support special fns to single channel rgb/rgba/hsl/hsla
This commit is contained in:
parent
4b94c8a948
commit
eadd7c5041
@ -6,7 +6,7 @@ use num_traits::One;
|
||||
use crate::{
|
||||
args::CallArgs,
|
||||
color::Color,
|
||||
common::QuoteKind,
|
||||
common::{Brackets, ListSeparator, QuoteKind},
|
||||
error::SassResult,
|
||||
parse::Parser,
|
||||
unit::Unit,
|
||||
@ -35,6 +35,24 @@ fn inner_hsl(name: &'static str, mut args: CallArgs, parser: &mut Parser) -> Sas
|
||||
.into());
|
||||
}
|
||||
|
||||
if channels.iter().any(Value::is_special_function) {
|
||||
let channel_sep = if channels.len() < 3 {
|
||||
ListSeparator::Space
|
||||
} else {
|
||||
ListSeparator::Comma
|
||||
};
|
||||
|
||||
return Ok(Value::String(
|
||||
format!(
|
||||
"{}({})",
|
||||
name,
|
||||
Value::List(channels, channel_sep, Brackets::None)
|
||||
.to_css_string(args.span(), false)?
|
||||
),
|
||||
QuoteKind::None,
|
||||
));
|
||||
}
|
||||
|
||||
let lightness = match channels.pop() {
|
||||
Some(Value::Dimension(Some(n), ..)) => n / Number::from(100),
|
||||
Some(Value::Dimension(None, ..)) => todo!(),
|
||||
|
@ -5,7 +5,7 @@ use num_traits::One;
|
||||
use crate::{
|
||||
args::CallArgs,
|
||||
color::Color,
|
||||
common::QuoteKind,
|
||||
common::{Brackets, ListSeparator, QuoteKind},
|
||||
error::SassResult,
|
||||
parse::Parser,
|
||||
unit::Unit,
|
||||
@ -37,6 +37,24 @@ fn inner_rgb(name: &'static str, mut args: CallArgs, parser: &mut Parser) -> Sas
|
||||
.into());
|
||||
}
|
||||
|
||||
if channels.iter().any(Value::is_special_function) {
|
||||
let channel_sep = if channels.len() < 3 {
|
||||
ListSeparator::Space
|
||||
} else {
|
||||
ListSeparator::Comma
|
||||
};
|
||||
|
||||
return Ok(Value::String(
|
||||
format!(
|
||||
"{}({})",
|
||||
name,
|
||||
Value::List(channels, channel_sep, Brackets::None)
|
||||
.to_css_string(args.span(), false)?
|
||||
),
|
||||
QuoteKind::None,
|
||||
));
|
||||
}
|
||||
|
||||
let blue = match channels.pop() {
|
||||
Some(Value::Dimension(Some(n), Unit::None, _)) => n,
|
||||
Some(Value::Dimension(Some(n), Unit::Percent, _)) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user