windjammer_ui/components/generated/
html_elements.rs1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3use super::traits::Renderable;
4
5pub struct Div {
6 children: Vec<String>,
7 class: String,
8 style: String,
9 id: String,
10}
11
12impl Div {
13 #[inline]
14 pub fn new() -> Div {
15 Div {
16 children: Vec::new(),
17 class: String::new(),
18 style: String::new(),
19 id: String::new(),
20 }
21 }
22 #[inline]
23 pub fn child<T: Renderable>(mut self, component: T) -> Div {
24 self.children.push(component.render());
25 self
26 }
27 #[inline]
28 pub fn text(mut self, text: String) -> Div {
29 self.children.push(text);
30 self
31 }
32 #[inline]
33 pub fn class(mut self, class: String) -> Div {
34 self.class = class;
35 self
36 }
37 #[inline]
38 pub fn style(mut self, style: String) -> Div {
39 self.style = style;
40 self
41 }
42 #[inline]
43 pub fn id(mut self, id: String) -> Div {
44 self.id = id;
45 self
46 }
47 pub fn render(&self) -> String {
48 let mut html = String::new();
49 html.push_str("<div");
50 if !self.id.is_empty() {
51 html.push_str(" id=\"");
52 html.push_str(self.id.as_str());
53 html.push('"')
54 }
55 if !self.class.is_empty() {
56 html.push_str(" class=\"");
57 html.push_str(self.class.as_str());
58 html.push('"')
59 }
60 if !self.style.is_empty() {
61 html.push_str(" style=\"");
62 html.push_str(self.style.as_str());
63 html.push('"')
64 }
65 html.push('>');
66 for child in self.children.iter() {
67 html.push_str(child.as_str());
68 }
69 html.push_str("</div>");
70 html
71 }
72}
73
74pub struct Span {
75 children: Vec<String>,
76 class: String,
77 style: String,
78}
79
80impl Span {
81 #[inline]
82 pub fn new() -> Span {
83 Span {
84 children: Vec::new(),
85 class: String::new(),
86 style: String::new(),
87 }
88 }
89 #[inline]
90 pub fn child<T: Renderable>(mut self, component: T) -> Span {
91 self.children.push(component.render());
92 self
93 }
94 #[inline]
95 pub fn text(mut self, text: String) -> Span {
96 self.children.push(text);
97 self
98 }
99 #[inline]
100 pub fn class(mut self, class: String) -> Span {
101 self.class = class;
102 self
103 }
104 #[inline]
105 pub fn style(mut self, style: String) -> Span {
106 self.style = style;
107 self
108 }
109}
110
111impl Renderable for Span {
112 fn render(self) -> String {
113 let mut html = String::new();
114 html.push_str("<span");
115 if !self.class.is_empty() {
116 html.push_str(" class=\"");
117 html.push_str(self.class.as_str());
118 html.push('"')
119 }
120 if !self.style.is_empty() {
121 html.push_str(" style=\"");
122 html.push_str(self.style.as_str());
123 html.push('"')
124 }
125 html.push('>');
126 for child in self.children.iter() {
127 html.push_str(child.as_str());
128 }
129 html.push_str("</span>");
130 html
131 }
132}
133
134pub struct P {
135 children: Vec<String>,
136 class: String,
137 style: String,
138}
139
140impl P {
141 #[inline]
142 pub fn new() -> P {
143 P {
144 children: Vec::new(),
145 class: String::new(),
146 style: String::new(),
147 }
148 }
149 #[inline]
150 pub fn child<T: Renderable>(mut self, component: T) -> P {
151 self.children.push(component.render());
152 self
153 }
154 #[inline]
155 pub fn text(mut self, text: String) -> P {
156 self.children.push(text);
157 self
158 }
159 #[inline]
160 pub fn class(mut self, class: String) -> P {
161 self.class = class;
162 self
163 }
164 #[inline]
165 pub fn style(mut self, style: String) -> P {
166 self.style = style;
167 self
168 }
169}
170
171impl Renderable for P {
172 fn render(self) -> String {
173 let mut html = String::new();
174 html.push_str("<p");
175 if !self.class.is_empty() {
176 html.push_str(" class=\"");
177 html.push_str(self.class.as_str());
178 html.push('"')
179 }
180 if !self.style.is_empty() {
181 html.push_str(" style=\"");
182 html.push_str(self.style.as_str());
183 html.push('"')
184 }
185 html.push('>');
186 for child in self.children.iter() {
187 html.push_str(child.as_str());
188 }
189 html.push_str("</p>");
190 html
191 }
192}
193
194pub struct H1 {
195 text: String,
196 class: String,
197 style: String,
198}
199
200impl H1 {
201 #[inline]
202 pub fn new(text: String) -> H1 {
203 H1 {
204 text,
205 class: String::new(),
206 style: String::new(),
207 }
208 }
209 #[inline]
210 pub fn class(mut self, class: String) -> H1 {
211 self.class = class;
212 self
213 }
214 #[inline]
215 pub fn style(mut self, style: String) -> H1 {
216 self.style = style;
217 self
218 }
219}
220
221impl Renderable for H1 {
222 fn render(self) -> String {
223 let mut html = String::new();
224 html.push_str("<h1");
225 if !self.class.is_empty() {
226 html.push_str(" class=\"");
227 html.push_str(self.class.as_str());
228 html.push('"')
229 }
230 if !self.style.is_empty() {
231 html.push_str(" style=\"");
232 html.push_str(self.style.as_str());
233 html.push('"')
234 }
235 html.push('>');
236 html.push_str(self.text.as_str());
237 html.push_str("</h1>");
238 html
239 }
240}
241
242pub struct H2 {
243 text: String,
244 class: String,
245 style: String,
246}
247
248impl H2 {
249 #[inline]
250 pub fn new(text: String) -> H2 {
251 H2 {
252 text,
253 class: String::new(),
254 style: String::new(),
255 }
256 }
257 #[inline]
258 pub fn class(mut self, class: String) -> H2 {
259 self.class = class;
260 self
261 }
262 #[inline]
263 pub fn style(mut self, style: String) -> H2 {
264 self.style = style;
265 self
266 }
267}
268
269impl Renderable for H2 {
270 fn render(self) -> String {
271 let mut html = String::new();
272 html.push_str("<h2");
273 if !self.class.is_empty() {
274 html.push_str(" class=\"");
275 html.push_str(self.class.as_str());
276 html.push('"')
277 }
278 if !self.style.is_empty() {
279 html.push_str(" style=\"");
280 html.push_str(self.style.as_str());
281 html.push('"')
282 }
283 html.push('>');
284 html.push_str(self.text.as_str());
285 html.push_str("</h2>");
286 html
287 }
288}
289
290pub struct H3 {
291 text: String,
292 class: String,
293 style: String,
294}
295
296impl H3 {
297 #[inline]
298 pub fn new(text: String) -> H3 {
299 H3 {
300 text,
301 class: String::new(),
302 style: String::new(),
303 }
304 }
305 #[inline]
306 pub fn class(mut self, class: String) -> H3 {
307 self.class = class;
308 self
309 }
310 #[inline]
311 pub fn style(mut self, style: String) -> H3 {
312 self.style = style;
313 self
314 }
315}
316
317impl Renderable for H3 {
318 fn render(self) -> String {
319 let mut html = String::new();
320 html.push_str("<h3");
321 if !self.class.is_empty() {
322 html.push_str(" class=\"");
323 html.push_str(self.class.as_str());
324 html.push('"')
325 }
326 if !self.style.is_empty() {
327 html.push_str(" style=\"");
328 html.push_str(self.style.as_str());
329 html.push('"')
330 }
331 html.push('>');
332 html.push_str(self.text.as_str());
333 html.push_str("</h3>");
334 html
335 }
336}