feat: port svg sizing to font icons

This commit is contained in:
2026-04-26 00:29:31 +01:00
parent 8b28f3d67f
commit dab18c40c5
5 changed files with 52 additions and 31 deletions

View File

@@ -1,4 +1,4 @@
use gpui::{Styled, svg};
use gpui::{Refineable as _, RenderOnce, Styled, svg};
use paste::paste;
use crate::app;
@@ -28,7 +28,33 @@ macro_rules! define_font_icons {
define_font_icons!(Check, ChevronDown, FolderGit, Github, ArrowRight);
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)
#[derive(gpui::IntoElement)]
pub struct FontIconSvg {
icon: FontIcon,
style: gpui::StyleRefinement,
}
pub fn font_icon(icon: FontIcon) -> FontIconSvg {
FontIconSvg {
icon,
style: gpui::StyleRefinement::default(),
}
}
impl Styled for FontIconSvg {
fn style(&mut self) -> &mut gpui::StyleRefinement {
&mut self.style
}
}
impl RenderOnce for FontIconSvg {
fn render(self, _window: &mut gpui::Window, cx: &mut gpui::App) -> impl gpui::IntoElement {
let theme = app::current_theme(cx);
let mut svg = svg()
.path(icon_path(self.icon))
.text_color(theme.colors.text);
svg.style().refine(&self.style);
svg
}
}