Skip to main content

impulse_thaw/persona/
types.rs

1use leptos::prelude::*;
2
3#[slot]
4pub struct PersonaPrimaryText {
5    children: Children,
6}
7
8#[slot]
9pub struct PersonaSecondaryText {
10    children: Children,
11}
12
13#[slot]
14pub struct PersonaTertiaryText {
15    children: Children,
16}
17
18#[slot]
19pub struct PersonaQuaternaryText {
20    children: Children,
21}
22
23#[derive(Debug, Default, Clone, PartialEq)]
24pub enum PersonaTextAlignment {
25    #[default]
26    Start,
27    Center,
28}
29
30impl PersonaTextAlignment {
31    pub fn as_str(&self) -> &'static str {
32        match self {
33            Self::Start => "start",
34            Self::Center => "center",
35        }
36    }
37}
38
39#[derive(Debug, Default, Clone, PartialEq)]
40pub enum PersonaTextPosition {
41    Before,
42    #[default]
43    After,
44    Below,
45}
46
47impl PersonaTextPosition {
48    pub fn as_str(&self) -> &'static str {
49        match self {
50            Self::Before => "before",
51            Self::After => "after",
52            Self::Below => "below",
53        }
54    }
55}
56
57#[derive(Debug, Default, Clone, PartialEq)]
58pub enum PersonaSize {
59    ExtraSmall,
60    Small,
61    #[default]
62    Medium,
63    Large,
64    ExtraLarge,
65    Huge,
66}
67
68impl PersonaSize {
69    pub(crate) fn as_avatar_size(&self) -> u8 {
70        match self {
71            Self::ExtraSmall => 20,
72            Self::Small => 28,
73            Self::Medium => 32,
74            Self::Large => 36,
75            Self::ExtraLarge => 40,
76            Self::Huge => 56,
77        }
78    }
79
80    pub fn as_str(&self) -> &'static str {
81        match self {
82            Self::ExtraSmall => "extra-small",
83            Self::Small => "small",
84            Self::Medium => "medium",
85            Self::Large => "large",
86            Self::ExtraLarge => "extra-large",
87            Self::Huge => "huge",
88        }
89    }
90}