windjammer_ui/components/generated/
column.rs

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