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