Skip to main content

orbital_base_components/spacing/
token.rs

1/// Horizontal spacing tokens from the active theme (`--orb-space-inline-*`).
2#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
3pub enum SpacingHorizontal {
4    None,
5    XXS,
6    XS,
7    SNudge,
8    S,
9    MNudge,
10    #[default]
11    M,
12    L,
13    XL,
14    XXL,
15    XXXL,
16}
17
18impl SpacingHorizontal {
19    pub fn css_var(self) -> &'static str {
20        match self {
21            Self::None => "var(--orb-space-inline-none)",
22            Self::XXS => "var(--orb-space-inline-2xs)",
23            Self::XS => "var(--orb-space-inline-xs)",
24            Self::SNudge => "var(--orb-space-inline-snudge)",
25            Self::S => "var(--orb-space-inline-sm)",
26            Self::MNudge => "var(--orb-space-inline-mnudge)",
27            Self::M => "var(--orb-space-inline-md)",
28            Self::L => "var(--orb-space-inline-lg)",
29            Self::XL => "var(--orb-space-inline-xl)",
30            Self::XXL => "var(--orb-space-inline-2xl)",
31            Self::XXXL => "var(--orb-space-inline-3xl)",
32        }
33    }
34}
35
36/// Vertical spacing tokens from the active theme (`--orb-space-block-*`).
37#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
38pub enum SpacingVertical {
39    None,
40    XXS,
41    XS,
42    SNudge,
43    S,
44    MNudge,
45    #[default]
46    M,
47    L,
48    XL,
49    XXL,
50    XXXL,
51}
52
53impl SpacingVertical {
54    pub fn css_var(self) -> &'static str {
55        match self {
56            Self::None => "var(--orb-space-block-none)",
57            Self::XXS => "var(--orb-space-block-2xs)",
58            Self::XS => "var(--orb-space-block-xs)",
59            Self::SNudge => "var(--orb-space-block-snudge)",
60            Self::S => "var(--orb-space-block-sm)",
61            Self::MNudge => "var(--orb-space-block-mnudge)",
62            Self::M => "var(--orb-space-block-md)",
63            Self::L => "var(--orb-space-block-lg)",
64            Self::XL => "var(--orb-space-block-xl)",
65            Self::XXL => "var(--orb-space-block-2xl)",
66            Self::XXXL => "var(--orb-space-block-3xl)",
67        }
68    }
69}