windjammer_ui/components/generated/
spacer.rs

1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3use super::traits::Renderable;
4
5#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
6pub struct Spacer {
7    pub width: String,
8    pub height: String,
9    pub flex: bool,
10}
11
12impl Spacer {
13    #[inline]
14    pub fn new() -> Spacer {
15        Spacer {
16            width: "".to_string(),
17            height: "".to_string(),
18            flex: false,
19        }
20    }
21    #[inline]
22    pub fn horizontal(width: String) -> Spacer {
23        Spacer {
24            width,
25            height: "".to_string(),
26            flex: false,
27        }
28    }
29    #[inline]
30    pub fn vertical(height: String) -> Spacer {
31        Spacer {
32            width: "".to_string(),
33            height,
34            flex: false,
35        }
36    }
37    #[inline]
38    pub fn flexible() -> Spacer {
39        Spacer {
40            width: "".to_string(),
41            height: "".to_string(),
42            flex: true,
43        }
44    }
45    #[inline]
46    pub fn width(mut self, width: String) -> Spacer {
47        self.width = width;
48        self
49    }
50    #[inline]
51    pub fn height(mut self, height: String) -> Spacer {
52        self.height = height;
53        self
54    }
55    #[inline]
56    pub fn xxs() -> Spacer {
57        Spacer::vertical("4px".to_string())
58    }
59    #[inline]
60    pub fn xs() -> Spacer {
61        Spacer::vertical("8px".to_string())
62    }
63    #[inline]
64    pub fn sm() -> Spacer {
65        Spacer::vertical("12px".to_string())
66    }
67    #[inline]
68    pub fn md() -> Spacer {
69        Spacer::vertical("16px".to_string())
70    }
71    #[inline]
72    pub fn lg() -> Spacer {
73        Spacer::vertical("24px".to_string())
74    }
75    #[inline]
76    pub fn xl() -> Spacer {
77        Spacer::vertical("32px".to_string())
78    }
79    #[inline]
80    pub fn xxl() -> Spacer {
81        Spacer::vertical("48px".to_string())
82    }
83}
84
85impl Renderable for Spacer {
86    #[inline]
87    fn render(self) -> String {
88        let mut style = "".to_string();
89        if self.flex {
90            style = "flex: 1; ".to_string();
91        }
92        if self.width != "" {
93            style = format!("{}width: {}; ", style, self.width);
94        }
95        if self.height != "" {
96            style = format!("{}height: {}; ", style, self.height);
97        }
98        format!("<div class='wj-spacer' style='{}'></div>", style)
99    }
100}