forge
Explore
Log in

Don't you dare go Hollow

Sidebar collapses from a hover strip on its right edge instead of a header arrow

Browse files at this commit

aef2bdf9f27aa5b21a43d05337075319d12a5c17Ahmet Kaan GümüşParent: 48153b0
  • style
    • sidebar collapses from a hover strip on its right edge instead of a header arrow
    • friends button back to the contact card now nothing boxy sits beside it
Show full message
💄 style: sidebar collapses from a hover strip on its right edge instead of a header arrow; friends button back to the contact card now nothing boxy sits beside it
crates/client/src/gui/sidebar.rsmodified+34 -29
@@ -51,14 +51,20 @@ impl Yumush {
5151 .flex_shrink_0()
5252 .overflow_hidden()
5353 .child(content);
54- match self.chat.sidebar_toggled {
54+ let sidebar = match self.chat.sidebar_toggled {
5555 Some(at) if at.elapsed() < motion().duration => sidebar
5656 .with_animation(id, motion(), move |sidebar, delta| {
5757 sidebar.w(px(from + (to - from) * delta))
5858 })
5959 .into_any_element(),
6060 _ => sidebar.w(px(to)).into_any_element(),
61- }
61+ };
62+ div()
63+ .relative()
64+ .h_full()
65+ .flex_shrink_0()
66+ .child(sidebar)
67+ .child(self.sidebar_edge(entity, palette))
6268 }
6369
6470 fn collapsed_sidebar(&self, entity: &Entity<Self>, palette: Palette) -> Div {
@@ -68,9 +74,8 @@ impl Yumush {
6874 .flex()
6975 .flex_col()
7076 .items_center()
71- .justify_between()
77+ .justify_end()
7278 .py(px(space::MD))
73- .child(self.collapse_button(entity, palette))
7479 .child(
7580 div()
7681 .flex()
@@ -134,8 +139,7 @@ impl Yumush {
134139 "New community",
135140 new_community(entity),
136141 ))
137- .child(self.friends_button(entity, friends_alert, palette))
138- .child(self.collapse_button(entity, palette)),
142+ .child(self.friends_button(entity, friends_alert, palette)),
139143 )
140144 .child(
141145 div()
@@ -371,29 +375,30 @@ impl Yumush {
371375 self.select_community(community_id, window, cx);
372376 }
373377
374- fn collapse_button(&self, entity: &Entity<Self>, palette: Palette) -> AnyElement {
375- let (icon, tip) = if self.chat.sidebar_collapsed {
376- (IconName::ArrowRight, "Expand")
377- } else {
378- (IconName::ArrowLeft, "Collapse")
379- };
380-
381- icon_button(
382- if self.chat.sidebar_collapsed {
383- "sidebar_expand"
378+ fn sidebar_edge(&self, entity: &Entity<Self>, palette: Palette) -> impl IntoElement {
379+ let border = palette.border;
380+ div()
381+ .id("sidebar_edge")
382+ .absolute()
383+ .top_0()
384+ .right_0()
385+ .h_full()
386+ .w(px(space::XS))
387+ .cursor_pointer()
388+ .hover(move |style| style.bg(border))
389+ .tip(if self.chat.sidebar_collapsed {
390+ "Expand"
384391 } else {
385- "sidebar_collapse"
386- },
387- palette,
388- icon,
389- tip,
390- entity_action(entity, |yumush, _, cx| {
391- yumush.chat.sidebar_collapsed = !yumush.chat.sidebar_collapsed;
392- yumush.chat.sidebar_toggled = Some(std::time::Instant::now());
393- cx.notify();
394- }),
395- )
396- .into_any_element()
392+ "Collapse"
393+ })
394+ .on_click({
395+ let toggle = entity_action(entity, |yumush, _, cx| {
396+ yumush.chat.sidebar_collapsed = !yumush.chat.sidebar_collapsed;
397+ yumush.chat.sidebar_toggled = Some(std::time::Instant::now());
398+ cx.notify();
399+ });
400+ move |_, window, cx| toggle(window, cx)
401+ })
397402 }
398403
399404 pub(super) fn open_friends(&mut self, window: &mut Window, cx: &mut Context<Self>) {
@@ -474,7 +479,7 @@ impl Yumush {
474479 .justify_center()
475480 .rounded_full()
476481 .text_color(palette.muted)
477- .child(Icon::new(IconName::HeartHandshake).size(px(size::ICON_SM)))
482+ .child(Icon::new(IconName::ContactRound).size(px(size::ICON_SM)))
478483 .children(alert.then(|| {
479484 div()
480485 .absolute()