1#![warn(missing_docs)]
5
6#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
9#[non_exhaustive]
10pub enum IconName {
11 Activity,
13 AlertCircle,
15 BarChart,
17 Bell,
19 Check,
21 ChevronDown,
23 ChevronLeft,
25 ChevronRight,
27 ChevronUp,
29 Command,
31 Download,
33 FileText,
35 Folder,
37 GitBranch,
39 GitCommit,
41 Info,
43 LayoutDashboard,
45 Menu,
47 MoreHorizontal,
49 Plus,
51 RefreshCw,
53 Search,
55 Settings,
57 Upload,
59 Users,
61 X,
63}
64
65impl IconName {
66 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 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 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}