Skip to main content

damascene_core/tree/
icon_name.rs

1//! Built-in icon-name vocabulary.
2
3// Lock in full per-item documentation for this module (issue #73).
4#![warn(missing_docs)]
5
6/// Built-in icon names. The string forms intentionally mirror common
7/// lucide/shadcn names so agents can reach for familiar labels.
8#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[non_exhaustive]
10pub enum IconName {
11    /// A pulse/activity waveform.
12    Activity,
13    /// An exclamation mark in a circle; also rendered as the fallback for unknown string icon names.
14    AlertCircle,
15    /// Vertical bar-chart columns.
16    BarChart,
17    /// A notification bell.
18    Bell,
19    /// A checkmark; the stock checkbox's checked indicator.
20    Check,
21    /// A downward chevron; the stock select's dropdown indicator.
22    ChevronDown,
23    /// A leftward chevron; the stock calendar's previous-month button.
24    ChevronLeft,
25    /// A rightward chevron; the stock accordion's expand indicator and the calendar's next-month button.
26    ChevronRight,
27    /// An upward chevron.
28    ChevronUp,
29    /// The command (⌘) key symbol.
30    Command,
31    /// A download arrow.
32    Download,
33    /// A text-document outline.
34    FileText,
35    /// A folder outline.
36    Folder,
37    /// A git branch fork.
38    GitBranch,
39    /// A git commit dot on a line.
40    GitCommit,
41    /// An information "i" in a circle.
42    Info,
43    /// A dashboard grid of panels.
44    LayoutDashboard,
45    /// Three stacked lines (hamburger menu).
46    Menu,
47    /// A horizontal ellipsis for overflow/"more" actions.
48    MoreHorizontal,
49    /// A plus sign; the stock editor-tabs add-tab button.
50    Plus,
51    /// Clockwise refresh arrows.
52    RefreshCw,
53    /// A magnifying glass.
54    Search,
55    /// A gear.
56    Settings,
57    /// An upload arrow.
58    Upload,
59    /// A group of people silhouettes.
60    Users,
61    /// An "x" cross; the stock close button (e.g. editor-tab close).
62    X,
63}
64
65impl IconName {
66    /// Resolve a lucide/shadcn-style string name (e.g. `"chevron-down"`,
67    /// with a few aliases like `"close"` for `X`) to its variant, or
68    /// `None` if the name is not in the built-in vocabulary.
69    pub fn parse(name: &str) -> Option<Self> {
70        match name {
71            "activity" => Some(Self::Activity),
72            "alert-circle" | "alert" => Some(Self::AlertCircle),
73            "bar-chart" | "chart-bar" => Some(Self::BarChart),
74            "bell" => Some(Self::Bell),
75            "check" => Some(Self::Check),
76            "chevron-down" => Some(Self::ChevronDown),
77            "chevron-left" => Some(Self::ChevronLeft),
78            "chevron-right" => Some(Self::ChevronRight),
79            "chevron-up" => Some(Self::ChevronUp),
80            "command" => Some(Self::Command),
81            "download" => Some(Self::Download),
82            "file-text" | "file" => Some(Self::FileText),
83            "folder" => Some(Self::Folder),
84            "git-branch" => Some(Self::GitBranch),
85            "git-commit" => Some(Self::GitCommit),
86            "info" => Some(Self::Info),
87            "layout-dashboard" | "dashboard" => Some(Self::LayoutDashboard),
88            "menu" => Some(Self::Menu),
89            "more-horizontal" | "more" => Some(Self::MoreHorizontal),
90            "plus" => Some(Self::Plus),
91            "refresh-cw" | "refresh" => Some(Self::RefreshCw),
92            "search" => Some(Self::Search),
93            "settings" => Some(Self::Settings),
94            "upload" => Some(Self::Upload),
95            "users" => Some(Self::Users),
96            "x" | "close" => Some(Self::X),
97            _ => None,
98        }
99    }
100
101    /// The canonical lucide-style string name (the inverse of [`IconName::parse`],
102    /// modulo aliases).
103    pub fn name(self) -> &'static str {
104        match self {
105            Self::Activity => "activity",
106            Self::AlertCircle => "alert-circle",
107            Self::BarChart => "bar-chart",
108            Self::Bell => "bell",
109            Self::Check => "check",
110            Self::ChevronDown => "chevron-down",
111            Self::ChevronLeft => "chevron-left",
112            Self::ChevronRight => "chevron-right",
113            Self::ChevronUp => "chevron-up",
114            Self::Command => "command",
115            Self::Download => "download",
116            Self::FileText => "file-text",
117            Self::Folder => "folder",
118            Self::GitBranch => "git-branch",
119            Self::GitCommit => "git-commit",
120            Self::Info => "info",
121            Self::LayoutDashboard => "layout-dashboard",
122            Self::Menu => "menu",
123            Self::MoreHorizontal => "more-horizontal",
124            Self::Plus => "plus",
125            Self::RefreshCw => "refresh-cw",
126            Self::Search => "search",
127            Self::Settings => "settings",
128            Self::Upload => "upload",
129            Self::Users => "users",
130            Self::X => "x",
131        }
132    }
133
134    /// A single-character text stand-in for the icon, used where the
135    /// vector glyph cannot be drawn (e.g. text-only rendering paths).
136    pub fn fallback_glyph(self) -> &'static str {
137        match self {
138            Self::Activity => "~",
139            Self::AlertCircle => "!",
140            Self::BarChart => "▮",
141            Self::Bell => "•",
142            Self::Check => "✓",
143            Self::ChevronDown => "⌄",
144            Self::ChevronLeft => "‹",
145            Self::ChevronRight => "›",
146            Self::ChevronUp => "⌃",
147            Self::Command => "⌘",
148            Self::Download => "↓",
149            Self::FileText => "□",
150            Self::Folder => "▱",
151            Self::GitBranch => "⑂",
152            Self::GitCommit => "⊙",
153            Self::Info => "i",
154            Self::LayoutDashboard => "▦",
155            Self::Menu => "☰",
156            Self::MoreHorizontal => "…",
157            Self::Plus => "+",
158            Self::RefreshCw => "↻",
159            Self::Search => "⌕",
160            Self::Settings => "⚙",
161            Self::Upload => "↑",
162            Self::Users => "●",
163            Self::X => "×",
164        }
165    }
166}