Skip to main content

fret_ui_kit/style/
vocab.rs

1use fret_ui::element::{CrossAlign, MainAlign, Overflow};
2
3/// Tailwind-like `justify-*` vocabulary (component-layer).
4///
5/// This exists to avoid leaking runtime enums into recipes.
6#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum Justify {
8    Start,
9    Center,
10    End,
11    Between,
12    Around,
13    Evenly,
14}
15
16impl Justify {
17    pub fn to_main_align(self) -> MainAlign {
18        match self {
19            Self::Start => MainAlign::Start,
20            Self::Center => MainAlign::Center,
21            Self::End => MainAlign::End,
22            Self::Between => MainAlign::SpaceBetween,
23            Self::Around => MainAlign::SpaceAround,
24            Self::Evenly => MainAlign::SpaceEvenly,
25        }
26    }
27}
28
29/// Tailwind-like `items-*` vocabulary (component-layer).
30///
31/// This exists to avoid leaking runtime enums into recipes.
32#[derive(Debug, Clone, Copy, PartialEq, Eq)]
33pub enum Items {
34    Start,
35    Center,
36    End,
37    Stretch,
38}
39
40impl Items {
41    pub fn to_cross_align(self) -> CrossAlign {
42        match self {
43            Self::Start => CrossAlign::Start,
44            Self::Center => CrossAlign::Center,
45            Self::End => CrossAlign::End,
46            Self::Stretch => CrossAlign::Stretch,
47        }
48    }
49}
50
51/// Tailwind-like overflow vocabulary (component-layer).
52///
53/// Note: Fret deliberately separates clipping (`overflow_hidden`) from scrolling (explicit `Scroll`).
54#[derive(Debug, Clone, Copy, PartialEq, Eq)]
55pub enum OverflowRefinement {
56    Visible,
57    Hidden,
58}
59
60impl OverflowRefinement {
61    pub fn to_overflow(self) -> Overflow {
62        match self {
63            Self::Visible => Overflow::Visible,
64            Self::Hidden => Overflow::Clip,
65        }
66    }
67}