windjammer_ui/components/generated/
popover.rs1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3#[derive(Debug, Clone, PartialEq)]
4pub struct Popover {
5 pub trigger: String,
6 pub content: String,
7 pub position: PopoverPosition,
8 pub class: String,
9}
10
11#[derive(Clone, Debug, PartialEq, Copy)]
12pub enum PopoverPosition {
13 Top,
14 Bottom,
15 Left,
16 Right,
17}
18
19impl Popover {
20 #[inline]
21 pub fn new(trigger: String, content: String) -> Popover {
22 Popover {
23 trigger,
24 content,
25 position: PopoverPosition::Bottom,
26 class: String::new(),
27 }
28 }
29 #[inline]
30 pub fn position(mut self, position: PopoverPosition) -> Popover {
31 self.position = position;
32 self
33 }
34 #[inline]
35 pub fn class(mut self, class: String) -> Popover {
36 self.class = class;
37 self
38 }
39 #[inline]
40 pub fn render(&self) -> String {
41 let position_style = match self.position {
42 PopoverPosition::Top => {
43 "bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 8px;"
44 .to_string()
45 }
46 PopoverPosition::Bottom => {
47 "top: 100%; left: 50%; transform: translateX(-50%); margin-top: 8px;".to_string()
48 }
49 PopoverPosition::Left => {
50 "right: 100%; top: 50%; transform: translateY(-50%); margin-right: 8px;".to_string()
51 }
52 PopoverPosition::Right => {
53 "left: 100%; top: 50%; transform: translateY(-50%); margin-left: 8px;".to_string()
54 }
55 };
56 let mut html = String::new();
57 html.push_str("<div class=\"wj-popover ");
58 html.push_str(&self.class.as_str());
59 html.push_str("\" style=\"position: relative; display: inline-block;\">");
60 html.push_str(&self.trigger.as_str());
61 html.push_str("<div class=\"wj-popover-content\" style=\"position: absolute; ");
62 html.push_str(&position_style);
63 html.push_str(" background: white; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); min-width: 200px; z-index: 1000; display: none;\">");
64 html.push_str(&self.content.as_str());
65 html.push_str("</div>");
66 html.push_str("</div>");
67 html.push_str("<style>.wj-popover:hover .wj-popover-content { display: block; }</style>");
68 html
69 }
70}