diff --git a/crates/client/src/gui/sidebar.rs b/crates/client/src/gui/sidebar.rs index ff01e0f..4dacea4 100644 --- a/crates/client/src/gui/sidebar.rs +++ b/crates/client/src/gui/sidebar.rs @@ -51,14 +51,20 @@ impl Yumush { .flex_shrink_0() .overflow_hidden() .child(content); - match self.chat.sidebar_toggled { + let sidebar = match self.chat.sidebar_toggled { Some(at) if at.elapsed() < motion().duration => sidebar .with_animation(id, motion(), move |sidebar, delta| { sidebar.w(px(from + (to - from) * delta)) }) .into_any_element(), _ => sidebar.w(px(to)).into_any_element(), - } + }; + div() + .relative() + .h_full() + .flex_shrink_0() + .child(sidebar) + .child(self.sidebar_edge(entity, palette)) } fn collapsed_sidebar(&self, entity: &Entity, palette: Palette) -> Div { @@ -68,9 +74,8 @@ impl Yumush { .flex() .flex_col() .items_center() - .justify_between() + .justify_end() .py(px(space::MD)) - .child(self.collapse_button(entity, palette)) .child( div() .flex() @@ -134,8 +139,7 @@ impl Yumush { "New community", new_community(entity), )) - .child(self.friends_button(entity, friends_alert, palette)) - .child(self.collapse_button(entity, palette)), + .child(self.friends_button(entity, friends_alert, palette)), ) .child( div() @@ -371,29 +375,30 @@ impl Yumush { self.select_community(community_id, window, cx); } - fn collapse_button(&self, entity: &Entity, palette: Palette) -> AnyElement { - let (icon, tip) = if self.chat.sidebar_collapsed { - (IconName::ArrowRight, "Expand") - } else { - (IconName::ArrowLeft, "Collapse") - }; - - icon_button( - if self.chat.sidebar_collapsed { - "sidebar_expand" + fn sidebar_edge(&self, entity: &Entity, palette: Palette) -> impl IntoElement { + let border = palette.border; + div() + .id("sidebar_edge") + .absolute() + .top_0() + .right_0() + .h_full() + .w(px(space::XS)) + .cursor_pointer() + .hover(move |style| style.bg(border)) + .tip(if self.chat.sidebar_collapsed { + "Expand" } else { - "sidebar_collapse" - }, - palette, - icon, - tip, - entity_action(entity, |yumush, _, cx| { - yumush.chat.sidebar_collapsed = !yumush.chat.sidebar_collapsed; - yumush.chat.sidebar_toggled = Some(std::time::Instant::now()); - cx.notify(); - }), - ) - .into_any_element() + "Collapse" + }) + .on_click({ + let toggle = entity_action(entity, |yumush, _, cx| { + yumush.chat.sidebar_collapsed = !yumush.chat.sidebar_collapsed; + yumush.chat.sidebar_toggled = Some(std::time::Instant::now()); + cx.notify(); + }); + move |_, window, cx| toggle(window, cx) + }) } pub(super) fn open_friends(&mut self, window: &mut Window, cx: &mut Context) { @@ -474,7 +479,7 @@ impl Yumush { .justify_center() .rounded_full() .text_color(palette.muted) - .child(Icon::new(IconName::HeartHandshake).size(px(size::ICON_SM))) + .child(Icon::new(IconName::ContactRound).size(px(size::ICON_SM))) .children(alert.then(|| { div() .absolute()