windjammer_ui/components/generated/
column.rs

1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3pub struct Column {
4    children: Vec<String>,
5    gap: String,
6    align: ColumnAlign,
7    justify: ColumnJustify,
8    class: String,
9}
10
11pub enum ColumnAlign {
12    Start,
13    Center,
14    End,
15    Stretch,
16}
17
18pub enum ColumnJustify {
19    Start,
20    Center,
21    End,
22    SpaceBetween,
23    SpaceAround,
24    SpaceEvenly,
25}
26
27impl Column {
28    #[inline]
29    pub fn new() -> Column {
30        Column {
31            children: Vec::new(),
32            gap: "8px".to_string(),
33            align: ColumnAlign::Start,
34            justify: ColumnJustify::Start,
35            class: String::new(),
36        }
37    }
38    #[inline]
39    pub fn child(mut self, child: String) -> Column {
40        self.children.push(child);
41        self
42    }
43    #[inline]
44    pub fn gap(mut self, gap: String) -> Column {
45        self.gap = gap;
46        self
47    }
48    #[inline]
49    pub fn align(mut self, align: ColumnAlign) -> Column {
50        self.align = align;
51        self
52    }
53    #[inline]
54    pub fn justify(mut self, justify: ColumnJustify) -> Column {
55        self.justify = justify;
56        self
57    }
58    #[inline]
59    pub fn class(mut self, class: String) -> Column {
60        self.class = class;
61        self
62    }
63    pub fn render(&self) -> String {
64        let align_str = match self.align {
65            ColumnAlign::Start => "flex-start",
66            ColumnAlign::Center => "center",
67            ColumnAlign::End => "flex-end",
68            ColumnAlign::Stretch => "stretch",
69        };
70        let justify_str = match self.justify {
71            ColumnJustify::Start => "flex-start",
72            ColumnJustify::Center => "center",
73            ColumnJustify::End => "flex-end",
74            ColumnJustify::SpaceBetween => "space-between",
75            ColumnJustify::SpaceAround => "space-around",
76            ColumnJustify::SpaceEvenly => "space-evenly",
77        };
78        let mut html = String::new();
79        html.push_str("<div class=\"wj-column ");
80        html.push_str(self.class.as_str());
81        html.push_str("\" style=\"display: flex; flex-direction: column; gap: ");
82        html.push_str(self.gap.as_str());
83        html.push_str("; align-items: ");
84        html.push_str(align_str);
85        html.push_str("; justify-content: ");
86        html.push_str(justify_str);
87        html.push_str(";\">");
88        for child in self.children.iter() {
89            html.push_str(child.as_str());
90        }
91        html.push_str("</div>");
92        html
93    }
94}