1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
use crate::Button;
use dioxus::prelude::*;
use freya_elements::elements as dioxus_elements;
use freya_hooks::{theme_with, ButtonThemeWith};

#[allow(non_snake_case)]
#[component]
pub fn PopupBackground(children: Element) -> Element {
    rsx!(rect {
        height: "100v",
        width: "100v",
        background: "rgb(0, 0, 0, 150)",
        position: "absolute",
        position_top: "0",
        position_left: "0",
        layer: "-1",
        main_align: "center",
        cross_align: "center",
        {children}
    })
}

#[allow(non_snake_case)]
#[component]
pub fn Popup(
    children: Element,
    #[props(default = "325".into(), into)] width: String,
    #[props(default = "225".into(), into)] height: String,

    on_close_request: Option<EventHandler>,
) -> Element {
    rsx!(
        PopupBackground {
            rect {
                padding: "14",
                corner_radius: "8",
                background: "white",
                shadow: "0 4 5 0 rgb(0, 0, 0, 30)",
                width: "{width}",
                height: "{height}",
                rect {
                    position: "absolute",
                    position_right: "0",
                    width: "30",
                    Button {
                        theme: theme_with!(ButtonTheme {
                            padding: "6".into(),
                            margin: "0".into(),
                            width: "30".into(),
                            height: "30".into(),
                            corner_radius: "999".into(),
                        }),
                        onclick: move |_| if let Some(on_close_request) = &on_close_request {
                            on_close_request.call(());
                        },
                        label {
                            font_size: "14",
                            "X"
                        }
                    }
                }
                {children}
            }
        }
    )
}

#[allow(non_snake_case)]
#[component]
pub fn PopupTitle(children: Element) -> Element {
    rsx!(
        rect {
            font_size: "18",
            margin: "4 2 8 2",
            font_weight: "bold",
            {children}
        }
    )
}

#[allow(non_snake_case)]
#[component]
pub fn PopupContent(children: Element) -> Element {
    rsx!(
        rect {
            font_size: "15",
            margin: "6 2",
            color: "rgb(20, 20, 20)",
            {children}
        }
    )
}