diff --git a/crates/story/src/modal_story.rs b/crates/story/src/modal_story.rs index f946f9c8..4e58be32 100644 --- a/crates/story/src/modal_story.rs +++ b/crates/story/src/modal_story.rs @@ -13,7 +13,7 @@ use gpui_component::{ input::{InputState, TextInput}, modal::ModalButtonProps, text::TextView, - v_flex, ContextModal as _, + v_flex, ActiveTheme, ContextModal as _, }; use crate::section; @@ -374,6 +374,28 @@ impl Render for ModalStory { }); })), ), + ) + .child( + section("Custom Modal style").child( + Button::new("custom-modal-style") + .label("Custom Modal Style") + .on_click(cx.listener(move |_, _, window, cx| { + window.open_modal(cx, move |modal, _, cx| { + modal + .rounded_lg() + .p_0() + .title(div().pt_4().px_4().child("Custom Modal Title")) + .child( + div() + .bg(cx.theme().info) + .text_color(cx.theme().info_foreground) + .p_4() + .rounded_b_lg() + .child("This is a custom modal content."), + ) + }); + })), + ), ), ) } diff --git a/crates/ui/src/modal.rs b/crates/ui/src/modal.rs index d7a50440..d1c89bf4 100644 --- a/crates/ui/src/modal.rs +++ b/crates/ui/src/modal.rs @@ -12,9 +12,7 @@ use crate::{ actions::{Cancel, Confirm}, animation::cubic_bezier, button::{Button, ButtonVariant, ButtonVariants as _}, - h_flex, - scroll::ScrollbarAxis, - v_flex, ActiveTheme as _, ContextModal, IconName, Root, Sizable as _, StyledExt, + h_flex, v_flex, ActiveTheme as _, ContextModal, IconName, Root, Sizable as _, StyledExt, }; const CONTEXT: &str = "Modal"; @@ -393,7 +391,7 @@ impl RenderOnce for Modal { .rounded(border_radius) .shadow_xl() .min_h_24() - .py_4() + .p_4() .gap_4() .refine_style(&self.style) .key_context(CONTEXT) @@ -437,11 +435,7 @@ impl RenderOnce for Modal { .when_some(self.max_width, |this, w| this.max_w(w)) .when_some(self.title, |this, title| { this.child( - div() - .font_semibold() - .px_4() - .line_height(relative(1.)) - .child(title), + div().font_semibold().line_height(relative(1.)).child(title), ) }) .when(self.show_close, |this| { @@ -461,17 +455,16 @@ impl RenderOnce for Modal { ) }) .child( - div().w_full().flex_1().overflow_hidden().child( - v_flex() - .scrollable(window.current_view(), ScrollbarAxis::Vertical) - .px_4() - .child(self.content), - ), + div() + .w_full() + .flex_1() + .overflow_hidden() + .child(self.content), ) .when(self.footer.is_some(), |this| { let footer = self.footer.unwrap(); - this.child(h_flex().px_4().gap_2().justify_end().children(footer( + this.child(h_flex().gap_2().justify_end().children(footer( render_ok, render_cancel, window,