summaryrefslogtreecommitdiffstats
path: root/src/components/modal.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/components/modal.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/components/modal.rs b/src/components/modal.rs
new file mode 100644
index 0000000..e23fa5d
--- /dev/null
+++ b/src/components/modal.rs
@@ -0,0 +1,25 @@
+// SPDX-FileCopyrightText: 2025 cel <cel@bunny.garden>
+//
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+use leptos::ev::MouseEvent;
+use leptos::prelude::*;
+
+#[component]
+pub fn Modal(
+ on_background_click: impl Fn(MouseEvent) + 'static,
+ children: Children,
+) -> impl IntoView {
+ view! {
+ <div
+ class="modal"
+ on:click=move |e| {
+ if e.current_target() == e.target() {
+ on_background_click(e)
+ }
+ }
+ >
+ {children()}
+ </div>
+ }
+}