windjammer_ui/components/generated/
list.rs

1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3#[derive(Debug, Clone, PartialEq, Eq, Default)]
4pub struct List {
5    pub items: Vec<String>,
6    pub ordered: bool,
7    pub class: String,
8}
9
10impl List {
11    #[inline]
12    pub fn new() -> List {
13        List {
14            items: Vec::new(),
15            ordered: false,
16            class: String::new(),
17        }
18    }
19    #[inline]
20    pub fn item(mut self, item: String) -> List {
21        self.items.push(item);
22        self
23    }
24    #[inline]
25    pub fn ordered(mut self, ordered: bool) -> List {
26        self.ordered = ordered;
27        self
28    }
29    #[inline]
30    pub fn class(mut self, class: String) -> List {
31        self.class = class;
32        self
33    }
34    #[inline]
35    pub fn render(&self) -> String {
36        let tag = {
37            if self.ordered {
38                "ol".to_string()
39            } else {
40                "ul".to_string()
41            }
42        };
43        let mut html = String::new();
44        html.push('<');
45        html.push_str(&tag.clone());
46        html.push_str(" class=\"wj-list ");
47        html.push_str(&self.class.as_str());
48        html.push_str("\" style=\"list-style-position: inside; padding-left: 0;\">");
49        for item in &self.items {
50            html.push_str("<li style=\"padding: 8px 0;\">");
51            html.push_str(&item.as_str());
52            html.push_str("</li>");
53        }
54        html.push_str("</");
55        html.push_str(&tag);
56        html.push('>');
57        html
58    }
59}
60
61#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
62pub struct ListItem {
63    pub content: String,
64    pub class: String,
65}
66
67impl ListItem {
68    #[inline]
69    pub fn new(content: String) -> ListItem {
70        ListItem {
71            content,
72            class: String::new(),
73        }
74    }
75    #[inline]
76    pub fn class(mut self, class: String) -> ListItem {
77        self.class = class;
78        self
79    }
80    #[inline]
81    pub fn render(&self) -> String {
82        let mut html = String::new();
83        html.push_str("<li class=\"wj-list-item ");
84        html.push_str(&self.class.as_str());
85        html.push_str("\" style=\"padding: 8px 0;\">");
86        html.push_str(&self.content.as_str());
87        html.push_str("</li>");
88        html
89    }
90}