elvis_core/value/
box.rs

1use super::{Color, Unit};
2use elvis_core_support::EnumStyle;
3use std::cmp::Ordering;
4
5/// Box Shadow
6#[derive(Clone, PartialEq, Eq)]
7pub enum BoxShadow {
8    /// None Style
9    None,
10    /// Inherit Style
11    Inherit,
12    /// Initial Style
13    Initial,
14    /// Inset Style
15    Inset,
16    /// Unset Style
17    Unset,
18    /// Unit
19    Unit(Unit),
20    /// Color
21    Color(Color),
22    /// offset-x | offset-y | blur-radius | spread-radius | color
23    Customize(Vec<BoxShadow>),
24    /// Derive BoxShadows
25    Derive(Vec<BoxShadow>),
26}
27
28impl Default for BoxShadow {
29    fn default() -> BoxShadow {
30        BoxShadow::None
31    }
32}
33
34impl PartialOrd for BoxShadow {
35    fn partial_cmp(&self, o: &Self) -> Option<Ordering> {
36        self.to_string().partial_cmp(&o.to_string())
37    }
38}
39
40impl Ord for BoxShadow {
41    fn cmp(&self, o: &Self) -> Ordering {
42        self.to_string().cmp(&o.to_string())
43    }
44}
45
46impl ToString for BoxShadow {
47    fn to_string(&self) -> String {
48        match self {
49            BoxShadow::None => "none".to_string(),
50            BoxShadow::Inset => "inset".to_string(),
51            BoxShadow::Inherit => "inherit".to_string(),
52            BoxShadow::Initial => "initial".to_string(),
53            BoxShadow::Unset => "unset".to_string(),
54            BoxShadow::Unit(v) => v.to_string(),
55            BoxShadow::Color(v) => v.to_string(),
56            BoxShadow::Customize(v) => v
57                .iter()
58                .map(|s| s.to_string())
59                .collect::<Vec<String>>()
60                .join(" "),
61            BoxShadow::Derive(v) => v
62                .iter()
63                .map(|bs| bs.to_string())
64                .collect::<Vec<String>>()
65                .join(", "),
66        }
67    }
68}
69
70/// Box Position
71#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, EnumStyle)]
72pub enum Position {
73    /// Absolute position
74    Absolute,
75    /// Relative position
76    Relative,
77}
78
79impl Default for Position {
80    fn default() -> Position {
81        Position::Relative
82    }
83}