Skip to main content

impulse_thaw/popover/
types.rs

1use leptos::prelude::*;
2use thaw_components::FollowerPlacement;
3
4#[derive(Debug, Default, Clone)]
5pub enum PopoverSize {
6    Small,
7    #[default]
8    Medium,
9    Large,
10}
11
12impl PopoverSize {
13    pub fn as_str(&self) -> &'static str {
14        match self {
15            Self::Small => "small",
16            Self::Medium => "medium",
17            Self::Large => "large",
18        }
19    }
20}
21
22#[derive(Clone)]
23pub enum PopoverAppearance {
24    Brand,
25    Inverted,
26}
27
28impl PopoverAppearance {
29    pub fn as_str(&self) -> &'static str {
30        match self {
31            PopoverAppearance::Brand => "brand",
32            PopoverAppearance::Inverted => "inverted",
33        }
34    }
35}
36
37#[derive(Default, PartialEq, Clone)]
38pub enum PopoverTriggerType {
39    #[default]
40    Hover,
41    Click,
42}
43
44impl Copy for PopoverTriggerType {}
45
46#[derive(Default)]
47pub enum PopoverPosition {
48    #[default]
49    Top,
50    Bottom,
51    Left,
52    Right,
53    TopStart,
54    TopEnd,
55    LeftStart,
56    LeftEnd,
57    RightStart,
58    RightEnd,
59    BottomStart,
60    BottomEnd,
61}
62
63impl From<PopoverPosition> for FollowerPlacement {
64    fn from(value: PopoverPosition) -> Self {
65        match value {
66            PopoverPosition::Top => Self::Top,
67            PopoverPosition::Bottom => Self::Bottom,
68            PopoverPosition::Left => Self::Left,
69            PopoverPosition::Right => Self::Right,
70            PopoverPosition::TopStart => Self::TopStart,
71            PopoverPosition::TopEnd => Self::TopEnd,
72            PopoverPosition::LeftStart => Self::LeftStart,
73            PopoverPosition::LeftEnd => Self::LeftEnd,
74            PopoverPosition::RightStart => Self::RightStart,
75            PopoverPosition::RightEnd => Self::RightEnd,
76            PopoverPosition::BottomStart => Self::BottomStart,
77            PopoverPosition::BottomEnd => Self::BottomEnd,
78        }
79    }
80}
81
82#[slot]
83pub struct PopoverTrigger<T> {
84    children: TypedChildren<T>,
85}