Implement subtraction for colors
This commit is contained in:
parent
e282220f8c
commit
835fe61bb4
@ -87,7 +87,18 @@ impl Sub for Value {
|
|||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
},
|
},
|
||||||
// Self::List(..) => todo!(),
|
// Self::List(..) => todo!(),
|
||||||
// Self::Color(..) => todo!(),
|
Self::Color(c) => match other {
|
||||||
|
Self::Ident(s, quotes) => {
|
||||||
|
let quotes = match quotes {
|
||||||
|
QuoteKind::Double | QuoteKind::Single => QuoteKind::Double,
|
||||||
|
QuoteKind::None => QuoteKind::None,
|
||||||
|
};
|
||||||
|
Value::Ident(format!("{}-{}{}{}", c, quotes, s, quotes), QuoteKind::None)
|
||||||
|
}
|
||||||
|
Self::Null => Value::Ident(format!("{}-", c), QuoteKind::None),
|
||||||
|
Self::Dimension(..) => todo!("investigate adding numbers and colors"),
|
||||||
|
_ => Value::Ident(format!("{}-{}", c, other), QuoteKind::None)
|
||||||
|
},
|
||||||
// Self::BinaryOp(..) => todo!(),
|
// Self::BinaryOp(..) => todo!(),
|
||||||
// Self::Paren(..) => todo!(),
|
// Self::Paren(..) => todo!(),
|
||||||
Self::Ident(s1, quotes1) => match other {
|
Self::Ident(s1, quotes1) => match other {
|
||||||
@ -105,7 +116,7 @@ impl Sub for Value {
|
|||||||
QuoteKind::None,
|
QuoteKind::None,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Self::Important | Self::True | Self::False | Self::Dimension(..) => {
|
Self::Important | Self::True | Self::False | Self::Dimension(..) | Self::Color(..) => {
|
||||||
let quotes = match quotes1 {
|
let quotes = match quotes1 {
|
||||||
QuoteKind::Double | QuoteKind::Single => QuoteKind::Double,
|
QuoteKind::Double | QuoteKind::Single => QuoteKind::Double,
|
||||||
QuoteKind::None => QuoteKind::None,
|
QuoteKind::None => QuoteKind::None,
|
||||||
|
@ -131,6 +131,26 @@ test!(
|
|||||||
"a {\n color: red - foo;\n}\n",
|
"a {\n color: red - foo;\n}\n",
|
||||||
"a {\n color: red-foo;\n}\n"
|
"a {\n color: red-foo;\n}\n"
|
||||||
);
|
);
|
||||||
|
test!(
|
||||||
|
color_minus_dbl_quote_ident,
|
||||||
|
"a {\n color: red - \"foo\";\n}\n",
|
||||||
|
"a {\n color: red-\"foo\";\n}\n"
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
color_minus_sgl_quote_ident,
|
||||||
|
"a {\n color: red - 'foo';\n}\n",
|
||||||
|
"a {\n color: red-\"foo\";\n}\n"
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
color_minus_important,
|
||||||
|
"a {\n color: red - !important;\n}\n",
|
||||||
|
"a {\n color: red-!important;\n}\n"
|
||||||
|
);
|
||||||
|
test!(
|
||||||
|
color_minus_null,
|
||||||
|
"a {\n color: red - null;\n}\n",
|
||||||
|
"a {\n color: red-;\n}\n"
|
||||||
|
);
|
||||||
test!(
|
test!(
|
||||||
ident_minus_color,
|
ident_minus_color,
|
||||||
"a {\n color: foo - red;\n}\n",
|
"a {\n color: foo - red;\n}\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user