windjammer_ui/components/generated/
scroll.rs

1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3pub struct Scroll {
4    children: Vec<String>,
5    direction: ScrollDir,
6    height: String,
7    width: String,
8    class: String,
9}
10
11pub enum ScrollDir {
12    Vertical,
13    Horizontal,
14    Both,
15    None,
16}
17
18impl Scroll {
19    #[inline]
20    pub fn new() -> Scroll {
21        Scroll {
22            children: Vec::new(),
23            direction: ScrollDir::Vertical,
24            height: "400px".to_string(),
25            width: "100%".to_string(),
26            class: String::new(),
27        }
28    }
29    #[inline]
30    pub fn child(mut self, child: String) -> Scroll {
31        self.children.push(child);
32        self
33    }
34    #[inline]
35    pub fn direction(mut self, direction: ScrollDir) -> Scroll {
36        self.direction = direction;
37        self
38    }
39    #[inline]
40    pub fn height(mut self, height: String) -> Scroll {
41        self.height = height;
42        self
43    }
44    #[inline]
45    pub fn width(mut self, width: String) -> Scroll {
46        self.width = width;
47        self
48    }
49    #[inline]
50    pub fn class(mut self, class: String) -> Scroll {
51        self.class = class;
52        self
53    }
54    pub fn render(&self) -> String {
55        let overflow = match self.direction {
56            ScrollDir::Vertical => "overflow-x: hidden; overflow-y: auto",
57            ScrollDir::Horizontal => "overflow-x: auto; overflow-y: hidden",
58            ScrollDir::Both => "overflow: auto",
59            ScrollDir::None => "overflow: hidden",
60        };
61        let mut html = String::new();
62        html.push_str("<div class=\"wj-scroll ");
63        html.push_str(self.class.as_str());
64        html.push_str("\" style=\"");
65        html.push_str(overflow);
66        html.push_str("; height: ");
67        html.push_str(self.height.as_str());
68        html.push_str("; width: ");
69        html.push_str(self.width.as_str());
70        html.push_str(";\">");
71        for child in self.children.iter() {
72            html.push_str(child.as_str());
73        }
74        html.push_str("</div>");
75        html
76    }
77}