windjammer_ui/components/generated/
tooltip.rs

1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3use super::traits::Renderable;
4
5pub enum TooltipPosition {
6    Top,
7    Bottom,
8    Left,
9    Right,
10}
11
12pub struct Tooltip {
13    text: String,
14    position: TooltipPosition,
15    child: String,
16}
17
18impl Tooltip {
19    #[inline]
20    pub fn new(text: String, child: String) -> Tooltip {
21        Tooltip {
22            text,
23            position: TooltipPosition::Top,
24            child,
25        }
26    }
27    #[inline]
28    pub fn position(mut self, position: TooltipPosition) -> Tooltip {
29        self.position = position;
30        self
31    }
32}
33
34impl Renderable for Tooltip {
35    #[inline]
36    fn render(self) -> String {
37        let position_class = match self.position {
38            TooltipPosition::Top => "wj-tooltip-top",
39            TooltipPosition::Bottom => "wj-tooltip-bottom",
40            TooltipPosition::Left => "wj-tooltip-left",
41            TooltipPosition::Right => "wj-tooltip-right",
42        };
43        format!(
44            "<div class='wj-tooltip-container {}'>{}<span class='wj-tooltip-text'>{}</span></div>",
45            position_class, self.child, self.text
46        )
47    }
48}