Modal dialog improvement.

This commit is contained in:
2023-08-24 21:58:03 +02:00
parent 9f17393310
commit df247b3ed1
5 changed files with 1042 additions and 20 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ pub fn HomePage(cx: Scope) -> impl IntoView {
view! { cx,
<ModalDialog opener={dialog} title="Titulek".to_string()>
<ModalDialog opener={dialog} title="Titulek">
<ModalBody>
<div class="row">
<div class="col mb-3">
+3 -1
View File
@@ -8,7 +8,9 @@ lazy_static! {
("cs", HashMap::from( [
("Dashboard", "Přehled"),
("Settings", "Nastavení"),
("Search...", "Najít...")
("Search...", "Najít..."),
("Close", "Zavřít"),
("Save changes", "Uložit změny")
])),
("sk", HashMap::from( [
("Dashboard", "Prehlad"),
+6 -7
View File
@@ -1,4 +1,4 @@
use std::rc::Rc;
use crate::locales::trl;
use leptos::*;
#[derive(Copy, Clone)]
@@ -21,11 +21,11 @@ impl DialogOpener {
}
pub fn show(&self) {
self.set_visible.update(|state| { *state = true});
self.set_visible.update(|state| *state = true);
}
pub fn hide(&self) {
self.set_visible.update(|state| { *state = false});
self.set_visible.update(|state| *state = false);
}
}
@@ -33,10 +33,9 @@ impl DialogOpener {
pub fn ModalDialog(
cx: Scope,
opener: DialogOpener,
title: String,
title: &'static str,
children: Children,
) -> impl IntoView {
view! {cx,
<div class={ move || if opener.visible() {"modal fade show"} else {"modal fade"}}
style={ move || if opener.visible() {"display: block;"} else {""}}
@@ -44,7 +43,7 @@ pub fn ModalDialog(
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalCenterTitle">{title}</h5>
<h5 class="modal-title" id="modalCenterTitle">{trl(cx, title)}</h5>
<button
type="button"
class="btn-close"
@@ -75,4 +74,4 @@ pub fn ModalFooter(cx: Scope, children: Children) -> impl IntoView {
{children(cx)}
</div>
}
}
}