@@ -12,7 +12,8 @@ pub fn Drawer(
12
12
#[ prop( optional, into) ] placement : MaybeSignal < DrawerPlacement > ,
13
13
#[ prop( default = MaybeSignal :: Static ( "520px" . to_string( ) ) , into) ] width : MaybeSignal < String > ,
14
14
#[ prop( default = MaybeSignal :: Static ( "260px" . to_string( ) ) , into) ] height : MaybeSignal < String > ,
15
- #[ prop( default = MaybeSignal :: Static ( "2000" . to_string( ) ) , into) ] z_index : MaybeSignal < String > ,
15
+ #[ prop( default = 2000 . into( ) , into) ] z_index : MaybeSignal < i16 > ,
16
+ #[ prop( optional, into) ] mount : DrawerMount ,
16
17
#[ prop( optional, into) ] class : OptionalProp < MaybeSignal < String > > ,
17
18
children : Children ,
18
19
) -> impl IntoView {
@@ -24,8 +25,17 @@ pub fn Drawer(
24
25
css_vars
25
26
} ) ;
26
27
27
- view ! {
28
- <Teleport >
28
+ #[ component]
29
+ fn DrawerInnr (
30
+ show : Model < bool > ,
31
+ title : OptionalProp < MaybeSignal < String > > ,
32
+ placement : MaybeSignal < DrawerPlacement > ,
33
+ z_index : MaybeSignal < i16 > ,
34
+ class : OptionalProp < MaybeSignal < String > > ,
35
+ css_vars : Memo < String > ,
36
+ children : Children ,
37
+ ) -> impl IntoView {
38
+ view ! {
29
39
<div
30
40
class="thaw-drawer-container"
31
41
style=move || if show. get( ) { format!( "z-index: {}" , z_index. get( ) ) } else { "display: none" . to_string( ) }
@@ -42,7 +52,18 @@ pub fn Drawer(
42
52
<Card title>{ children( ) } </Card >
43
53
</div>
44
54
</div>
45
- </Teleport >
55
+ }
56
+ }
57
+
58
+ match mount {
59
+ DrawerMount :: None => view ! {
60
+ <DrawerInnr show title placement z_index class css_vars children />
61
+ } ,
62
+ DrawerMount :: Body => view ! {
63
+ <Teleport >
64
+ <DrawerInnr show title placement z_index class css_vars children />
65
+ </Teleport >
66
+ } ,
46
67
}
47
68
}
48
69
@@ -65,3 +86,10 @@ impl DrawerPlacement {
65
86
}
66
87
}
67
88
}
89
+
90
+ #[ derive( Default ) ]
91
+ pub enum DrawerMount {
92
+ None ,
93
+ #[ default]
94
+ Body ,
95
+ }
0 commit comments