windjammer_ui/components/generated/
text.rs1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3use super::traits::Renderable;
4
5pub enum TextSize {
6 Small,
7 Medium,
8 Large,
9 XLarge,
10}
11
12pub enum TextWeight {
13 Normal,
14 Bold,
15}
16
17pub struct Text {
18 content: String,
19 size: TextSize,
20 weight: TextWeight,
21}
22
23impl Text {
24 #[inline]
25 pub fn new(content: String) -> Text {
26 Text {
27 content,
28 size: TextSize::Medium,
29 weight: TextWeight::Normal,
30 }
31 }
32 #[inline]
33 pub fn size(mut self, size: TextSize) -> Text {
34 self.size = size;
35 self
36 }
37 #[inline]
38 pub fn bold(mut self) -> Text {
39 self.weight = TextWeight::Bold;
40 self
41 }
42}
43
44impl Renderable for Text {
45 #[inline]
46 fn render(self) -> String {
47 let size_class = match self.size {
48 TextSize::Small => "sm",
49 TextSize::Medium => "md",
50 TextSize::Large => "lg",
51 TextSize::XLarge => "xl",
52 };
53 let weight_class = match self.weight {
54 TextWeight::Normal => "normal",
55 TextWeight::Bold => "bold",
56 };
57 format!(
58 "<span class='wj-text {} {}'>{}</span>",
59 size_class, weight_class, self.content
60 )
61 }
62}