Skip to content

Commit f8d3414

Browse files
Dan modal update (#1057)
1 parent 008a107 commit f8d3414

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

pgml-dashboard/src/components/modal/mod.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ pub struct Modal {
99
pub size_class: String,
1010
pub header: Option<Component>,
1111
pub body: Component,
12+
pub default_style: bool,
1213
}
1314

1415
component!(Modal);
1516

1617
impl Modal {
1718
/// Create a new x-large modal with the given body.
1819
pub fn new(body: Component) -> Self {
19-
let modal = Modal::default();
20+
let modal = Modal {
21+
default_style: true,
22+
..Modal::default()
23+
};
2024
let id = format!("modal-{}", crate::utils::random_string(10));
2125

2226
modal.id(&id).body(body).xlarge()
@@ -45,6 +49,20 @@ impl Modal {
4549
self.header = Some(header);
4650
self
4751
}
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+
}
4866
}
4967

5068
#[cfg(test)]

pgml-dashboard/src/components/modal/modal.scss

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
.modal {
1+
div[data-controller="modal"].modal {
22
--bs-modal-margin: 1.65rem;
33
--bs-modal-header-padding: 0;
44
--bs-modal-width: 75vw;
5+
--bs-modal-padding: 40px;
56

67
@include media-breakpoint-up(lg) {
78
--bs-modal-width: 40rem;
@@ -29,4 +30,17 @@
2930
width: 100%;
3031
display: flex;
3132
}
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+
}
3246
}

pgml-dashboard/src/components/modal/template.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
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" >
22
<div class="modal-dialog">
33
<div class="modal-content">
44
<% if let Some(header) = header { %>
55
<div class="modal-header">
66
<%+ header %>
77
</div>
88
<% } %>
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 %>
1311
</div>
1412
</div>
1513
</div>

0 commit comments

Comments
 (0)