BlueGit

ict rusty-teams

Files

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

assets.rs

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