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