diff --git a/thaw/src/drawer/docs/mod.md b/thaw/src/drawer/docs/mod.md index c541eb1..62fd874 100644 --- a/thaw/src/drawer/docs/mod.md +++ b/thaw/src/drawer/docs/mod.md @@ -39,6 +39,34 @@ view! { } ``` +### Overlay No Modal + +```rust demo +let open = RwSignal::new(false); + +view! { + + + + + + + + "Default Drawer" + + + +

"Drawer content"

+
+
+} +``` + ### Inline ```rust demo @@ -151,6 +179,7 @@ view! { | close_on_esc | `bool` | `false` | Whether to close drawer on Esc is pressed. | | position | `MaybeSignal` | `DrawerPlacement::Left` | Position of the drawer. | | size | `MaybeSignal` | `DrawerSize::Small` | Size of the drawer. | +| modal_type | `DrawerModalType` | `DrawerModalType::Modal` | Dialog variations. | | children | `Children` | | | ### InlineDrawer Props diff --git a/thaw/src/drawer/mod.rs b/thaw/src/drawer/mod.rs index 97bea06..13500a8 100644 --- a/thaw/src/drawer/mod.rs +++ b/thaw/src/drawer/mod.rs @@ -54,3 +54,14 @@ impl DrawerSize { } } } + +#[derive(Debug, Default, PartialEq)] +pub enum DrawerModalType { + /// When this type of dialog is open, + /// the rest of the page is dimmed out and cannot be interacted with. + #[default] + Modal, + /// When a non-modal dialog is open, + /// the rest of the page is not dimmed out and users can interact with the rest of the page. + NonModal, +} diff --git a/thaw/src/drawer/overlay_drawer.rs b/thaw/src/drawer/overlay_drawer.rs index b383e32..2ca6f38 100644 --- a/thaw/src/drawer/overlay_drawer.rs +++ b/thaw/src/drawer/overlay_drawer.rs @@ -1,6 +1,6 @@ -use super::{DrawerPosition, DrawerSize}; +use super::{DrawerModalType, DrawerPosition, DrawerSize}; use crate::ConfigInjection; -use leptos::{ev, html, prelude::*}; +use leptos::{either::Either, ev, html, prelude::*}; use thaw_components::{CSSTransition, FocusTrap, Teleport}; use thaw_utils::{class_list, mount_style, use_lock_html_scroll, Model}; @@ -22,6 +22,9 @@ pub fn OverlayDrawer( /// Size of the drawer. #[prop(optional, into)] size: MaybeSignal, + /// Dialog variations. + #[prop(optional, into)] + modal_type: DrawerModalType, children: Children, ) -> impl IntoView { mount_style("drawer", include_str!("./drawer.css")); @@ -60,20 +63,28 @@ pub fn OverlayDrawer( class=class_list!["thaw-config-provider thaw-overlay-drawer-container", class] data-thaw-id=config_provider.id() > - -
-
+ {if modal_type == DrawerModalType::Modal { + Either::Left( + view! { + +
+
+ }, + ) + } else { + Either::Right(()) + }}