windjammer_ui/components/generated/
card.rs

1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3use std::fmt::Write;
4
5use super::traits::Renderable;
6
7#[derive(Debug, Clone, PartialEq, Eq, Default)]
8pub struct Card {
9    pub title: String,
10    pub children: Vec<String>,
11    pub padding: String,
12    pub background_color: String,
13    pub border_color: String,
14}
15
16impl Card {
17    #[inline]
18    pub fn new() -> Card {
19        Card {
20            title: "".to_string(),
21            children: Vec::new(),
22            padding: "16px".to_string(),
23            background_color: "#fff".to_string(),
24            border_color: "#e0e0e0".to_string(),
25        }
26    }
27    #[inline]
28    pub fn title(mut self, title: String) -> Card {
29        self.title = title;
30        self
31    }
32    #[inline]
33    pub fn child(mut self, child: String) -> Card {
34        self.children.push(child);
35        self
36    }
37    #[inline]
38    pub fn children(mut self, children: Vec<String>) -> Card {
39        self.children = children;
40        self
41    }
42    #[inline]
43    pub fn padding(mut self, padding: String) -> Card {
44        self.padding = padding;
45        self
46    }
47    #[inline]
48    pub fn background_color(mut self, color: String) -> Card {
49        self.background_color = color;
50        self
51    }
52    #[inline]
53    pub fn border_color(mut self, color: String) -> Card {
54        self.border_color = color;
55        self
56    }
57}
58
59impl Renderable for Card {
60    #[inline]
61    fn render(self) -> String {
62        let style = {
63            let mut __s = String::with_capacity(64);
64            write!(
65                &mut __s,
66                "padding: {}; background-color: {}; border: 1px solid {}; border-radius: 8px;",
67                self.padding, self.background_color, self.border_color
68            )
69            .unwrap();
70            __s
71        };
72        let title_html = {
73            if self.title != "" {
74                {
75                    let mut __s = String::with_capacity(64);
76                    write!(&mut __s, "<div class='wj-card-title' style='font-weight: bold; margin-bottom: 12px; font-size: 1.25rem;'>{}</div>", self.title).unwrap();
77                    __s
78                }
79            } else {
80                "".to_string()
81            }
82        };
83        let children_html = self.children.join(
84            "
85",
86        );
87        format!(
88            "<div class='wj-card' style='{}'>
89{}{}
90</div>",
91            style, title_html, children_html
92        )
93    }
94}