From d53b30ff9f7569c174838a3125095955b9daf7b1 Mon Sep 17 00:00:00 2001 From: ihavecoke Date: Wed, 13 Nov 2024 14:38:47 +0800 Subject: [PATCH] drawer: Set paddings to base to support override drawer body paddings. (#413) Co-authored-by: Jason Lee --- crates/story/src/modal_story.rs | 11 ++++------- crates/ui/src/drawer.rs | 8 ++++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/crates/story/src/modal_story.rs b/crates/story/src/modal_story.rs index 4e8cb8c3..228ba538 100644 --- a/crates/story/src/modal_story.rs +++ b/crates/story/src/modal_story.rs @@ -19,10 +19,7 @@ use ui::{ theme::ActiveTheme as _, v_flex, webview::WebView, - ContextModal as _, - Icon, - IconName, - Placement + ContextModal as _, Icon, IconName, Placement, }; actions!(modal_story, [TestAction]); @@ -499,18 +496,18 @@ impl Render for ModalStory { WebView::new(cx, webview) }); webview.update(cx, |webview, _| { - webview.load_url("https://github.com"); + webview.load_url("https://github.com/explore"); }); cx.open_drawer(move |drawer, cx| { let height = cx.window_bounds().get_bounds().size.height; let webview_bounds = webview.read(cx).bounds(); - let buffer_height = px(12.); drawer .title("WebView Title") + .p_0() .child( div() - .h(height - webview_bounds.origin.y - buffer_height) + .h(height - webview_bounds.origin.y) .child(webview.clone()) ) }); diff --git a/crates/ui/src/drawer.rs b/crates/ui/src/drawer.rs index afcfb055..ac363056 100644 --- a/crates/ui/src/drawer.rs +++ b/crates/ui/src/drawer.rs @@ -48,7 +48,7 @@ impl Drawer { resizable: true, title: None, footer: None, - content: v_flex(), + content: v_flex().px_4().py_3(), margin_top: TITLE_BAR_HEIGHT, overlay: true, on_close: Rc::new(|_, _| {}), @@ -189,7 +189,7 @@ impl RenderOnce for Drawer { h_flex() .justify_between() .px_4() - .py_3() + .py_2() .w_full() .child(self.title.unwrap_or(div().into_any_element())) .child( @@ -204,10 +204,9 @@ impl RenderOnce for Drawer { ), ) .child( + // Body div().flex_1().overflow_hidden().child( v_flex() - .p_4() - .pt_0() .scrollable( cx.parent_view_id().unwrap_or_default(), ScrollbarAxis::Vertical, @@ -216,6 +215,7 @@ impl RenderOnce for Drawer { ), ) .when_some(self.footer, |this, footer| { + // Footer this.child( h_flex() .justify_between()