Sidebar collapses from a hover strip on its right edge instead of a header arrow
Browse files at this commitaef2bdf9f27aa5b21a43d05337075319d12a5c17Parent: 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
1 changed file +34 -29
- crates/client/src/gui/sidebar.rs +34 -29
crates/client/src/gui/sidebar.rsmodified+34 -29
| @@ -51,14 +51,20 @@ impl Yumush { | ||
| 51 | 51 | .flex_shrink_0() |
| 52 | 52 | .overflow_hidden() |
| 53 | 53 | .child(content); |
| 54 | - match self.chat.sidebar_toggled { | |
| 54 | + let sidebar = match self.chat.sidebar_toggled { | |
| 55 | 55 | Some(at) if at.elapsed() < motion().duration => sidebar |
| 56 | 56 | .with_animation(id, motion(), move |sidebar, delta| { |
| 57 | 57 | sidebar.w(px(from + (to - from) * delta)) |
| 58 | 58 | }) |
| 59 | 59 | .into_any_element(), |
| 60 | 60 | _ => 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)) | |
| 62 | 68 | } |
| 63 | 69 | |
| 64 | 70 | fn collapsed_sidebar(&self, entity: &Entity<Self>, palette: Palette) -> Div { |
| @@ -68,9 +74,8 @@ impl Yumush { | ||
| 68 | 74 | .flex() |
| 69 | 75 | .flex_col() |
| 70 | 76 | .items_center() |
| 71 | - .justify_between() | |
| 77 | + .justify_end() | |
| 72 | 78 | .py(px(space::MD)) |
| 73 | - .child(self.collapse_button(entity, palette)) | |
| 74 | 79 | .child( |
| 75 | 80 | div() |
| 76 | 81 | .flex() |
| @@ -134,8 +139,7 @@ impl Yumush { | ||
| 134 | 139 | "New community", |
| 135 | 140 | new_community(entity), |
| 136 | 141 | )) |
| 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)), | |
| 139 | 143 | ) |
| 140 | 144 | .child( |
| 141 | 145 | div() |
| @@ -371,29 +375,30 @@ impl Yumush { | ||
| 371 | 375 | self.select_community(community_id, window, cx); |
| 372 | 376 | } |
| 373 | 377 | |
| 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" | |
| 384 | 391 | } 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 | + }) | |
| 397 | 402 | } |
| 398 | 403 | |
| 399 | 404 | pub(super) fn open_friends(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| @@ -474,7 +479,7 @@ impl Yumush { | ||
| 474 | 479 | .justify_center() |
| 475 | 480 | .rounded_full() |
| 476 | 481 | .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))) | |
| 478 | 483 | .children(alert.then(|| { |
| 479 | 484 | div() |
| 480 | 485 | .absolute() |