From e361d86c4b2426d5e73ed9276055ffdc67b3f800 Mon Sep 17 00:00:00 2001 From: luoxiao Date: Mon, 5 Feb 2024 14:58:39 +0800 Subject: [PATCH] feat: drawer adds mount prop --- demo_markdown/docs/drawer/mod.md | 17 +++++++++++++++ thaw/src/drawer/mod.rs | 36 ++++++++++++++++++++++++++++---- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/demo_markdown/docs/drawer/mod.md b/demo_markdown/docs/drawer/mod.md index f8e4fb7..ff84c2c 100644 --- a/demo_markdown/docs/drawer/mod.md +++ b/demo_markdown/docs/drawer/mod.md @@ -22,6 +22,21 @@ view! { } ``` +### Customize display area + +```rust demo +let show = create_rw_signal(false); + +view! { +
+ + + "Current position" + +
+} +``` + ### Drawer Props | Name | Type | Default | Desciption | @@ -32,4 +47,6 @@ view! { | placement | `MaybeSignal` | `DrawerPlacement::Right` | Drawer placement. | | width | `MaybeSignal` | `520px` | Drawer width. | | height | `MaybeSignal` | `260px` | Drawer height. | +| z_index | `MaybeSignal` | `2000` | z-index of the drawer. | +| mount | `DrawerMount` | `DrawerMount::Body` | Container node of the drawer. | | children | `Children` | | Drawer content. | diff --git a/thaw/src/drawer/mod.rs b/thaw/src/drawer/mod.rs index eaa4946..627d719 100644 --- a/thaw/src/drawer/mod.rs +++ b/thaw/src/drawer/mod.rs @@ -12,7 +12,8 @@ pub fn Drawer( #[prop(optional, into)] placement: MaybeSignal, #[prop(default = MaybeSignal::Static("520px".to_string()), into)] width: MaybeSignal, #[prop(default = MaybeSignal::Static("260px".to_string()), into)] height: MaybeSignal, - #[prop(default = MaybeSignal::Static("2000".to_string()), into)] z_index: MaybeSignal, + #[prop(default = 2000.into(), into)] z_index: MaybeSignal, + #[prop(optional, into)] mount: DrawerMount, #[prop(optional, into)] class: OptionalProp>, children: Children, ) -> impl IntoView { @@ -24,8 +25,17 @@ pub fn Drawer( css_vars }); - view! { - + #[component] + fn DrawerInnr( + show: Model, + title: OptionalProp>, + placement: MaybeSignal, + z_index: MaybeSignal, + class: OptionalProp>, + css_vars: Memo, + children: Children, + ) -> impl IntoView { + view! {
{children()}
-
+ } + } + + match mount { + DrawerMount::None => view! { + + }, + DrawerMount::Body => view! { + + + + }, } } @@ -65,3 +86,10 @@ impl DrawerPlacement { } } } + +#[derive(Default)] +pub enum DrawerMount { + None, + #[default] + Body, +}