1
1
use crate :: { Card , CardFooter , CardHeader , CardHeaderExtra , Icon , Scrollbar , ScrollbarRef } ;
2
2
use leptos:: * ;
3
- use thaw_components:: { CSSTransition , FocusTrap , OptionComp , Teleport } ;
4
- use thaw_utils:: { mount_style, use_click_position, ComponentRef , Model } ;
3
+ use thaw_components:: { CSSTransition , FocusTrap , If , OptionComp , Teleport , Then } ;
4
+ use thaw_utils:: { class_list , mount_style, use_click_position, ComponentRef , Model , OptionalProp } ;
5
5
6
6
#[ slot]
7
7
pub struct ModalFooter {
@@ -13,11 +13,13 @@ pub fn Modal(
13
13
#[ prop( into) ] show : Model < bool > ,
14
14
#[ prop( default = true . into( ) , into) ] mask_closeable : MaybeSignal < bool > ,
15
15
#[ prop( default = true , into) ] close_on_esc : bool ,
16
+ #[ prop( default = true , into) ] closable : bool ,
16
17
#[ prop( default = 2000 . into( ) , into) ] z_index : MaybeSignal < i16 > ,
17
18
#[ prop( default = MaybeSignal :: Static ( "600px" . to_string( ) ) , into) ] width : MaybeSignal < String > ,
18
19
#[ prop( optional, into) ] title : MaybeSignal < String > ,
19
20
children : Children ,
20
21
#[ prop( optional) ] modal_footer : Option < ModalFooter > ,
22
+ #[ prop( optional, into) ] class : OptionalProp < MaybeSignal < String > > ,
21
23
) -> impl IntoView {
22
24
mount_style ( "modal" , include_str ! ( "./modal.css" ) ) ;
23
25
@@ -80,6 +82,7 @@ pub fn Modal(
80
82
String :: from( "display: none" )
81
83
}
82
84
} )
85
+
83
86
comp_ref=scrollbar_ref
84
87
>
85
88
<CSSTransition
@@ -106,7 +109,9 @@ pub fn Modal(
106
109
let : display
107
110
>
108
111
<div
109
- class="thaw-modal-body"
112
+ class=class_list![
113
+ "thaw-modal-body" , class. map( | c | move || c. get( ) )
114
+ ]
110
115
ref=modal_ref
111
116
role="dialog"
112
117
aria-modal="true"
@@ -117,12 +122,16 @@ pub fn Modal(
117
122
<span class="thaw-model-title" >{ move || title. get( ) } </span>
118
123
</CardHeader >
119
124
<CardHeaderExtra slot>
120
- <span
121
- style="cursor: pointer;"
122
- on: click=move |_| show. set( false )
123
- >
124
- <Icon icon=icondata_ai:: AiCloseOutlined />
125
- </span>
125
+ <If cond=closable>
126
+ <Then slot>
127
+ <span
128
+ style="cursor: pointer;"
129
+ on: click=move |_| show. set( false )
130
+ >
131
+ <Icon icon=icondata_ai:: AiCloseOutlined />
132
+ </span>
133
+ </Then >
134
+ </If >
126
135
</CardHeaderExtra >
127
136
{ children( ) }
128
137
<CardFooter slot if_=modal_footer. is_some( ) >
0 commit comments