Polish off channel buttons (#3858)
This PR polishes off the channel buttons such that they behave as expected. The absolutely-positioned button container will now no longer take up space—and thus obscure the channel name—when there are no notifications and the channel entry is not hovered. Release Notes: - N/A
This commit is contained in:
parent
b4a205b37c
commit
f73f735d41
1 changed files with 84 additions and 57 deletions
|
@ -2110,6 +2110,47 @@ impl CollabPanel {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let button_container = |cx: &mut ViewContext<Self>| {
|
||||||
|
h_stack()
|
||||||
|
.absolute()
|
||||||
|
// We're using a negative coordinate for the right anchor to
|
||||||
|
// counteract the padding of the `ListItem`.
|
||||||
|
//
|
||||||
|
// This prevents a gap from showing up between the background
|
||||||
|
// of this element and the edge of the collab panel.
|
||||||
|
.right(rems(-0.5))
|
||||||
|
// HACK: Without this the channel name clips on top of the icons, but I'm not sure why.
|
||||||
|
.z_index(10)
|
||||||
|
.bg(cx.theme().colors().panel_background)
|
||||||
|
.when(is_selected || is_active, |this| {
|
||||||
|
this.bg(cx.theme().colors().ghost_element_selected)
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
let messages_button = |cx: &mut ViewContext<Self>| {
|
||||||
|
IconButton::new("channel_chat", Icon::MessageBubbles)
|
||||||
|
.icon_size(IconSize::Small)
|
||||||
|
.icon_color(if has_messages_notification {
|
||||||
|
Color::Default
|
||||||
|
} else {
|
||||||
|
Color::Muted
|
||||||
|
})
|
||||||
|
.on_click(cx.listener(move |this, _, cx| this.join_channel_chat(channel_id, cx)))
|
||||||
|
.tooltip(|cx| Tooltip::text("Open channel chat", cx))
|
||||||
|
};
|
||||||
|
|
||||||
|
let notes_button = |cx: &mut ViewContext<Self>| {
|
||||||
|
IconButton::new("channel_notes", Icon::File)
|
||||||
|
.icon_size(IconSize::Small)
|
||||||
|
.icon_color(if has_notes_notification {
|
||||||
|
Color::Default
|
||||||
|
} else {
|
||||||
|
Color::Muted
|
||||||
|
})
|
||||||
|
.on_click(cx.listener(move |this, _, cx| this.open_channel_notes(channel_id, cx)))
|
||||||
|
.tooltip(|cx| Tooltip::text("Open channel notes", cx))
|
||||||
|
};
|
||||||
|
|
||||||
let width = self.width.unwrap_or(px(240.));
|
let width = self.width.unwrap_or(px(240.));
|
||||||
|
|
||||||
div()
|
div()
|
||||||
|
@ -2172,63 +2213,49 @@ impl CollabPanel {
|
||||||
.child(Label::new(channel.name.clone()))
|
.child(Label::new(channel.name.clone()))
|
||||||
.children(face_pile.map(|face_pile| face_pile.render(cx))),
|
.children(face_pile.map(|face_pile| face_pile.render(cx))),
|
||||||
)
|
)
|
||||||
.end_slot(
|
.end_slot::<Div>(
|
||||||
h_stack()
|
// If we have a notification for either button, we want to show the corresponding
|
||||||
.absolute()
|
// button(s) as indicators.
|
||||||
// We're using a negative coordinate for the right anchor to
|
if has_messages_notification || has_notes_notification {
|
||||||
// counteract the padding of the `ListItem`.
|
Some(
|
||||||
//
|
button_container(cx).child(
|
||||||
// This prevents a gap from showing up between the background
|
h_stack()
|
||||||
// of this element and the edge of the collab panel.
|
.px_1()
|
||||||
.right(rems(-0.5))
|
.children(
|
||||||
// HACK: Without this the channel name clips on top of the icons, but I'm not sure why.
|
// We only want to render the messages button if there are unseen messages.
|
||||||
.z_index(10)
|
// This way we don't take up any space that might overlap the channel name
|
||||||
.bg(cx.theme().colors().panel_background)
|
// when there are no notifications.
|
||||||
.when(is_selected || is_active, |this| {
|
has_messages_notification.then(|| messages_button(cx)),
|
||||||
this.bg(cx.theme().colors().ghost_element_selected)
|
)
|
||||||
})
|
.child(
|
||||||
.child(
|
// We always want the notes button to take up space to prevent layout
|
||||||
h_stack()
|
// shift when hovering over the channel.
|
||||||
.px_1()
|
// However, if there are is no notes notification we just show an empty slot.
|
||||||
// The element hover background has a slight transparency to it, so we
|
notes_button(cx)
|
||||||
// need to apply it to the inner element so that it blends with the solid
|
.when(!has_notes_notification, |this| {
|
||||||
// background color of the absolutely-positioned element.
|
this.visible_on_hover("")
|
||||||
.group_hover("", |style| {
|
}),
|
||||||
style.bg(cx.theme().colors().ghost_element_hover)
|
),
|
||||||
})
|
),
|
||||||
.child(
|
)
|
||||||
IconButton::new("channel_chat", Icon::MessageBubbles)
|
} else {
|
||||||
.icon_size(IconSize::Small)
|
None
|
||||||
.icon_color(if has_messages_notification {
|
},
|
||||||
Color::Default
|
)
|
||||||
} else {
|
.end_hover_slot(
|
||||||
Color::Muted
|
// When we hover the channel entry we want to always show both buttons.
|
||||||
})
|
button_container(cx).child(
|
||||||
.when(!has_messages_notification, |this| {
|
h_stack()
|
||||||
this.visible_on_hover("")
|
.px_1()
|
||||||
})
|
// The element hover background has a slight transparency to it, so we
|
||||||
.on_click(cx.listener(move |this, _, cx| {
|
// need to apply it to the inner element so that it blends with the solid
|
||||||
this.join_channel_chat(channel_id, cx)
|
// background color of the absolutely-positioned element.
|
||||||
}))
|
.group_hover("", |style| {
|
||||||
.tooltip(|cx| Tooltip::text("Open channel chat", cx)),
|
style.bg(cx.theme().colors().ghost_element_hover)
|
||||||
)
|
})
|
||||||
.child(
|
.child(messages_button(cx))
|
||||||
IconButton::new("channel_notes", Icon::File)
|
.child(notes_button(cx)),
|
||||||
.icon_size(IconSize::Small)
|
),
|
||||||
.icon_color(if has_notes_notification {
|
|
||||||
Color::Default
|
|
||||||
} else {
|
|
||||||
Color::Muted
|
|
||||||
})
|
|
||||||
.when(!has_notes_notification, |this| {
|
|
||||||
this.visible_on_hover("")
|
|
||||||
})
|
|
||||||
.on_click(cx.listener(move |this, _, cx| {
|
|
||||||
this.open_channel_notes(channel_id, cx)
|
|
||||||
}))
|
|
||||||
.tooltip(|cx| Tooltip::text("Open channel notes", cx)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.tooltip(|cx| Tooltip::text("Join channel", cx))
|
.tooltip(|cx| Tooltip::text("Join channel", cx))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue