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