icons: default to ambient text color when unset

This commit is contained in:
2026-11-16 07:35:53 +07:00
parent a7abeea8c6
commit de2980712f
2 changed files with 9 additions and 6 deletions
+2 -2
View File
@@ -288,12 +288,12 @@ impl RenderOnce for Button {
.when_some(self.label, |content, label| content.child(label)) .when_some(self.label, |content, label| content.child(label))
.children(self.children) .children(self.children)
.when_some(self.icon, |content, icon| { .when_some(self.icon, |content, icon| {
content.child(icon.size(metrics.icon_size).color(foreground)) content.child(icon.size(metrics.icon_size))
}) })
} else { } else {
content content
.when_some(self.icon, |content, icon| { .when_some(self.icon, |content, icon| {
content.child(icon.size(metrics.icon_size).color(foreground)) content.child(icon.size(metrics.icon_size))
}) })
.when_some(self.label, |content, label| content.child(label)) .when_some(self.label, |content, label| content.child(label))
.children(self.children) .children(self.children)
+7 -4
View File
@@ -532,7 +532,7 @@ enum Glyph {
Named(SharedString), Named(SharedString),
} }
/// An icon element. Unpainted unless a color is set. /// An icon element. Painted with the ambient text color unless a color is set.
#[derive(Clone, IntoElement)] #[derive(Clone, IntoElement)]
pub struct Icon { pub struct Icon {
glyph: Glyph, glyph: Glyph,
@@ -681,16 +681,19 @@ where
} }
impl RenderOnce for Icon { impl RenderOnce for Icon {
fn render(self, _window: &mut Window, _cx: &mut gpui::App) -> impl IntoElement { fn render(self, window: &mut Window, _cx: &mut gpui::App) -> impl IntoElement {
let Icon { let Icon {
glyph, glyph,
size, size,
color, color,
transformation, transformation,
} = self; } = self;
let color = color.unwrap_or_else(|| window.text_style().color);
match glyph { match glyph {
Glyph::Named(path) => Self::render_svg_path(size, color, transformation, path), Glyph::Named(path) => Self::render_svg_path(size, Some(color), transformation, path),
Glyph::Role(role) => Self::render_role(size, color, transformation, role), Glyph::Role(role) => Self::render_role(size, Some(color), transformation, role),
} }
} }
} }