From a9f02ede65a139d083ed994bab32128f1123472c Mon Sep 17 00:00:00 2001 From: kandrelczyk Date: Mon, 10 Jun 2024 17:30:31 +0200 Subject: [PATCH] add class to modal (#206) * add class to modal * add class to modal * add closable option to modal --- demo_markdown/docs/modal/mod.md | 2 ++ thaw/src/modal/mod.rs | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/demo_markdown/docs/modal/mod.md b/demo_markdown/docs/modal/mod.md index a62b3fa..2c0da87 100644 --- a/demo_markdown/docs/modal/mod.md +++ b/demo_markdown/docs/modal/mod.md @@ -15,12 +15,14 @@ view! { | Name | Type | Default | Description | | -------------- | --------------------- | -------------------- | ------------------------------------------- | +| class | `OptionalProp>` | `Default::default()` | Addtional classes for the modal element. | | show | `Model` | | Whether to show modal. | | title | `MaybeSignal` | `Default::default()` | Modal title. | | width | `MaybeSignal` | `600px` | Modal width. | | z_index | `MaybeSignal` | `2000` | z-index of the modal. | | mask_closeable | `MaybeSignal` | `true` | Whether to emit hide event when click mask. | | close_on_esc | `bool` | `true` | Whether to close modal on Esc is pressed. | +| closable | `bool` | `true` | Whether to display the close button. | | children | `Children` | | Modal's content. | ### Modal Slots diff --git a/thaw/src/modal/mod.rs b/thaw/src/modal/mod.rs index 396ad7d..3b54d25 100644 --- a/thaw/src/modal/mod.rs +++ b/thaw/src/modal/mod.rs @@ -1,7 +1,7 @@ use crate::{Card, CardFooter, CardHeader, CardHeaderExtra, Icon, Scrollbar, ScrollbarRef}; use leptos::*; -use thaw_components::{CSSTransition, FocusTrap, OptionComp, Teleport}; -use thaw_utils::{mount_style, use_click_position, ComponentRef, Model}; +use thaw_components::{CSSTransition, FocusTrap, If, OptionComp, Teleport, Then}; +use thaw_utils::{class_list, mount_style, use_click_position, ComponentRef, Model, OptionalProp}; #[slot] pub struct ModalFooter { @@ -13,11 +13,13 @@ pub fn Modal( #[prop(into)] show: Model, #[prop(default = true.into(), into)] mask_closeable: MaybeSignal, #[prop(default = true, into)] close_on_esc: bool, + #[prop(default = true, into)] closable: bool, #[prop(default = 2000.into(), into)] z_index: MaybeSignal, #[prop(default = MaybeSignal::Static("600px".to_string()), into)] width: MaybeSignal, #[prop(optional, into)] title: MaybeSignal, children: Children, #[prop(optional)] modal_footer: Option, + #[prop(optional, into)] class: OptionalProp>, ) -> impl IntoView { mount_style("modal", include_str!("./modal.css")); @@ -80,6 +82,7 @@ pub fn Modal( String::from("display: none") } }) + comp_ref=scrollbar_ref >