1use crate::value::Unit;
2
3#[derive(Clone, Eq, Ord, PartialEq, PartialOrd)]
5pub enum GridAuto {
6 Auto,
8 Fixed(Unit),
10 Inherit,
12 Initial,
14 MaxContent,
16 MinContent,
18 MinMax(Unit, Unit),
20 Plain(Vec<Unit>),
22 Unset,
24}
25
26impl Default for GridAuto {
27 fn default() -> GridAuto {
28 GridAuto::Unset
29 }
30}
31
32impl ToString for GridAuto {
33 fn to_string(&self) -> String {
34 match self {
35 GridAuto::Auto => "auto".to_string(),
36 GridAuto::MaxContent => "max-content".to_string(),
37 GridAuto::MinContent => "min-content".to_string(),
38 GridAuto::MinMax(c, r) => format!("minmax({}, {})", c.to_string(), r.to_string()),
39 GridAuto::Fixed(u) => u.to_string(),
40 GridAuto::Inherit => "inherit".to_string(),
41 GridAuto::Initial => "initial".to_string(),
42 GridAuto::Unset => "unset".to_string(),
43 GridAuto::Plain(x) => {
44 let mut s = "".to_string();
45 for i in x {
46 s += &i.to_string();
47 s += " ";
48 }
49
50 s
51 }
52 }
53 }
54}
55
56#[derive(Clone, Copy, Eq, Ord, PartialEq, PartialOrd)]
73pub enum GridFlow {
74 Column,
76 Row,
78 Dense,
80 ColumnDense,
82 RowDense,
84 Inherit,
86 Initial,
88 Unset,
90}
91
92impl Default for GridFlow {
93 fn default() -> GridFlow {
94 GridFlow::Unset
95 }
96}
97
98impl ToString for GridFlow {
99 fn to_string(&self) -> String {
100 match self {
101 GridFlow::Column => "column",
102 GridFlow::ColumnDense => "column dense",
103 GridFlow::Dense => "dense",
104 GridFlow::Inherit => "inherit",
105 GridFlow::Initial => "initial",
106 GridFlow::Row => "row",
107 GridFlow::RowDense => "row dense",
108 GridFlow::Unset => "unset",
109 }
110 .to_string()
111 }
112}
113
114#[derive(Clone, Eq, Ord, PartialEq, PartialOrd)]
116pub enum GridTemplate {
117 FitContent(Unit),
119 Inherit,
121 Initial,
123 MinMax(Unit, Unit),
125 None,
127 Plain(Vec<Unit>),
129 Repeat(i32, Unit),
131 SubGrid,
133 Unset,
135}
136
137impl Default for GridTemplate {
138 fn default() -> GridTemplate {
139 GridTemplate::Repeat(1, Unit::Fr(1.0))
140 }
141}
142
143impl ToString for GridTemplate {
144 fn to_string(&self) -> String {
145 match self {
146 GridTemplate::FitContent(u) => format!("fit-content({})", u.to_string()),
147 GridTemplate::Inherit => "inherit".to_string(),
148 GridTemplate::Initial => "initial".to_string(),
149 GridTemplate::MinMax(i, a) => format!("minmax({}, {})", i.to_string(), a.to_string()),
150 GridTemplate::None => "none".to_string(),
151 GridTemplate::Plain(x) => {
152 let mut s = "".to_string();
153 for i in x {
154 s += &i.to_string();
155 s += " ";
156 }
157
158 s
159 }
160 GridTemplate::Repeat(n, u) => format!("({}, {})", n, u.to_string()),
161 GridTemplate::SubGrid => "subgrid".to_string(),
162 GridTemplate::Unset => "unit".to_string(),
163 }
164 }
165}