Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Use an `IconButton` for the tab close button
Marshall Bowers1361b617082b
diff --git a/crates/ui2/src/elements/icon.rs b/crates/ui2/src/elements/icon.rsindex 94e15ca0f11..9c056d68d1c 100644--- a/crates/ui2/src/elements/icon.rs+++ b/crates/ui2/src/elements/icon.rs@@ -159,7 +159,6 @@ impl Icon {pub struct IconElement {icon: Icon,color: IconColor,- hover_color: Option<IconColor>,size: IconSize,}@@ -168,7 +167,6 @@ impl IconElement {Self {icon,color: IconColor::default(),- hover_color: None,size: IconSize::default(),}}@@ -178,11 +176,6 @@ impl IconElement {self}- pub fn hover_color(mut self, hover_color: impl Into<Option<IconColor>>) -> Self {- self.hover_color = hover_color.into();- self- }-pub fn size(mut self, size: IconSize) -> Self {self.size = size;self@@ -199,9 +192,6 @@ impl IconElement {.flex_none().path(self.icon.path()).text_color(self.color.color(cx))- .when_some(self.hover_color, |this, hover_color| {- this.hover(|style| style.text_color(hover_color.color(cx)))- })}}diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rsindex a1ec1684884..0c2ee5f46e9 100644--- a/crates/workspace2/src/pane.rs+++ b/crates/workspace2/src/pane.rs@@ -9,8 +9,8 @@ use crate::{use anyhow::Result;use collections::{HashMap, HashSet, VecDeque};use gpui::{- AnyView, AppContext, AsyncWindowContext, Component, Div, EntityId, EventEmitter, FocusHandle,- Model, PromptLevel, Render, Task, View, ViewContext, VisualContext, WeakView, WindowContext,+ AppContext, AsyncWindowContext, Component, Div, EntityId, EventEmitter, FocusHandle, Model,+ PromptLevel, Render, Task, View, ViewContext, VisualContext, WeakView, WindowContext,};use parking_lot::Mutex;use project2::{Project, ProjectEntryId, ProjectPath};@@ -1366,15 +1366,12 @@ impl Pane {.id(item.id()).invisible().group_hover("", |style| style.visible())- .child(- IconElement::new(Icon::Close)- .color(IconColor::Muted)- .hover_color(IconColor::Accent),- )- .on_click(move |pane: &mut Self, _, cx| {- pane.close_item_by_id(id, SaveIntent::Close, cx)- .detach_and_log_err(cx);- })+ .child(IconButton::<Self>::new("close_tab", Icon::Close).on_click(+ move |pane: &mut Self, cx| {+ pane.close_item_by_id(id, SaveIntent::Close, cx)+ .detach_and_log_err(cx);+ },+ ))};let (text_color, tab_bg, tab_hover_bg, tab_active_bg) = match ix == self.active_item_index {