Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

ssh: Clean up title bar indicator icon (#19328)

Danilo Leal78093b8e76c9
diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs
index d0307d5625a..8c708e619a0 100644
--- a/crates/title_bar/src/title_bar.rs
+++ b/crates/title_bar/src/title_bar.rs
@@ -24,8 +24,8 @@ use smallvec::SmallVec;
use std::sync::Arc;
use theme::ActiveTheme;
use ui::{
- h_flex, prelude::*, Avatar, Button, ButtonLike, ButtonStyle, ContextMenu, Icon,
- IconButtonShape, IconName, IconSize, Indicator, PopoverMenu, Tooltip,
+ h_flex, prelude::*, Avatar, Button, ButtonLike, ButtonStyle, ContextMenu, Icon, IconName,
+ IconSize, IconWithIndicator, Indicator, PopoverMenu, Tooltip,
};
use util::ResultExt;
use vcs_menu::{BranchList, OpenRecent as ToggleVcsMenu};
@@ -281,8 +281,6 @@ impl TitleBar {
}
};
- let indicator_border_color = cx.theme().colors().title_bar_background;
-
let icon_color = match self.project.read(cx).ssh_connection_state(cx)? {
remote::ConnectionState::Connecting => Color::Info,
remote::ConnectionState::Connected => Color::Default,
@@ -293,42 +291,22 @@ impl TitleBar {
let meta = SharedString::from(meta);
- let indicator = h_flex()
- // We're using the circle inside a circle approach because, otherwise, by using borders
- // we'd get a very thin, leaking indicator color, which is not what we want.
- .absolute()
- .size_2p5()
- .right_0()
- .bottom_0()
- .bg(indicator_border_color)
- .size_2p5()
- .rounded_full()
- .items_center()
- .justify_center()
- .overflow_hidden()
- .child(Indicator::dot().color(indicator_color));
-
Some(
- div()
- .relative()
+ ButtonLike::new("ssh-server-icon")
.child(
- IconButton::new("ssh-server-icon", IconName::Server)
- .icon_size(IconSize::Small)
- .shape(IconButtonShape::Square)
- .icon_color(icon_color)
- .tooltip(move |cx| {
- Tooltip::with_meta(
- "Remote Project",
- Some(&OpenRemote),
- meta.clone(),
- cx,
- )
- })
- .on_click(|_, cx| {
- cx.dispatch_action(OpenRemote.boxed_clone());
- }),
+ IconWithIndicator::new(
+ Icon::new(IconName::Server).color(icon_color),
+ Some(Indicator::dot().color(indicator_color)),
+ )
+ .indicator_border_color(Some(cx.theme().colors().title_bar_background))
+ .into_any_element(),
)
- .child(indicator)
+ .tooltip(move |cx| {
+ Tooltip::with_meta("Remote Project", Some(&OpenRemote), meta.clone(), cx)
+ })
+ .on_click(|_, cx| {
+ cx.dispatch_action(OpenRemote.boxed_clone());
+ })
.into_any_element(),
)
}
diff --git a/crates/ui/src/components/icon.rs b/crates/ui/src/components/icon.rs
index 8d374ef67ca..683bcec5a8c 100644
--- a/crates/ui/src/components/icon.rs
+++ b/crates/ui/src/components/icon.rs
@@ -473,13 +473,12 @@ impl RenderOnce for IconWithIndicator {
this.child(
div()
.absolute()
- .w_2()
- .h_2()
- .border_1()
+ .size_2p5()
+ .border_2()
.border_color(indicator_border_color)
.rounded_full()
.bottom_neg_0p5()
- .right_neg_1()
+ .right_neg_0p5()
.child(indicator),
)
})