Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
ui: Remove support for unnecessary Switch colors (#44388)
Danilo Leala8b61c5ffad3
diff --git a/crates/agent_ui/src/agent_configuration.rs b/crates/agent_ui/src/agent_configuration.rsindex f831329e2cd..3e4654af6e7 100644--- a/crates/agent_ui/src/agent_configuration.rs+++ b/crates/agent_ui/src/agent_configuration.rs@@ -36,7 +36,7 @@ use settings::{Settings, SettingsStore, update_settings_file};use ui::{Button, ButtonStyle, Chip, CommonAnimationExt, ContextMenu, ContextMenuEntry, Disclosure,Divider, DividerColor, ElevationIndex, IconName, IconPosition, IconSize, Indicator, LabelSize,- PopoverMenu, Switch, SwitchColor, Tooltip, WithScrollbar, prelude::*,+ PopoverMenu, Switch, Tooltip, WithScrollbar, prelude::*,};use util::ResultExt as _;use workspace::{Workspace, create_and_open_local_file};@@ -879,7 +879,6 @@ impl AgentConfiguration {.child(context_server_configuration_menu).child(Switch::new("context-server-switch", is_running.into())- .color(SwitchColor::Accent).on_click({let context_server_manager = self.context_server_store.clone();let fs = self.fs.clone();diff --git a/crates/debugger_ui/src/new_process_modal.rs b/crates/debugger_ui/src/new_process_modal.rsindex ca13e3eed5f..24f6cc8f341 100644--- a/crates/debugger_ui/src/new_process_modal.rs+++ b/crates/debugger_ui/src/new_process_modal.rs@@ -881,7 +881,6 @@ impl ConfigureMode {.label("Stop on Entry").label_position(SwitchLabelPosition::Start).label_size(LabelSize::Default)- .color(ui::SwitchColor::Accent).on_click({let this = cx.weak_entity();move |state, _, cx| {diff --git a/crates/extensions_ui/src/extensions_ui.rs b/crates/extensions_ui/src/extensions_ui.rsindex 89247ae5a49..3dd4803ce17 100644--- a/crates/extensions_ui/src/extensions_ui.rs+++ b/crates/extensions_ui/src/extensions_ui.rs@@ -1472,8 +1472,7 @@ impl ExtensionsPage {},);},- ))- .color(ui::SwitchColor::Accent),+ )),),),)diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rsindex 43925c1893a..4464d3bdd95 100644--- a/crates/settings_ui/src/settings_ui.rs+++ b/crates/settings_ui/src/settings_ui.rs@@ -29,8 +29,8 @@ use std::{use title_bar::platform_title_bar::PlatformTitleBar;use ui::{Banner, ContextMenu, Divider, DividerColor, DropdownMenu, DropdownStyle, IconButtonShape,- KeyBinding, KeybindingHint, PopoverMenu, Switch, SwitchColor, Tooltip, TreeViewItem,- WithScrollbar, prelude::*,+ KeyBinding, KeybindingHint, PopoverMenu, Switch, Tooltip, TreeViewItem, WithScrollbar,+ prelude::*,};use ui_input::{NumberField, NumberFieldType};use util::{ResultExt as _, paths::PathStyle, rel_path::RelPath};@@ -3501,7 +3501,6 @@ fn render_toggle_button<B: Into<bool> + From<bool> + Copy>(Switch::new("toggle_button", toggle_state).tab_index(0_isize)- .color(SwitchColor::Accent).on_click({move |state, _window, cx| {telemetry::event!("Settings Change", setting = field.json_path, type = file.setting_type());diff --git a/crates/ui/src/components/toggle.rs b/crates/ui/src/components/toggle.rsindex 1e637f24194..e0360d6a2a8 100644--- a/crates/ui/src/components/toggle.rs+++ b/crates/ui/src/components/toggle.rs@@ -281,11 +281,7 @@ impl RenderOnce for Checkbox {#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Default)]pub enum SwitchColor {#[default]- Default,Accent,- Error,- Warning,- Success,Custom(Hsla),}@@ -299,27 +295,10 @@ impl SwitchColor {}match self {- SwitchColor::Default => {- let colors = cx.theme().colors();- let base_color = colors.text;- let bg_color = colors.element_background.blend(base_color.opacity(0.08));- (bg_color, colors.border_variant)- }SwitchColor::Accent => {let status = cx.theme().status();- (status.info.opacity(0.4), status.info.opacity(0.2))- }- SwitchColor::Error => {- let status = cx.theme().status();- (status.error.opacity(0.4), status.error.opacity(0.2))- }- SwitchColor::Warning => {- let status = cx.theme().status();- (status.warning.opacity(0.4), status.warning.opacity(0.2))- }- SwitchColor::Success => {- let status = cx.theme().status();- (status.success.opacity(0.4), status.success.opacity(0.2))+ let colors = cx.theme().colors();+ (status.info.opacity(0.4), colors.text_accent.opacity(0.2))}SwitchColor::Custom(color) => (*color, color.opacity(0.6)),}@@ -329,11 +308,7 @@ impl SwitchColor {impl From<SwitchColor> for Color {fn from(color: SwitchColor) -> Self {match color {- SwitchColor::Default => Color::Default,SwitchColor::Accent => Color::Accent,- SwitchColor::Error => Color::Error,- SwitchColor::Warning => Color::Warning,- SwitchColor::Success => Color::Success,SwitchColor::Custom(_) => Color::Default,}}@@ -980,37 +955,8 @@ impl Component for Switch {"Colors",vec![single_example(- "Default",- Switch::new("switch_default_style", ToggleState::Selected)- .color(SwitchColor::Default)- .on_click(|_, _, _cx| {})- .into_any_element(),- ),- single_example(- "Accent",+ "Accent (Default)",Switch::new("switch_accent_style", ToggleState::Selected)- .color(SwitchColor::Accent)- .on_click(|_, _, _cx| {})- .into_any_element(),- ),- single_example(- "Error",- Switch::new("switch_error_style", ToggleState::Selected)- .color(SwitchColor::Error)- .on_click(|_, _, _cx| {})- .into_any_element(),- ),- single_example(- "Warning",- Switch::new("switch_warning_style", ToggleState::Selected)- .color(SwitchColor::Warning)- .on_click(|_, _, _cx| {})- .into_any_element(),- ),- single_example(- "Success",- Switch::new("switch_success_style", ToggleState::Selected)- .color(SwitchColor::Success).on_click(|_, _, _cx| {}).into_any_element(),),