From 597a9f954863cab91dc85f52a1bc2bc38832b9db Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 18 Oct 2023 09:39:20 +0200 Subject: [PATCH] Use text color to paint SVGs --- crates/gpui3/src/elements/svg.rs | 11 +++++------ crates/storybook2/src/collab_panel.rs | 2 +- crates/storybook2/src/workspace.rs | 22 +++++++++++----------- crates/ui2/src/components/collab_panel.rs | 2 +- crates/ui2/src/elements/icon.rs | 5 ++++- 5 files changed, 22 insertions(+), 20 deletions(-) diff --git a/crates/gpui3/src/elements/svg.rs b/crates/gpui3/src/elements/svg.rs index 7ccd2a2c68aed732ad16b30cdc36ba4f02f40089..7904c2c7299d05d80ae95a3e52cff7bf2216c87f 100644 --- a/crates/gpui3/src/elements/svg.rs +++ b/crates/gpui3/src/elements/svg.rs @@ -84,14 +84,13 @@ where Self: Sized, { self.base.paint(bounds, view, element_state, cx); - let fill_color = self + let color = self .base .compute_style(bounds, element_state, cx) - .fill - .as_ref() - .and_then(|fill| fill.color()); - if let Some((path, fill_color)) = self.path.as_ref().zip(fill_color) { - cx.paint_svg(bounds, path.clone(), fill_color).log_err(); + .text + .color; + if let Some((path, color)) = self.path.as_ref().zip(color) { + cx.paint_svg(bounds, path.clone(), color).log_err(); } } } diff --git a/crates/storybook2/src/collab_panel.rs b/crates/storybook2/src/collab_panel.rs index 8f2eb14a54e022cf6e03f051272ef276bbe9ed70..bc21dafd4714ccb129c2b81f4a4480f92d1c2981 100644 --- a/crates/storybook2/src/collab_panel.rs +++ b/crates/storybook2/src/collab_panel.rs @@ -144,7 +144,7 @@ impl CollabPanel { }) .w_3p5() .h_3p5() - .fill(theme.middle.variant.default.foreground), + .text_color(theme.middle.variant.default.foreground), ), ) } diff --git a/crates/storybook2/src/workspace.rs b/crates/storybook2/src/workspace.rs index 2d32c3b8c1d1b1143cd48f600f85616098d3cc5f..610d80de0737ab23428d6c962456c2bc0eb39f2d 100644 --- a/crates/storybook2/src/workspace.rs +++ b/crates/storybook2/src/workspace.rs @@ -215,7 +215,7 @@ impl Titlebar { svg() .path("icons/exit.svg") .size_4() - .fill(theme.lowest.base.default.foreground), + .text_color(theme.lowest.base.default.foreground), ), ), ), @@ -245,7 +245,7 @@ impl Titlebar { svg() .path("icons/mic.svg") .size_3p5() - .fill(theme.lowest.base.default.foreground), + .text_color(theme.lowest.base.default.foreground), ), ) .child( @@ -265,7 +265,7 @@ impl Titlebar { svg() .path("icons/speaker-loud.svg") .size_3p5() - .fill(theme.lowest.base.default.foreground), + .text_color(theme.lowest.base.default.foreground), ), ) .child( @@ -285,7 +285,7 @@ impl Titlebar { svg() .path("icons/desktop.svg") .size_3p5() - .fill(theme.lowest.base.default.foreground), + .text_color(theme.lowest.base.default.foreground), ), ), ), @@ -318,7 +318,7 @@ impl Titlebar { .path("icons/caret_down.svg") .w_2() .h_2() - .fill(theme.lowest.variant.default.foreground), + .text_color(theme.lowest.variant.default.foreground), ), ), ) @@ -374,7 +374,7 @@ mod statusbar { .path("icons/project.svg") .w_4() .h_4() - .fill(theme.lowest.base.default.foreground), + .text_color(theme.lowest.base.default.foreground), ), ) .child( @@ -389,7 +389,7 @@ mod statusbar { .path("icons/conversations.svg") .w_4() .h_4() - .fill(theme.lowest.base.default.foreground), + .text_color(theme.lowest.base.default.foreground), ), ) .child( @@ -404,7 +404,7 @@ mod statusbar { .path("icons/file_icons/notebook.svg") .w_4() .h_4() - .fill(theme.lowest.accent.default.foreground), + .text_color(theme.lowest.accent.default.foreground), ), ), ) @@ -432,7 +432,7 @@ mod statusbar { .path("icons/error.svg") .w_4() .h_4() - .fill(theme.lowest.negative.default.foreground), + .text_color(theme.lowest.negative.default.foreground), ) .child(div().text_sm().child("2")), ) @@ -473,7 +473,7 @@ mod statusbar { .path("icons/check_circle.svg") .w_4() .h_4() - .fill(theme.lowest.base.default.foreground), + .text_color(theme.lowest.base.default.foreground), ), ) .child( @@ -488,7 +488,7 @@ mod statusbar { .path("icons/copilot.svg") .w_4() .h_4() - .fill(theme.lowest.accent.default.foreground), + .text_color(theme.lowest.accent.default.foreground), ), ), ) diff --git a/crates/ui2/src/components/collab_panel.rs b/crates/ui2/src/components/collab_panel.rs index 7512707de75a60f3211537cc625dcdfdbfdde658..bbf1a71f5b586bcb81d3ee448fd273a52efa8a75 100644 --- a/crates/ui2/src/components/collab_panel.rs +++ b/crates/ui2/src/components/collab_panel.rs @@ -121,7 +121,7 @@ impl CollabPanel { }) .w_3p5() .h_3p5() - .fill(theme.middle.variant.default.foreground), + .text_color(theme.middle.variant.default.foreground), ), ) } diff --git a/crates/ui2/src/elements/icon.rs b/crates/ui2/src/elements/icon.rs index f38c8c339a664d86fb4104d24102af399a230a36..56df8ee680f48802a8562157b36ed9bd2f3687b4 100644 --- a/crates/ui2/src/elements/icon.rs +++ b/crates/ui2/src/elements/icon.rs @@ -183,7 +183,10 @@ impl IconElement { IconSize::Large => svg().size_4(), }; - sized_svg.flex_none().path(self.icon.path()).fill(fill) + sized_svg + .flex_none() + .path(self.icon.path()) + .text_color(fill) } }