1use crate::theme::theme;
2use gpui2::elements::svg;
3use gpui2::style::StyleHelpers;
4use gpui2::IntoElement;
5use gpui2::{Element, ViewContext};
6
7#[derive(Default, PartialEq, Copy, Clone)]
8pub enum IconAsset {
9 Ai,
10 ArrowLeft,
11 ArrowRight,
12 ArrowUpRight,
13 Bolt,
14 ChevronDown,
15 ChevronLeft,
16 ChevronRight,
17 ChevronUp,
18 #[default]
19 File,
20 FileDoc,
21 FileGit,
22 FileLock,
23 FileRust,
24 FileToml,
25 Folder,
26 FolderOpen,
27 Hash,
28}
29
30impl IconAsset {
31 pub fn path(self) -> &'static str {
32 match self {
33 IconAsset::Ai => "icons/ai.svg",
34 IconAsset::ArrowLeft => "icons/arrow_left.svg",
35 IconAsset::ArrowRight => "icons/arrow_right.svg",
36 IconAsset::ArrowUpRight => "icons/arrow_up_right.svg",
37 IconAsset::Bolt => "icons/bolt.svg",
38 IconAsset::ChevronDown => "icons/chevron_down.svg",
39 IconAsset::ChevronLeft => "icons/chevron_left.svg",
40 IconAsset::ChevronRight => "icons/chevron_right.svg",
41 IconAsset::ChevronUp => "icons/chevron_up.svg",
42 IconAsset::File => "icons/file_icons/file.svg",
43 IconAsset::FileDoc => "icons/file_icons/book.svg",
44 IconAsset::FileGit => "icons/file_icons/git.svg",
45 IconAsset::FileLock => "icons/file_icons/lock.svg",
46 IconAsset::FileRust => "icons/file_icons/rust.svg",
47 IconAsset::FileToml => "icons/file_icons/toml.svg",
48 IconAsset::Folder => "icons/file_icons/folder.svg",
49 IconAsset::FolderOpen => "icons/file_icons/folder_open.svg",
50 IconAsset::Hash => "icons/hash.svg",
51 }
52 }
53}
54
55#[derive(Element, Clone)]
56pub struct Icon {
57 asset: IconAsset,
58}
59
60pub fn icon(asset: IconAsset) -> Icon {
61 Icon { asset }
62}
63
64impl Icon {
65 fn render<V: 'static>(&mut self, _: &mut V, cx: &mut ViewContext<V>) -> impl IntoElement<V> {
66 let theme = theme(cx);
67
68 svg()
69 .flex_none()
70 .path(self.asset.path())
71 .size_4()
72 .fill(theme.lowest.variant.default.foreground)
73 }
74}