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