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::{
|
use crate::{
|
||||||
args::CallArgs,
|
args::CallArgs,
|
||||||
color::Color,
|
color::Color,
|
||||||
common::QuoteKind,
|
common::{Brackets, ListSeparator, QuoteKind},
|
||||||
error::SassResult,
|
error::SassResult,
|
||||||
parse::Parser,
|
parse::Parser,
|
||||||
unit::Unit,
|
unit::Unit,
|
||||||
@ -35,6 +35,24 @@ fn inner_hsl(name: &'static str, mut args: CallArgs, parser: &mut Parser) -> Sas
|
|||||||
.into());
|
.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() {
|
let lightness = match channels.pop() {
|
||||||
Some(Value::Dimension(Some(n), ..)) => n / Number::from(100),
|
Some(Value::Dimension(Some(n), ..)) => n / Number::from(100),
|
||||||
Some(Value::Dimension(None, ..)) => todo!(),
|
Some(Value::Dimension(None, ..)) => todo!(),
|
||||||
|
@ -5,7 +5,7 @@ use num_traits::One;
|
|||||||
use crate::{
|
use crate::{
|
||||||
args::CallArgs,
|
args::CallArgs,
|
||||||
color::Color,
|
color::Color,
|
||||||
common::QuoteKind,
|
common::{Brackets, ListSeparator, QuoteKind},
|
||||||
error::SassResult,
|
error::SassResult,
|
||||||
parse::Parser,
|
parse::Parser,
|
||||||
unit::Unit,
|
unit::Unit,
|
||||||
@ -37,6 +37,24 @@ fn inner_rgb(name: &'static str, mut args: CallArgs, parser: &mut Parser) -> Sas
|
|||||||
.into());
|
.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() {
|
let blue = match channels.pop() {
|
||||||
Some(Value::Dimension(Some(n), Unit::None, _)) => n,
|
Some(Value::Dimension(Some(n), Unit::None, _)) => n,
|
||||||
Some(Value::Dimension(Some(n), Unit::Percent, _)) => {
|
Some(Value::Dimension(Some(n), Unit::Percent, _)) => {
|
||||||
|
@ -233,7 +233,7 @@ test!(
|
|||||||
"@media (max-width: 0px) {\n a {\n color: red;\n }\n}\n\na {\n color: red;\n}\n"
|
"@media (max-width: 0px) {\n a {\n color: red;\n }\n}\n\na {\n color: red;\n}\n"
|
||||||
);
|
);
|
||||||
test!(
|
test!(
|
||||||
#[ignore = "we move to top of media"]
|
#[ignore = "we move to top of media"]
|
||||||
plain_import_inside_media_is_not_moved_to_top,
|
plain_import_inside_media_is_not_moved_to_top,
|
||||||
r#"@media foo {
|
r#"@media foo {
|
||||||
a {
|
a {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user