windjammer_ui/components/generated/
divider.rs1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3use super::traits::Renderable;
4
5#[derive(Clone, Debug, PartialEq, Copy)]
6pub enum DividerOrientation {
7 Horizontal,
8 Vertical,
9}
10
11#[derive(Debug, Clone, PartialEq)]
12pub struct Divider {
13 pub orientation: DividerOrientation,
14 pub color: String,
15 pub thickness: String,
16 pub margin: String,
17}
18
19impl Divider {
20 #[inline]
21 pub fn new() -> Divider {
22 Divider {
23 orientation: DividerOrientation::Horizontal,
24 color: "#3E3E3E".to_string(),
25 thickness: "1px".to_string(),
26 margin: "0".to_string(),
27 }
28 }
29 #[inline]
30 pub fn horizontal() -> Divider {
31 Divider::new()
32 }
33 #[inline]
34 pub fn vertical() -> Divider {
35 Divider {
36 orientation: DividerOrientation::Vertical,
37 color: "#3E3E3E".to_string(),
38 thickness: "1px".to_string(),
39 margin: "0".to_string(),
40 }
41 }
42 #[inline]
43 pub fn color(mut self, color: String) -> Divider {
44 self.color = color;
45 self
46 }
47 #[inline]
48 pub fn thickness(mut self, thickness: String) -> Divider {
49 self.thickness = thickness;
50 self
51 }
52 #[inline]
53 pub fn margin(mut self, margin: String) -> Divider {
54 self.margin = margin;
55 self
56 }
57}
58
59impl Renderable for Divider {
60 #[inline]
61 fn render(self) -> String {
62 let orientation_class = match self.orientation {
63 DividerOrientation::Horizontal => "wj-divider-horizontal".to_string(),
64 DividerOrientation::Vertical => "wj-divider-vertical".to_string(),
65 };
66 let style = match self.orientation {
67 DividerOrientation::Horizontal => {
68 format!(
69 "width: 100%; height: {}; background: {}; margin: {} 0;",
70 self.thickness, self.color, self.margin
71 )
72 }
73 DividerOrientation::Vertical => {
74 format!(
75 "width: {}; height: 100%; background: {}; margin: 0 {};",
76 self.thickness, self.color, self.margin
77 )
78 }
79 };
80 format!(
81 "<div class='wj-divider {}' style='{}'></div>",
82 orientation_class, style
83 )
84 }
85}