summaryrefslogtreecommitdiffstats
path: root/src/components/modal.rs
blob: e23fa5dd6cac00bc7d9bb93096314b7df540f867 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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>
    }
}