BlueGit

ict rusty-teams

Files

rusty-teams / crates / app-base / src / assets.rs

assets.rs

8675fa6c History
assets.rs 2.5 KiB Download Raw
1use std::borrow::Cow;
2
3use gpui_kit::{AssetSource, Result, SharedString};
4
5macro_rules! symbols {
6 ($($name:literal),* $(,)?) => {
7 [$((concat!("symbols/", $name, ".svg"), include_bytes!(concat!("../../app/assets/symbols/", $name, ".svg")) as &[u8])),*]
8 };
9}
10
11const SYMBOLS: [(&str, &[u8]); 79] = symbols![
12 "campaign",
13 "lock",
14 "bot",
15 "copilot_color",
16 "done",
17 "table",
18 "done_all",
19 "keyboard_return",
20 "schedule",
21 "schedule_send",
22 "event",
23 "wb_sunny",
24 "work",
25 "close",
26 "reply",
27 "group",
28 "tag",
29 "image",
30 "check_circle",
31 "error",
32 "notifications",
33 "content_copy",
34 "attach_file",
35 "upload",
36 "download",
37 "folder_open",
38 "refresh",
39 "code",
40 "link",
41 "format_list_bulleted",
42 "format_list_numbered",
43 "format_quote",
44 "mood",
45 "status_dot",
46 "status_dnd",
47 "status_away",
48 "status_ring",
49 "status_available",
50 "status_offline",
51 "recap",
52 "zoom_in",
53 "zoom_out",
54 "rotate_right",
55 "forward",
56 "open_in_new",
57 "chevron_left",
58 "chevron_right",
59 "fullscreen",
60 "spinner_track",
61 "spinner_arc",
62 "shield",
63 "call",
64 "call_missed",
65 "videocam",
66 "fluent_video",
67 "fluent_record",
68 "fluent_record_stop",
69 "fluent_cloud_arrow_up",
70 "fluent_share",
71 "fluent_clock",
72 "fluent_document_text",
73 "fluent_text_edit_style",
74 "fluent_text_edit_style_filled",
75 "fluent_table_add",
76 "fluent_table_dismiss",
77 "fluent_important",
78 "fluent_important_filled",
79 "fluent_alert_urgent",
80 "fluent_alert_urgent_filled",
81 "fluent_chat",
82 "fluent_text_color",
83 "fluent_highlight",
84 "fluent_text_indent_increase",
85 "fluent_text_indent_decrease",
86 "fluent_line_horizontal_1",
87 "fluent_text_clear_formatting",
88 "fluent_code_block",
89 "fluent_text_header_1",
90 "fluent_text_font_size",
91];
92
93pub struct AppAssets;
94
95impl AssetSource for AppAssets {
96 fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> {
97 if let Some((_, bytes)) = SYMBOLS.iter().find(|(name, _)| *name == path) {
98 return Ok(Some(Cow::Borrowed(bytes)));
99 }
100 gpui_kit::assets::AllAssets.load(path)
101 }
102
103 fn list(&self, path: &str) -> Result<Vec<SharedString>> {
104 let mut names = gpui_kit::assets::AllAssets.list(path)?;
105 names.extend(
106 SYMBOLS
107 .iter()
108 .filter(|(name, _)| name.starts_with(path))
109 .map(|(name, _)| SharedString::from(*name)),
110 );
111 Ok(names)
112 }
113}