Skip to content

Commit

Permalink
Improve doc aside repsonsiveness in the context menu
Browse files Browse the repository at this point in the history
Co-authored-by: Agus Zubiaga <[email protected]>
  • Loading branch information
danilo-leal and agu-z committed Feb 21, 2025
1 parent c9235ff commit 1700ce4
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions crates/ui/src/components/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,26 +508,33 @@ impl ContextMenuItem {
impl Render for ContextMenu {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let ui_font_size = ThemeSettings::get_global(cx).ui_font_size(cx);
let window_size = window.viewport_size();
let rem_size = window.rem_size();
let is_wide_window = window_size.width / rem_size > rems_from_px(800.).0;

let aside = self
.documentation_aside
.as_ref()
.map(|(_, callback)| callback.clone());

h_flex()
.when(is_wide_window, |this| {this.flex_row()})
.when(!is_wide_window, |this| {this.flex_col()})
.w_full()
.items_start()
.gap_1()
.when_some(aside, |this, aside| {
this.child(
.child(
div().children(aside.map(|aside|
WithRemSize::new(ui_font_size)
.occlude()
.elevation_2(cx)
.p_2()
.max_w_96()
.child(aside(cx)),
)
})
.overflow_hidden()
.when(is_wide_window, |this| {this.max_w_96()})
.when(!is_wide_window, |this| {this.max_w_48()})
.child(aside(cx))
))
)
.child(
WithRemSize::new(ui_font_size)
.occlude()
Expand Down

0 comments on commit 1700ce4

Please sign in to comment.