From c0d11be75f0a2febec1edc86c70a2594eca79b44 Mon Sep 17 00:00:00 2001 From: Nate Butler Date: Tue, 19 Nov 2024 00:24:37 -0500 Subject: [PATCH] remove usages of `theme::color_alpha` --- crates/assistant/src/assistant_panel.rs | 4 ++-- crates/extensions_ui/src/components/extension_card.rs | 5 +---- crates/outline/src/outline.rs | 4 ++-- crates/theme/src/theme.rs | 8 -------- 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/crates/assistant/src/assistant_panel.rs b/crates/assistant/src/assistant_panel.rs index b682bfdcca..6e0ff77ef2 100644 --- a/crates/assistant/src/assistant_panel.rs +++ b/crates/assistant/src/assistant_panel.rs @@ -2625,8 +2625,8 @@ impl ContextEditor { .px_1() .mr_0p5() .border_1() - .border_color(theme::color_alpha(colors.border_variant, 0.6)) - .bg(theme::color_alpha(colors.element_background, 0.6)) + .border_color(colors.border_variant.opacity(0.6)) + .bg(colors.element_background.opacity(0.6)) .child("esc"), ) .child("to cancel") diff --git a/crates/extensions_ui/src/components/extension_card.rs b/crates/extensions_ui/src/components/extension_card.rs index 2dc472f801..c44ac2063a 100644 --- a/crates/extensions_ui/src/components/extension_card.rs +++ b/crates/extensions_ui/src/components/extension_card.rs @@ -52,10 +52,7 @@ impl RenderOnce for ExtensionCard { .size_full() .items_center() .justify_center() - .bg(theme::color_alpha( - cx.theme().colors().elevated_surface_background, - 0.8, - )) + .bg(cx.theme().colors().elevated_surface_background.opacity(0.8)) .child(Label::new("Overridden by dev extension.")), ) }), diff --git a/crates/outline/src/outline.rs b/crates/outline/src/outline.rs index 154b9297a3..e6ba24f75c 100644 --- a/crates/outline/src/outline.rs +++ b/crates/outline/src/outline.rs @@ -17,7 +17,7 @@ use language::{Outline, OutlineItem}; use ordered_float::OrderedFloat; use picker::{Picker, PickerDelegate}; use settings::Settings; -use theme::{color_alpha, ActiveTheme, ThemeSettings}; +use theme::{ActiveTheme, ThemeSettings}; use ui::{prelude::*, ListItem, ListItemSpacing}; use util::ResultExt; use workspace::{DismissDecision, ModalView}; @@ -297,7 +297,7 @@ pub fn render_item( cx: &AppContext, ) -> StyledText { let highlight_style = HighlightStyle { - background_color: Some(color_alpha(cx.theme().colors().text_accent, 0.3)), + background_color: Some(cx.theme().colors().text_accent.opacity(0.3)), ..Default::default() }; let custom_highlights = match_ranges diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index cf860ad452..d501d3c118 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -333,14 +333,6 @@ impl Theme { } } -/// Compounds a color with an alpha value. -/// TODO: Replace this with a method on Hsla. -pub fn color_alpha(color: Hsla, alpha: f32) -> Hsla { - let mut color = color; - color.a = alpha; - color -} - /// Asynchronously reads the user theme from the specified path. pub async fn read_user_theme(theme_path: &Path, fs: Arc) -> Result { let reader = fs.open_sync(theme_path).await?;