1#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
6#[non_exhaustive]
7pub enum IconName {
8 Activity,
9 AlertCircle,
10 BarChart,
11 Bell,
12 Check,
13 ChevronDown,
14 ChevronLeft,
15 ChevronRight,
16 ChevronUp,
17 Command,
18 Download,
19 FileText,
20 Folder,
21 GitBranch,
22 GitCommit,
23 Info,
24 LayoutDashboard,
25 Menu,
26 MoreHorizontal,
27 Plus,
28 RefreshCw,
29 Search,
30 Settings,
31 Upload,
32 Users,
33 X,
34}
35
36impl IconName {
37 pub fn parse(name: &str) -> Option<Self> {
38 match name {
39 "activity" => Some(Self::Activity),
40 "alert-circle" | "alert" => Some(Self::AlertCircle),
41 "bar-chart" | "chart-bar" => Some(Self::BarChart),
42 "bell" => Some(Self::Bell),
43 "check" => Some(Self::Check),
44 "chevron-down" => Some(Self::ChevronDown),
45 "chevron-left" => Some(Self::ChevronLeft),
46 "chevron-right" => Some(Self::ChevronRight),
47 "chevron-up" => Some(Self::ChevronUp),
48 "command" => Some(Self::Command),
49 "download" => Some(Self::Download),
50 "file-text" | "file" => Some(Self::FileText),
51 "folder" => Some(Self::Folder),
52 "git-branch" => Some(Self::GitBranch),
53 "git-commit" => Some(Self::GitCommit),
54 "info" => Some(Self::Info),
55 "layout-dashboard" | "dashboard" => Some(Self::LayoutDashboard),
56 "menu" => Some(Self::Menu),
57 "more-horizontal" | "more" => Some(Self::MoreHorizontal),
58 "plus" => Some(Self::Plus),
59 "refresh-cw" | "refresh" => Some(Self::RefreshCw),
60 "search" => Some(Self::Search),
61 "settings" => Some(Self::Settings),
62 "upload" => Some(Self::Upload),
63 "users" => Some(Self::Users),
64 "x" | "close" => Some(Self::X),
65 _ => None,
66 }
67 }
68
69 pub fn name(self) -> &'static str {
70 match self {
71 Self::Activity => "activity",
72 Self::AlertCircle => "alert-circle",
73 Self::BarChart => "bar-chart",
74 Self::Bell => "bell",
75 Self::Check => "check",
76 Self::ChevronDown => "chevron-down",
77 Self::ChevronLeft => "chevron-left",
78 Self::ChevronRight => "chevron-right",
79 Self::ChevronUp => "chevron-up",
80 Self::Command => "command",
81 Self::Download => "download",
82 Self::FileText => "file-text",
83 Self::Folder => "folder",
84 Self::GitBranch => "git-branch",
85 Self::GitCommit => "git-commit",
86 Self::Info => "info",
87 Self::LayoutDashboard => "layout-dashboard",
88 Self::Menu => "menu",
89 Self::MoreHorizontal => "more-horizontal",
90 Self::Plus => "plus",
91 Self::RefreshCw => "refresh-cw",
92 Self::Search => "search",
93 Self::Settings => "settings",
94 Self::Upload => "upload",
95 Self::Users => "users",
96 Self::X => "x",
97 }
98 }
99
100 pub fn fallback_glyph(self) -> &'static str {
101 match self {
102 Self::Activity => "~",
103 Self::AlertCircle => "!",
104 Self::BarChart => "▮",
105 Self::Bell => "•",
106 Self::Check => "✓",
107 Self::ChevronDown => "⌄",
108 Self::ChevronLeft => "‹",
109 Self::ChevronRight => "›",
110 Self::ChevronUp => "⌃",
111 Self::Command => "⌘",
112 Self::Download => "↓",
113 Self::FileText => "□",
114 Self::Folder => "▱",
115 Self::GitBranch => "⑂",
116 Self::GitCommit => "⊙",
117 Self::Info => "i",
118 Self::LayoutDashboard => "▦",
119 Self::Menu => "☰",
120 Self::MoreHorizontal => "…",
121 Self::Plus => "+",
122 Self::RefreshCw => "↻",
123 Self::Search => "⌕",
124 Self::Settings => "⚙",
125 Self::Upload => "↑",
126 Self::Users => "●",
127 Self::X => "×",
128 }
129 }
130}