forked from parcel-bundler/lightningcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogical.rs
More file actions
47 lines (40 loc) · 1.06 KB
/
logical.rs
File metadata and controls
47 lines (40 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
use crate::traits::ToCss;
use crate::printer::Printer;
use crate::error::PrinterError;
use crate::properties::{Property, PropertyId};
#[derive(Debug, Clone, PartialEq)]
pub struct LogicalProperty<'i> {
pub property_id: PropertyId<'i>,
pub ltr: Option<Box<Property<'i>>>,
pub rtl: Option<Box<Property<'i>>>
}
impl<'i> ToCss for LogicalProperty<'i> {
fn to_css<W>(&self, dest: &mut Printer<W>) -> Result<(), PrinterError> where W: std::fmt::Write {
if let Some(ltr) = &self.ltr {
dest.write_str("var(--ltr,")?;
dest.whitespace()?;
ltr.value_to_css(dest)?;
dest.write_char(')')?;
}
if self.ltr.is_some() && self.rtl.is_some() {
dest.whitespace()?;
}
if let Some(rtl) = &self.rtl {
dest.write_str("var(--rtl,")?;
dest.whitespace()?;
rtl.value_to_css(dest)?;
dest.write_char(')')?;
}
Ok(())
}
}
#[derive(Debug, PartialEq)]
pub(crate) enum PropertyCategory {
Logical,
Physical
}
impl Default for PropertyCategory {
fn default() -> PropertyCategory {
PropertyCategory::Physical
}
}