windjammer_ui/components/generated/
label.rs1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3pub struct Label {
4 text: String,
5 for_id: String,
6 required: bool,
7 class: String,
8}
9
10impl Label {
11 #[inline]
12 pub fn new(text: String) -> Label {
13 Label {
14 text,
15 for_id: String::new(),
16 required: false,
17 class: String::new(),
18 }
19 }
20 #[inline]
21 pub fn for_id(mut self, for_id: String) -> Label {
22 self.for_id = for_id;
23 self
24 }
25 #[inline]
26 pub fn required(mut self, required: bool) -> Label {
27 self.required = required;
28 self
29 }
30 #[inline]
31 pub fn class(mut self, class: String) -> Label {
32 self.class = class;
33 self
34 }
35 pub fn render(&self) -> String {
36 let mut html = String::new();
37 html.push_str("<label class=\"wj-label ");
38 html.push_str(self.class.as_str());
39 html.push_str("\" style=\"font-weight: 500; font-size: 14px; color: #374151; display: block; margin-bottom: 4px;\"");
40 if !self.for_id.is_empty() {
41 html.push_str(" for=\"");
42 html.push_str(self.for_id.as_str());
43 html.push('"')
44 }
45 html.push('>');
46 html.push_str(self.text.as_str());
47 if self.required {
48 html.push_str("<span style=\"color: #ef4444; margin-left: 4px;\">*</span>")
49 }
50 html.push_str("</label>");
51 html
52 }
53}