Skip to main content

basecoat_core/props/
alert.rs

1use crate::{AttrMap, BasecoatProps, Children};
2use std::borrow::Cow;
3
4/// Alert variant — maps to `.alert` or `.alert-destructive`.
5#[derive(Clone, Debug, PartialEq, Eq, Default)]
6pub enum AlertVariant {
7    #[default]
8    Default,
9    Destructive,
10}
11
12impl std::fmt::Display for AlertVariant {
13    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
14        let s = match self {
15            AlertVariant::Default => "alert",
16            AlertVariant::Destructive => "alert-destructive",
17        };
18        f.write_str(s)
19    }
20}
21
22#[derive(BasecoatProps, Default, Clone, Debug)]
23pub struct AlertProps {
24    #[prop(default)]
25    pub variant: AlertVariant,
26    #[prop(optional, into)]
27    pub class: Option<Cow<'static, str>>,
28    #[prop(extend)]
29    pub attrs: AttrMap,
30    pub children: Children,
31}