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
48
49
50
51
use types::{Appearance, PropertyValue};
use properties::Color;
use yoga::StyleUnit;

impl_union_into_appearance!(Background);

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum Background {
    Gradient(Gradient),
    Color(Color),
}

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct GradientStop {
    pub offset: f32,
    pub color: Color,
}

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct Gradient {
    pub stops: Vec<GradientStop>,
    // By percentage
    pub from: (f32, f32),
    pub to: (f32, f32),
}

#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub struct BoxShadow {
    pub color: Option<Color>,
    pub horizontal: StyleUnit,
    pub vertical: StyleUnit,
    pub blur: Option<StyleUnit>,
    pub spread: Option<StyleUnit>,
    pub inset: bool,
}

#[derive(Debug, PartialEq, Copy, Clone, Serialize, Deserialize)]
pub enum Visibility {
    Hidden,
    Visible,
}

impl Into<bool> for Visibility {
    fn into(self) -> bool {
        match self {
            Visibility::Visible => true,
            Visibility::Hidden => false,
        }
    }
}