File tree Expand file tree Collapse file tree 3 files changed +37
-7
lines changed
pgml-dashboard/src/components/modal Expand file tree Collapse file tree 3 files changed +37
-7
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,18 @@ pub struct Modal {
9
9
pub size_class : String ,
10
10
pub header : Option < Component > ,
11
11
pub body : Component ,
12
+ pub default_style : bool ,
12
13
}
13
14
14
15
component ! ( Modal ) ;
15
16
16
17
impl Modal {
17
18
/// Create a new x-large modal with the given body.
18
19
pub fn new ( body : Component ) -> Self {
19
- let modal = Modal :: default ( ) ;
20
+ let modal = Modal {
21
+ default_style : true ,
22
+ ..Modal :: default ( )
23
+ } ;
20
24
let id = format ! ( "modal-{}" , crate :: utils:: random_string( 10 ) ) ;
21
25
22
26
modal. id ( & id) . body ( body) . xlarge ( )
@@ -45,6 +49,20 @@ impl Modal {
45
49
self . header = Some ( header) ;
46
50
self
47
51
}
52
+
53
+ // Quick implimitation to toggle the modal
54
+ pub fn toggle ( id : & str ) -> String {
55
+ format ! ( r#"data-bs-toggle="modal" data-bs-target="{}{}""# , "#" , id)
56
+ }
57
+
58
+ pub fn dismiss ( ) -> String {
59
+ r#"data-bs-dismiss="modal""# . into ( )
60
+ }
61
+
62
+ pub fn no_default_style ( mut self ) -> Modal {
63
+ self . default_style = false ;
64
+ self
65
+ }
48
66
}
49
67
50
68
#[ cfg( test) ]
Original file line number Diff line number Diff line change 1
- .modal {
1
+ div [ data-controller = " modal " ] .modal {
2
2
--bs-modal-margin : 1.65rem ;
3
3
--bs-modal-header-padding : 0 ;
4
4
--bs-modal-width : 75vw ;
5
+ --bs-modal-padding : 40px ;
5
6
6
7
@include media-breakpoint-up (lg) {
7
8
--bs-modal-width : 40rem ;
29
30
width : 100% ;
30
31
display : flex ;
31
32
}
33
+
34
+ .modal-body {
35
+ margin-top : 3rem ;
36
+ background-color : #{$gray-600 } ;
37
+ border : 2px solid #{$gray-100 } ;
38
+ border-radius : $border-radius ;
39
+ justify-content : center ;
40
+ align-items : center ;
41
+ flex-direction : column ;
42
+ display : flex ;
43
+ width : 100% ;
44
+ height : 100% ;
45
+ }
32
46
}
Original file line number Diff line number Diff line change 1
- < div class ="modal <%- size_class %> " id ="<%= id %> " data-controller ="modal " tabindex ="-1 " aria-modal ="true " role ="dialog " data-modal-target ="modal ">
1
+ < div class ="modal <%- size_class %> " id ="<%= id %> " data-controller ="modal " tabindex ="-1 " aria-modal ="true " role ="dialog " data-modal-target ="modal " >
2
2
< div class ="modal-dialog ">
3
3
< div class ="modal-content ">
4
4
< % if let Some(header) = header { %>
5
5
< div class ="modal-header ">
6
6
< %+ header %>
7
7
</ div >
8
8
< % } %>
9
- < div class ="modal-body ">
10
- < div class ="w-100 h-100 mt-5 py-5 px-3 d-flex flex-column justify-content-center align-items-center " style ="background: black; border: 2px solid white; border-radius: 12px; ">
11
- < %+ body %>
12
- </ div >
9
+ < div < % if default_style { %> class="modal-body" < % } %> >
10
+ < %+ body %>
13
11
</ div >
14
12
</ div >
15
13
</ div >
You can’t perform that action at this time.
0 commit comments