Files
novem/src/component/font_icon.rs

35 lines
953 B
Rust
Raw Normal View History

2026-04-20 15:13:26 +01:00
use gpui::{Styled, svg};
use paste::paste;
use crate::app;
macro_rules! define_font_icons {
($($name:ident),+ $(,)?) => {
paste! {
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum FontIcon {
$($name),+
}
pub const fn icon_path(icon: FontIcon) -> &'static str {
match icon {
$(
FontIcon::$name => concat!(
"asset/font_icon/",
stringify!([<$name:snake>]),
".svg"
),
)+
}
}
}
};
}
2026-04-25 00:49:50 +01:00
define_font_icons!(Check, ChevronDown, FolderGit, Github);
2026-04-20 15:13:26 +01:00
pub fn font_icon<T>(icon: FontIcon, cx: &gpui::Context<T>) -> gpui::Svg {
let theme = cx.global::<app::Global>().current_theme;
svg().path(icon_path(icon)).text_color(theme.colors.text)
}