Make channel buttons square (#4092)
This PR makes the channel buttons square. Release Notes: - Adjusted the shape of the channel buttons.
This commit is contained in:
parent
19c488b378
commit
df67917768
3 changed files with 44 additions and 8 deletions
|
@ -2314,7 +2314,7 @@ impl CollabPanel {
|
||||||
.child(
|
.child(
|
||||||
IconButton::new("channel_chat", IconName::MessageBubbles)
|
IconButton::new("channel_chat", IconName::MessageBubbles)
|
||||||
.style(ButtonStyle::Filled)
|
.style(ButtonStyle::Filled)
|
||||||
.size(ButtonSize::Compact)
|
.shape(ui::IconButtonShape::Square)
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.icon_color(if has_messages_notification {
|
.icon_color(if has_messages_notification {
|
||||||
Color::Default
|
Color::Default
|
||||||
|
@ -2332,7 +2332,7 @@ impl CollabPanel {
|
||||||
.child(
|
.child(
|
||||||
IconButton::new("channel_notes", IconName::File)
|
IconButton::new("channel_notes", IconName::File)
|
||||||
.style(ButtonStyle::Filled)
|
.style(ButtonStyle::Filled)
|
||||||
.size(ButtonSize::Compact)
|
.shape(ui::IconButtonShape::Square)
|
||||||
.icon_size(IconSize::Small)
|
.icon_size(IconSize::Small)
|
||||||
.icon_color(if has_notes_notification {
|
.icon_color(if has_notes_notification {
|
||||||
Color::Default
|
Color::Default
|
||||||
|
|
|
@ -127,16 +127,25 @@ impl VisibleOnHover for IconButton {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RenderOnce 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_disabled = self.base.disabled;
|
||||||
let is_selected = self.base.selected;
|
let is_selected = self.base.selected;
|
||||||
let selected_style = self.base.selected_style;
|
let selected_style = self.base.selected_style;
|
||||||
|
|
||||||
self.base
|
self.base
|
||||||
.map(|this| match self.shape {
|
.map(|this| match self.shape {
|
||||||
IconButtonShape::Square => this
|
IconButtonShape::Square => {
|
||||||
.width(self.icon_size.rems().into())
|
let icon_size = self.icon_size.rems() * cx.rem_size();
|
||||||
.height(self.icon_size.rems().into()),
|
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,
|
IconButtonShape::Wide => this,
|
||||||
})
|
})
|
||||||
.child(
|
.child(
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use gpui::Render;
|
use gpui::Render;
|
||||||
use story::{StoryContainer, StoryItem, StorySection};
|
use story::{StoryContainer, StoryItem, StorySection};
|
||||||
|
|
||||||
use crate::{prelude::*, Tooltip};
|
use crate::{prelude::*, IconButtonShape, Tooltip};
|
||||||
use crate::{IconButton, IconName};
|
use crate::{IconButton, IconName};
|
||||||
|
|
||||||
pub struct IconButtonStory;
|
pub struct IconButtonStory;
|
||||||
|
@ -115,7 +115,34 @@ impl Render for IconButtonStory {
|
||||||
"Icon Button",
|
"Icon Button",
|
||||||
"crates/ui2/src/components/stories/icon_button.rs",
|
"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()
|
.into_element()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue