use crate::{AttrMap, BasecoatProps, Children, Markup};
use std::borrow::Cow;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum PopoverPlacement {
Top,
TopStart,
TopEnd,
#[default]
Bottom,
BottomStart,
BottomEnd,
Left,
LeftStart,
LeftEnd,
Right,
RightStart,
RightEnd,
}
impl PopoverPlacement {
pub fn as_str(&self) -> &'static str {
match self {
PopoverPlacement::Top => "top",
PopoverPlacement::TopStart => "top-start",
PopoverPlacement::TopEnd => "top-end",
PopoverPlacement::Bottom => "bottom",
PopoverPlacement::BottomStart => "bottom-start",
PopoverPlacement::BottomEnd => "bottom-end",
PopoverPlacement::Left => "left",
PopoverPlacement::LeftStart => "left-start",
PopoverPlacement::LeftEnd => "left-end",
PopoverPlacement::Right => "right",
PopoverPlacement::RightStart => "right-start",
PopoverPlacement::RightEnd => "right-end",
}
}
}
impl std::fmt::Display for PopoverPlacement {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[derive(BasecoatProps, Default, Clone, Debug)]
pub struct PopoverProps {
#[prop(optional, into)]
pub id: Option<Cow<'static, str>>,
#[prop(optional)]
pub trigger: Option<Markup>,
#[prop(default)]
pub placement: PopoverPlacement,
#[prop(default = 8.0)]
pub offset_px: f64,
#[prop(default = false)]
pub arrow: bool,
#[prop(optional, into)]
pub class: Option<Cow<'static, str>>,
#[prop(extend)]
pub attrs: AttrMap,
pub children: Children,
}