windjammer_ui/components/generated/
alert.rs

1#![allow(clippy::all)]
2#![allow(noop_method_call)]
3use super::traits::Renderable;
4
5pub enum AlertVariant {
6    Error,
7    Warning,
8    Info,
9    Success,
10}
11
12pub struct Alert {
13    message: String,
14    variant: AlertVariant,
15}
16
17impl Alert {
18    #[inline]
19    pub fn error(message: String) -> Alert {
20        Alert {
21            message,
22            variant: AlertVariant::Error,
23        }
24    }
25    #[inline]
26    pub fn warning(message: String) -> Alert {
27        Alert {
28            message,
29            variant: AlertVariant::Warning,
30        }
31    }
32    #[inline]
33    pub fn info(message: String) -> Alert {
34        Alert {
35            message,
36            variant: AlertVariant::Info,
37        }
38    }
39    #[inline]
40    pub fn success(message: String) -> Alert {
41        Alert {
42            message,
43            variant: AlertVariant::Success,
44        }
45    }
46}
47
48impl Renderable for Alert {
49    #[inline]
50    fn render(self) -> String {
51        let variant_class = match self.variant {
52            AlertVariant::Error => "wj-alert-error",
53            AlertVariant::Warning => "wj-alert-warning",
54            AlertVariant::Info => "wj-alert-info",
55            AlertVariant::Success => "wj-alert-success",
56        };
57        let icon = match self.variant {
58            AlertVariant::Error => "❌",
59            AlertVariant::Warning => "⚠️",
60            AlertVariant::Info => "ℹ️",
61            AlertVariant::Success => "✅",
62        };
63        format!(
64            "<div class='wj-alert {}'>{} {}</div>",
65            variant_class, icon, self.message
66        )
67    }
68}