windjammer_ui/components/generated/
dialog.rs1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3use super::traits::Renderable;
4
5#[derive(Debug, Clone, PartialEq, Eq, Hash, Default)]
6pub struct Dialog {
7 pub title: String,
8 pub content: String,
9 pub open: bool,
10 pub width: String,
11}
12
13impl Dialog {
14 #[inline]
15 pub fn new(title: String, content: String) -> Dialog {
16 Dialog {
17 title,
18 content,
19 open: false,
20 width: "500px".to_string(),
21 }
22 }
23 #[inline]
24 pub fn open(mut self, open: bool) -> Dialog {
25 self.open = open;
26 self
27 }
28 #[inline]
29 pub fn width(mut self, width: String) -> Dialog {
30 self.width = width;
31 self
32 }
33}
34
35impl Renderable for Dialog {
36 #[inline]
37 fn render(self) -> String {
38 let display_style = {
39 if self.open {
40 "display: flex;".to_string()
41 } else {
42 "display: none;".to_string()
43 }
44 };
45 format!(
46 "<div class='wj-dialog-overlay' style='{}'>
47 <div class='wj-dialog' style='max-width: {}; width: 90%;'>
48 <div class='wj-dialog-header'>
49 <h2>{}</h2>
50 <button class='wj-dialog-close'>×</button>
51 </div>
52 <div class='wj-dialog-content'>
53 {}
54 </div>
55 </div>
56</div>",
57 display_style, self.width, self.title, self.content
58 )
59 }
60}