Skip to main content

euv_ui/component/space/view/
struct.rs

1use super::*;
2
3/// The spacing step of the `euv_space` component.
4///
5/// Each step maps to a design token rather than a hardcoded pixel value, so
6/// the gap follows the theme's spacing scale.
7#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
8pub enum EuvSpaceSize {
9    /// The tightest step, for separating an icon from its label.
10    Xs,
11    /// A small step, for list items and inline groups.
12    Sm,
13    /// The default step, for sibling blocks inside a section.
14    #[default]
15    Md,
16    /// A large step, for separating section groups.
17    Lg,
18    /// The largest step, for separating top-level page regions.
19    Xl,
20}
21
22impl EuvSpaceSize {
23    /// Returns the name of the design token backing this step.
24    ///
25    /// The returned name is the token key without the `--` prefix, ready to be
26    /// passed to [`var!`]; the caller resolves it to a `var(--token)`
27    /// reference rather than hardcoding a pixel value.
28    ///
29    /// # Returns
30    ///
31    /// - `&'static str` - The design token name: `space-xs`, `space-sm`,
32    ///   `space-md`, `space-lg`, or `space-xl`.
33    pub fn token(&self) -> &'static str {
34        match self {
35            EuvSpaceSize::Xs => "space-xs",
36            EuvSpaceSize::Sm => "space-sm",
37            EuvSpaceSize::Md => "space-md",
38            EuvSpaceSize::Lg => "space-lg",
39            EuvSpaceSize::Xl => "space-xl",
40        }
41    }
42}
43
44/// Props for the `euv_space` component.
45///
46/// Defines the strongly-typed interface for the layout gap primitive.
47#[derive(Clone, CustomDebug, Default)]
48pub struct EuvSpaceProps {
49    /// The spacing step taken from the design token scale.
50    pub size: EuvSpaceSize,
51    /// Whether the gap is applied vertically (`margin-top`) instead of
52    /// horizontally (`margin-left`).
53    pub vertical: Signal<bool>,
54}