diff --git a/crates/core/src/dialog.rs b/crates/core/src/dialog.rs index d29315d..528ab42 100644 --- a/crates/core/src/dialog.rs +++ b/crates/core/src/dialog.rs @@ -2,9 +2,10 @@ use gpui::prelude::FluentBuilder as _; use std::rc::Rc; use gpui::{ - Animation, AnimationExt as _, AnyElement, App, ElementId, FontWeight, InteractiveElement as _, - IntoElement, KeyDownEvent, MouseButton, ParentElement as _, RenderOnce, Role, SharedString, - StatefulInteractiveElement as _, Styled as _, Window, canvas, div, ease_out_quint, relative, + Animation, AnimationExt as _, AnyElement, App, DefiniteLength, ElementId, FontWeight, + InteractiveElement as _, IntoElement, KeyDownEvent, MouseButton, ParentElement as _, + RenderOnce, Role, SharedString, StatefulInteractiveElement as _, Styled as _, Window, canvas, + div, ease_out_quint, relative, }; use gpui_native_icons::IconRole; use gpui_native_theme::ActiveTheme as _; @@ -29,6 +30,7 @@ pub struct Dialog { on_change: Option, content: Option, actions: Option, + min_width: Option, } impl Dialog { @@ -46,6 +48,7 @@ impl Dialog { on_change: None, content: None, actions: None, + min_width: None, } } @@ -105,6 +108,15 @@ impl Dialog { self.a11y_label = Some(label.into()); self } + + /// Sets the panel's minimum width, defaults to the standard dialog width. + pub fn min_width(mut self, width: W) -> Self + where + W: Into, + { + self.min_width = Some(width.into()); + self + } } impl RenderOnce for Dialog { @@ -171,7 +183,8 @@ impl RenderOnce for Dialog { .track_focus(&focus) .role(role) .aria_label(label) - .min_w_64() + .when_some(self.min_width, |panel, width| panel.min_w(width)) + .when(self.min_width.is_none(), |panel| panel.min_w_80()) .max_w(relative(0.9)) .p_4() .gap_3()