Derive icon paths (#17816)
This PR improves adding and working with icons by using the new `DerivePathStr` to derive icon paths. This means paths no longer need to be manually specified, and the `IconName` and file name will always be consistent between icons. This PR does not do any work to standardize icons visually, remove unused icons, or any other such cleanup. Release Notes: - N/A
This commit is contained in:
parent
ce848375fe
commit
e8a2dd92c8
39 changed files with 96 additions and 226 deletions
|
@ -1,6 +1,7 @@
|
|||
use gpui::{svg, AnimationElement, Hsla, IntoElement, Rems, Transformation};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use strum::{EnumIter, EnumString, IntoStaticStr};
|
||||
use ui_macros::DerivePathStr;
|
||||
|
||||
use crate::{prelude::*, Indicator};
|
||||
|
||||
|
@ -102,15 +103,27 @@ impl IconSize {
|
|||
}
|
||||
|
||||
#[derive(
|
||||
Debug, PartialEq, Eq, Copy, Clone, EnumIter, EnumString, IntoStaticStr, Serialize, Deserialize,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Copy,
|
||||
Clone,
|
||||
EnumIter,
|
||||
EnumString,
|
||||
IntoStaticStr,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
DerivePathStr,
|
||||
)]
|
||||
#[strum(serialize_all = "snake_case")]
|
||||
#[path_str(prefix = "icons", suffix = ".svg")]
|
||||
pub enum IconName {
|
||||
Ai,
|
||||
AiAnthropic,
|
||||
AiAnthropicHosted,
|
||||
AiOpenAi,
|
||||
AiGoogle,
|
||||
AiOllama,
|
||||
AiOpenAi,
|
||||
AiZed,
|
||||
ArrowCircle,
|
||||
ArrowDown,
|
||||
|
@ -135,15 +148,13 @@ pub enum IconName {
|
|||
CaseSensitive,
|
||||
Check,
|
||||
ChevronDown,
|
||||
/// This chevron indicates a popover menu.
|
||||
ChevronDownSmall,
|
||||
ChevronDownSmall, // This chevron indicates a popover menu.
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
ChevronUp,
|
||||
ChevronUpDown,
|
||||
Close,
|
||||
Code,
|
||||
Collab,
|
||||
Command,
|
||||
Context,
|
||||
Control,
|
||||
|
@ -153,6 +164,8 @@ pub enum IconName {
|
|||
CopilotInit,
|
||||
Copy,
|
||||
CountdownTimer,
|
||||
CursorIBeam,
|
||||
CursorText,
|
||||
Dash,
|
||||
DatabaseZap,
|
||||
Delete,
|
||||
|
@ -162,21 +175,20 @@ pub enum IconName {
|
|||
EllipsisVertical,
|
||||
Envelope,
|
||||
Escape,
|
||||
ExclamationTriangle,
|
||||
Exit,
|
||||
ExpandVertical,
|
||||
ExternalLink,
|
||||
Eye,
|
||||
File,
|
||||
FileCode,
|
||||
FileDoc,
|
||||
FileGeneric,
|
||||
FileGit,
|
||||
FileLock,
|
||||
FileRust,
|
||||
FileText,
|
||||
FileToml,
|
||||
FileTree,
|
||||
FileText,
|
||||
FileCode,
|
||||
Filter,
|
||||
Folder,
|
||||
FolderOpen,
|
||||
|
@ -184,11 +196,11 @@ pub enum IconName {
|
|||
Font,
|
||||
FontSize,
|
||||
FontWeight,
|
||||
Github,
|
||||
GenericMinimize,
|
||||
GenericMaximize,
|
||||
GenericClose,
|
||||
GenericMaximize,
|
||||
GenericMinimize,
|
||||
GenericRestore,
|
||||
Github,
|
||||
Hash,
|
||||
HistoryRerun,
|
||||
Indicator,
|
||||
|
@ -228,21 +240,21 @@ pub enum IconName {
|
|||
Rerun,
|
||||
Return,
|
||||
Reveal,
|
||||
Route,
|
||||
RotateCcw,
|
||||
RotateCw,
|
||||
Route,
|
||||
Save,
|
||||
Screen,
|
||||
SearchSelection,
|
||||
SearchCode,
|
||||
SearchSelection,
|
||||
SelectAll,
|
||||
Server,
|
||||
Settings,
|
||||
SettingsAlt,
|
||||
Shift,
|
||||
Slash,
|
||||
SlashSquare,
|
||||
Sliders,
|
||||
SlidersAlt,
|
||||
Snip,
|
||||
Space,
|
||||
Sparkle,
|
||||
|
@ -260,191 +272,18 @@ pub enum IconName {
|
|||
SupermavenInit,
|
||||
Tab,
|
||||
Terminal,
|
||||
TextCursor,
|
||||
TextSelect,
|
||||
Trash,
|
||||
TriangleRight,
|
||||
Undo,
|
||||
Unpin,
|
||||
Update,
|
||||
UserGroup,
|
||||
Visible,
|
||||
Warning,
|
||||
WholeWord,
|
||||
XCircle,
|
||||
ZedAssistant,
|
||||
ZedAssistantFilled,
|
||||
Visible,
|
||||
}
|
||||
|
||||
impl IconName {
|
||||
pub fn path(self) -> &'static str {
|
||||
match self {
|
||||
IconName::Ai => "icons/ai.svg",
|
||||
IconName::AiAnthropic => "icons/ai_anthropic.svg",
|
||||
IconName::AiAnthropicHosted => "icons/ai_anthropic_hosted.svg",
|
||||
IconName::AiOpenAi => "icons/ai_open_ai.svg",
|
||||
IconName::AiGoogle => "icons/ai_google.svg",
|
||||
IconName::AiOllama => "icons/ai_ollama.svg",
|
||||
IconName::AiZed => "icons/ai_zed.svg",
|
||||
IconName::ArrowCircle => "icons/arrow_circle.svg",
|
||||
IconName::ArrowDown => "icons/arrow_down.svg",
|
||||
IconName::ArrowDownFromLine => "icons/arrow_down_from_line.svg",
|
||||
IconName::ArrowLeft => "icons/arrow_left.svg",
|
||||
IconName::ArrowRight => "icons/arrow_right.svg",
|
||||
IconName::ArrowUp => "icons/arrow_up.svg",
|
||||
IconName::ArrowUpFromLine => "icons/arrow_up_from_line.svg",
|
||||
IconName::ArrowUpRight => "icons/arrow_up_right.svg",
|
||||
IconName::AtSign => "icons/at_sign.svg",
|
||||
IconName::AudioOff => "icons/speaker_off.svg",
|
||||
IconName::AudioOn => "icons/speaker_loud.svg",
|
||||
IconName::Backspace => "icons/backspace.svg",
|
||||
IconName::Bell => "icons/bell.svg",
|
||||
IconName::BellDot => "icons/bell_dot.svg",
|
||||
IconName::BellOff => "icons/bell_off.svg",
|
||||
IconName::BellRing => "icons/bell_ring.svg",
|
||||
IconName::Bolt => "icons/bolt.svg",
|
||||
IconName::Book => "icons/book.svg",
|
||||
IconName::BookCopy => "icons/book_copy.svg",
|
||||
IconName::BookPlus => "icons/book_plus.svg",
|
||||
IconName::CaseSensitive => "icons/case_insensitive.svg",
|
||||
IconName::Check => "icons/check.svg",
|
||||
IconName::ChevronDown => "icons/chevron_down.svg",
|
||||
IconName::ChevronDownSmall => "icons/chevron_down_small.svg",
|
||||
IconName::ChevronLeft => "icons/chevron_left.svg",
|
||||
IconName::ChevronRight => "icons/chevron_right.svg",
|
||||
IconName::ChevronUp => "icons/chevron_up.svg",
|
||||
IconName::ChevronUpDown => "icons/chevron_up_down.svg",
|
||||
IconName::Close => "icons/x.svg",
|
||||
IconName::Code => "icons/code.svg",
|
||||
IconName::Collab => "icons/user_group_16.svg",
|
||||
IconName::Command => "icons/command.svg",
|
||||
IconName::Context => "icons/context.svg",
|
||||
IconName::Control => "icons/control.svg",
|
||||
IconName::Copilot => "icons/copilot.svg",
|
||||
IconName::CopilotDisabled => "icons/copilot_disabled.svg",
|
||||
IconName::CopilotError => "icons/copilot_error.svg",
|
||||
IconName::CopilotInit => "icons/copilot_init.svg",
|
||||
IconName::Copy => "icons/copy.svg",
|
||||
IconName::CountdownTimer => "icons/countdown_timer.svg",
|
||||
IconName::Dash => "icons/dash.svg",
|
||||
IconName::DatabaseZap => "icons/database_zap.svg",
|
||||
IconName::Delete => "icons/delete.svg",
|
||||
IconName::Disconnected => "icons/disconnected.svg",
|
||||
IconName::Download => "icons/download.svg",
|
||||
IconName::Ellipsis => "icons/ellipsis.svg",
|
||||
IconName::EllipsisVertical => "icons/ellipsis_vertical.svg",
|
||||
IconName::Envelope => "icons/feedback.svg",
|
||||
IconName::Escape => "icons/escape.svg",
|
||||
IconName::ExclamationTriangle => "icons/warning.svg",
|
||||
IconName::Exit => "icons/exit.svg",
|
||||
IconName::ExpandVertical => "icons/expand_vertical.svg",
|
||||
IconName::ExternalLink => "icons/external_link.svg",
|
||||
IconName::Eye => "icons/eye.svg",
|
||||
IconName::File => "icons/file.svg",
|
||||
IconName::FileDoc => "icons/file_icons/book.svg",
|
||||
IconName::FileGeneric => "icons/file_icons/file.svg",
|
||||
IconName::FileGit => "icons/file_icons/git.svg",
|
||||
IconName::FileLock => "icons/file_icons/lock.svg",
|
||||
IconName::FileRust => "icons/file_icons/rust.svg",
|
||||
IconName::FileToml => "icons/file_icons/toml.svg",
|
||||
IconName::FileTree => "icons/project.svg",
|
||||
IconName::FileCode => "icons/file_code.svg",
|
||||
IconName::FileText => "icons/file_text.svg",
|
||||
IconName::Filter => "icons/filter.svg",
|
||||
IconName::Folder => "icons/file_icons/folder.svg",
|
||||
IconName::FolderOpen => "icons/file_icons/folder_open.svg",
|
||||
IconName::FolderX => "icons/stop_sharing.svg",
|
||||
IconName::Font => "icons/font.svg",
|
||||
IconName::FontSize => "icons/font_size.svg",
|
||||
IconName::FontWeight => "icons/font_weight.svg",
|
||||
IconName::Github => "icons/github.svg",
|
||||
IconName::GenericMinimize => "icons/generic_minimize.svg",
|
||||
IconName::GenericMaximize => "icons/generic_maximize.svg",
|
||||
IconName::GenericClose => "icons/generic_close.svg",
|
||||
IconName::GenericRestore => "icons/generic_restore.svg",
|
||||
IconName::Hash => "icons/hash.svg",
|
||||
IconName::HistoryRerun => "icons/history_rerun.svg",
|
||||
IconName::Indicator => "icons/indicator.svg",
|
||||
IconName::IndicatorX => "icons/indicator_x.svg",
|
||||
IconName::InlayHint => "icons/inlay_hint.svg",
|
||||
IconName::Library => "icons/library.svg",
|
||||
IconName::LineHeight => "icons/line_height.svg",
|
||||
IconName::Link => "icons/link.svg",
|
||||
IconName::ListTree => "icons/list_tree.svg",
|
||||
IconName::MagnifyingGlass => "icons/magnifying_glass.svg",
|
||||
IconName::MailOpen => "icons/mail_open.svg",
|
||||
IconName::Maximize => "icons/maximize.svg",
|
||||
IconName::Menu => "icons/menu.svg",
|
||||
IconName::MessageBubbles => "icons/conversations.svg",
|
||||
IconName::Mic => "icons/mic.svg",
|
||||
IconName::MicMute => "icons/mic_mute.svg",
|
||||
IconName::Microscope => "icons/microscope.svg",
|
||||
IconName::Minimize => "icons/minimize.svg",
|
||||
IconName::Option => "icons/option.svg",
|
||||
IconName::PageDown => "icons/page_down.svg",
|
||||
IconName::PageUp => "icons/page_up.svg",
|
||||
IconName::Pencil => "icons/pencil.svg",
|
||||
IconName::Person => "icons/person.svg",
|
||||
IconName::Pin => "icons/pin.svg",
|
||||
IconName::Play => "icons/play.svg",
|
||||
IconName::Plus => "icons/plus.svg",
|
||||
IconName::PocketKnife => "icons/pocket_knife.svg",
|
||||
IconName::Public => "icons/public.svg",
|
||||
IconName::PullRequest => "icons/pull_request.svg",
|
||||
IconName::Quote => "icons/quote.svg",
|
||||
IconName::Regex => "icons/regex.svg",
|
||||
IconName::ReplNeutral => "icons/repl_neutral.svg",
|
||||
IconName::Replace => "icons/replace.svg",
|
||||
IconName::ReplaceAll => "icons/replace_all.svg",
|
||||
IconName::ReplaceNext => "icons/replace_next.svg",
|
||||
IconName::ReplyArrowRight => "icons/reply_arrow_right.svg",
|
||||
IconName::Rerun => "icons/rerun.svg",
|
||||
IconName::Return => "icons/return.svg",
|
||||
IconName::Reveal => "icons/reveal.svg",
|
||||
IconName::RotateCcw => "icons/rotate_ccw.svg",
|
||||
IconName::RotateCw => "icons/rotate_cw.svg",
|
||||
IconName::Route => "icons/route.svg",
|
||||
IconName::Save => "icons/save.svg",
|
||||
IconName::Screen => "icons/desktop.svg",
|
||||
IconName::SearchSelection => "icons/search_selection.svg",
|
||||
IconName::SearchCode => "icons/search_code.svg",
|
||||
IconName::SelectAll => "icons/select_all.svg",
|
||||
IconName::Server => "icons/server.svg",
|
||||
IconName::Settings => "icons/file_icons/settings.svg",
|
||||
IconName::Shift => "icons/shift.svg",
|
||||
IconName::Slash => "icons/slash.svg",
|
||||
IconName::SlashSquare => "icons/slash_square.svg",
|
||||
IconName::Sliders => "icons/sliders.svg",
|
||||
IconName::SlidersAlt => "icons/sliders-alt.svg",
|
||||
IconName::Snip => "icons/snip.svg",
|
||||
IconName::Space => "icons/space.svg",
|
||||
IconName::Sparkle => "icons/sparkle.svg",
|
||||
IconName::SparkleAlt => "icons/sparkle_alt.svg",
|
||||
IconName::SparkleFilled => "icons/sparkle_filled.svg",
|
||||
IconName::Spinner => "icons/spinner.svg",
|
||||
IconName::Split => "icons/split.svg",
|
||||
IconName::Star => "icons/star.svg",
|
||||
IconName::StarFilled => "icons/star_filled.svg",
|
||||
IconName::Stop => "icons/stop.svg",
|
||||
IconName::Strikethrough => "icons/strikethrough.svg",
|
||||
IconName::Supermaven => "icons/supermaven.svg",
|
||||
IconName::SupermavenDisabled => "icons/supermaven_disabled.svg",
|
||||
IconName::SupermavenError => "icons/supermaven_error.svg",
|
||||
IconName::SupermavenInit => "icons/supermaven_init.svg",
|
||||
IconName::Tab => "icons/tab.svg",
|
||||
IconName::Terminal => "icons/terminal.svg",
|
||||
IconName::TextCursor => "icons/text-cursor.svg",
|
||||
IconName::TextSelect => "icons/text_select.svg",
|
||||
IconName::Trash => "icons/trash.svg",
|
||||
IconName::TriangleRight => "icons/triangle_right.svg",
|
||||
IconName::Unpin => "icons/unpin.svg",
|
||||
IconName::Update => "icons/update.svg",
|
||||
IconName::Undo => "icons/undo.svg",
|
||||
IconName::WholeWord => "icons/word_search.svg",
|
||||
IconName::XCircle => "icons/error.svg",
|
||||
IconName::ZedAssistant => "icons/zed_assistant.svg",
|
||||
IconName::ZedAssistantFilled => "icons/zed_assistant_filled.svg",
|
||||
IconName::Visible => "icons/visible.svg",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(IntoElement)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue