initial commit
This commit is contained in:
34
src/component/font_icon.rs
Normal file
34
src/component/font_icon.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
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"
|
||||
),
|
||||
)+
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
define_font_icons!(ChevronDown, FolderGit);
|
||||
|
||||
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)
|
||||
}
|
||||
13
src/component/text.rs
Normal file
13
src/component/text.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use crate::app;
|
||||
use gpui::{ParentElement, Styled, div};
|
||||
|
||||
pub trait Text: gpui::IntoElement {}
|
||||
|
||||
impl Text for &'static str {}
|
||||
impl Text for String {}
|
||||
impl Text for gpui::SharedString {}
|
||||
|
||||
pub fn text<'a, Content: Text, T>(s: Content, cx: &gpui::Context<T>) -> gpui::Div {
|
||||
let theme = cx.global::<app::Global>().current_theme;
|
||||
div().text_color(theme.colors.text).child(s)
|
||||
}
|
||||
Reference in New Issue
Block a user