From 6eabc6a0ec259e7a16e9770296e5e9444622a3f4 Mon Sep 17 00:00:00 2001 From: Kenneth Date: Sat, 9 May 2026 18:59:32 +0800 Subject: [PATCH] fix: text theme color not applied --- src/component/text.rs | 53 ++++++------------------------------------- 1 file changed, 7 insertions(+), 46 deletions(-) diff --git a/src/component/text.rs b/src/component/text.rs index b073c58..6041700 100644 --- a/src/component/text.rs +++ b/src/component/text.rs @@ -7,8 +7,6 @@ pub(crate) struct Text { font_weight: gpui::FontWeight, opacity: f32, text_align: gpui::TextAlign, - text_size: Option, - text_color: Option, line_height: gpui::DefiniteLength, style: gpui::StyleRefinement, } @@ -25,8 +23,6 @@ pub(crate) fn text(content: impl TextContent) -> Text { font_weight: gpui::FontWeight::NORMAL, opacity: 1., text_align: gpui::TextAlign::Left, - text_size: None, - text_color: None, line_height: gpui::relative(1.5), style: gpui::StyleRefinement::default(), } @@ -59,44 +55,6 @@ impl Text { self } - pub(crate) fn text_size(mut self, size: impl Into) -> Self { - self.text_size = Some(size.into()); - self - } - - pub(crate) fn text_xs(self) -> Self { - self.text_size(gpui::rems(0.75)) - } - - pub(crate) fn text_sm(self) -> Self { - self.text_size(gpui::rems(0.875)) - } - - pub(crate) fn text_base(self) -> Self { - self.text_size(gpui::rems(1.0)) - } - - pub(crate) fn text_lg(self) -> Self { - self.text_size(gpui::rems(1.125)) - } - - pub(crate) fn text_xl(self) -> Self { - self.text_size(gpui::rems(1.25)) - } - - pub(crate) fn text_2xl(self) -> Self { - self.text_size(gpui::rems(1.5)) - } - - pub(crate) fn text_3xl(self) -> Self { - self.text_size(gpui::rems(1.875)) - } - - pub(crate) fn text_color(mut self, color: impl Into) -> Self { - self.text_color = Some(color.into()); - self - } - pub(crate) fn line_height(mut self, line_height: impl Into) -> Self { self.line_height = line_height.into(); self @@ -167,17 +125,20 @@ impl Text { impl gpui::RenderOnce for Text { fn render(self, _window: &mut gpui::Window, cx: &mut gpui::App) -> impl gpui::IntoElement { let theme = app::current_theme(cx); + let mut div = div() - .text_color(self.text_color.unwrap_or(theme.colors.text.into())) .font_weight(self.font_weight) .opacity(self.opacity) .text_align(self.text_align) .line_height(self.line_height) .child(self.content); - if let Some(text_size) = self.text_size { - div = div.text_size(text_size); - } div.style().refine(&self.style); + + if div.style().text.as_ref().and_then(|it| it.color).is_none() { + // if no text color override, use theme text color + div = div.text_color(theme.colors.text); + } + div } }