1
- use crate :: utils:: { class_list:: class_list, mount_style, OptionalProp } ;
1
+ use crate :: utils:: { class_list:: class_list, mount_style, OptionalMaybeSignal , OptionalProp } ;
2
2
use leptos:: * ;
3
3
4
4
#[ derive( Default ) ]
@@ -16,6 +16,8 @@ pub enum SpaceGap {
16
16
pub fn Space (
17
17
#[ prop( optional) ] gap : SpaceGap ,
18
18
#[ prop( optional) ] vertical : bool ,
19
+ #[ prop( optional, into) ] align : OptionalMaybeSignal < SpaceAlign > ,
20
+ #[ prop( optional, into) ] justify : OptionalMaybeSignal < SpaceJustify > ,
19
21
#[ prop( optional, into) ] class : OptionalProp < MaybeSignal < String > > ,
20
22
children : Children ,
21
23
) -> impl IntoView {
@@ -32,6 +34,8 @@ pub fn Space(
32
34
<div
33
35
class=class_list![ "thaw-space" , class. map( | c | move || c. get( ) ) ]
34
36
style: gap=gap
37
+ style: align-items=move || align. get( ) . map( |a| a. as_str( ) )
38
+ style: justify-content=move || justify. get( ) . map( |j| j. as_str( ) )
35
39
style: flex-direction=if vertical { "column" } else { "row" }
36
40
>
37
41
@@ -46,3 +50,55 @@ pub fn Space(
46
50
</div>
47
51
}
48
52
}
53
+
54
+ #[ derive( Clone ) ]
55
+ pub enum SpaceAlign {
56
+ FlexStart ,
57
+ FlexEnd ,
58
+ Start ,
59
+ End ,
60
+ Center ,
61
+ Baseline ,
62
+ Stretch ,
63
+ }
64
+
65
+ impl SpaceAlign {
66
+ fn as_str ( & self ) -> & ' static str {
67
+ match self {
68
+ Self :: FlexStart => "flex-start" ,
69
+ Self :: FlexEnd => "flex-end" ,
70
+ Self :: Start => "start" ,
71
+ Self :: End => "end" ,
72
+ Self :: Center => "center" ,
73
+ Self :: Baseline => "baseline" ,
74
+ Self :: Stretch => "stretch" ,
75
+ }
76
+ }
77
+ }
78
+
79
+ #[ derive( Clone ) ]
80
+ pub enum SpaceJustify {
81
+ FlexStart ,
82
+ FlexEnd ,
83
+ Start ,
84
+ End ,
85
+ Center ,
86
+ SpaceAround ,
87
+ SpaceBetween ,
88
+ SpaceEvenly ,
89
+ }
90
+
91
+ impl SpaceJustify {
92
+ fn as_str ( & self ) -> & ' static str {
93
+ match self {
94
+ Self :: FlexStart => "flex-start" ,
95
+ Self :: FlexEnd => "flex-end" ,
96
+ Self :: Start => "start" ,
97
+ Self :: End => "end" ,
98
+ Self :: Center => "center" ,
99
+ Self :: SpaceAround => "space-around" ,
100
+ Self :: SpaceBetween => "space-between" ,
101
+ Self :: SpaceEvenly => "space-evenly" ,
102
+ }
103
+ }
104
+ }
0 commit comments