2020-06-16 19:38:30 -04:00
|
|
|
use codemap::Spanned;
|
2020-04-12 19:37:12 -04:00
|
|
|
|
2020-06-16 20:00:11 -04:00
|
|
|
use crate::{error::SassResult, value::Value};
|
2020-01-06 16:50:16 -05:00
|
|
|
|
2020-01-08 20:58:02 -05:00
|
|
|
/// A style: `color: red`
|
2020-01-06 16:50:16 -05:00
|
|
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
2020-01-20 13:15:47 -05:00
|
|
|
pub(crate) struct Style {
|
2020-05-22 14:20:31 -04:00
|
|
|
pub property: String,
|
2020-04-12 19:37:12 -04:00
|
|
|
pub value: Spanned<Value>,
|
2020-01-06 16:50:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Style {
|
2020-04-12 19:37:12 -04:00
|
|
|
pub fn to_string(&self) -> SassResult<String> {
|
|
|
|
Ok(format!(
|
|
|
|
"{}: {};",
|
|
|
|
self.property,
|
|
|
|
self.value.node.to_css_string(self.value.span)?
|
|
|
|
))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub(crate) fn eval(self) -> SassResult<Self> {
|
|
|
|
Ok(Style {
|
|
|
|
property: self.property,
|
|
|
|
value: Spanned {
|
|
|
|
span: self.value.span,
|
|
|
|
node: self.value.node.eval(self.value.span)?.node,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
2020-01-06 16:50:16 -05:00
|
|
|
}
|