Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Make channel buttons square (#4092)
Marshall Bowersdf67917768b4
diff --git a/crates/collab_ui/src/collab_panel.rs b/crates/collab_ui/src/collab_panel.rsindex 47c5463e921..d6de5135711 100644--- a/crates/collab_ui/src/collab_panel.rs+++ b/crates/collab_ui/src/collab_panel.rs@@ -2314,7 +2314,7 @@ impl CollabPanel {.child(IconButton::new("channel_chat", IconName::MessageBubbles).style(ButtonStyle::Filled)- .size(ButtonSize::Compact)+ .shape(ui::IconButtonShape::Square).icon_size(IconSize::Small).icon_color(if has_messages_notification {Color::Default@@ -2332,7 +2332,7 @@ impl CollabPanel {.child(IconButton::new("channel_notes", IconName::File).style(ButtonStyle::Filled)- .size(ButtonSize::Compact)+ .shape(ui::IconButtonShape::Square).icon_size(IconSize::Small).icon_color(if has_notes_notification {Color::Defaultdiff --git a/crates/ui/src/components/button/icon_button.rs b/crates/ui/src/components/button/icon_button.rsindex 1e37a872922..cc1e31b65cb 100644--- a/crates/ui/src/components/button/icon_button.rs+++ b/crates/ui/src/components/button/icon_button.rs@@ -127,16 +127,25 @@ impl VisibleOnHover for IconButton {}impl RenderOnce for IconButton {- fn render(self, _cx: &mut WindowContext) -> impl IntoElement {+ fn render(self, cx: &mut WindowContext) -> impl IntoElement {let is_disabled = self.base.disabled;let is_selected = self.base.selected;let selected_style = self.base.selected_style;self.base.map(|this| match self.shape {- IconButtonShape::Square => this- .width(self.icon_size.rems().into())- .height(self.icon_size.rems().into()),+ IconButtonShape::Square => {+ let icon_size = self.icon_size.rems() * cx.rem_size();+ let padding = match self.icon_size {+ IconSize::Indicator => px(0.),+ IconSize::XSmall => px(0.),+ IconSize::Small => px(2.),+ IconSize::Medium => px(2.),+ };++ this.width((icon_size + padding * 2.).into())+ .height((icon_size + padding * 2.).into())+ }IconButtonShape::Wide => this,}).child(diff --git a/crates/ui/src/components/stories/icon_button.rs b/crates/ui/src/components/stories/icon_button.rsindex df9f37b1647..ba3d5fd8660 100644--- a/crates/ui/src/components/stories/icon_button.rs+++ b/crates/ui/src/components/stories/icon_button.rs@@ -1,7 +1,7 @@use gpui::Render;use story::{StoryContainer, StoryItem, StorySection};-use crate::{prelude::*, Tooltip};+use crate::{prelude::*, IconButtonShape, Tooltip};use crate::{IconButton, IconName};pub struct IconButtonStory;@@ -115,7 +115,34 @@ impl Render for IconButtonStory {"Icon Button","crates/ui2/src/components/stories/icon_button.rs",)- .children(vec![StorySection::new().children(buttons)])+ .child(StorySection::new().children(buttons))+ .child(+ StorySection::new().child(StoryItem::new(+ "Square",+ h_flex()+ .gap_2()+ .child(+ IconButton::new("square-medium", IconName::Close)+ .shape(IconButtonShape::Square)+ .icon_size(IconSize::Medium),+ )+ .child(+ IconButton::new("square-small", IconName::Close)+ .shape(IconButtonShape::Square)+ .icon_size(IconSize::Small),+ )+ .child(+ IconButton::new("square-xsmall", IconName::Close)+ .shape(IconButtonShape::Square)+ .icon_size(IconSize::XSmall),+ )+ .child(+ IconButton::new("square-indicator", IconName::Close)+ .shape(IconButtonShape::Square)+ .icon_size(IconSize::Indicator),+ ),+ )),+ ).into_element()}}