Skip to main content

euv_ui/component/icon/view/
struct.rs

1use super::*;
2
3/// The size scale of the `euv_icon` component.
4///
5/// The steps match the shared monochrome type scale: an icon is a glyph, so it
6/// never carries colour — only the foreground token, inherited by the class.
7#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
8pub enum EuvIconSize {
9    /// A 12px glyph for inline hints and metadata rows.
10    Xs,
11    /// A 16px glyph for dense rows and button-adjacent marks.
12    Sm,
13    /// A 20px glyph, the default size for inline body content.
14    #[default]
15    Md,
16    /// A 24px glyph for section headers and empty-state marks.
17    Lg,
18    /// A 32px glyph for hero and page-header glyphs.
19    Xl,
20}
21
22impl EuvIconSize {
23    /// Returns the glyph edge length in pixels for this size.
24    ///
25    /// # Returns
26    ///
27    /// - `i32` - The edge length in pixels: 12 for `Xs`, 16 for `Sm`, 20 for
28    ///   `Md`, 24 for `Lg`, 32 for `Xl`.
29    pub fn px(&self) -> i32 {
30        match self {
31            EuvIconSize::Xs => 12,
32            EuvIconSize::Sm => 16,
33            EuvIconSize::Md => 20,
34            EuvIconSize::Lg => 24,
35            EuvIconSize::Xl => 32,
36        }
37    }
38}
39
40/// Props for the `euv_icon` component.
41///
42/// Defines the strongly-typed interface for a monochrome glyph wrapper. The
43/// `name` prop carries the glyph itself (an emoji or a text symbol) — the
44/// design system has no icon font and no coloured icon set.
45#[derive(Clone, CustomDebug, Default)]
46pub struct EuvIconProps {
47    /// The glyph text rendered as the icon content.
48    pub name: &'static str,
49    /// The accessible label. When empty the icon is treated as decorative.
50    pub label: &'static str,
51    /// The size of the glyph.
52    pub size: EuvIconSize,
53}