Use an IconButton for the tab close button

This commit is contained in:
Marshall Bowers 2023-11-03 16:36:02 -04:00
parent 33245d119e
commit 1361b61708
2 changed files with 8 additions and 21 deletions

View file

@ -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)))
})
}
}

View file

@ -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 {