summaryrefslogtreecommitdiffstats
path: root/src/components/modal.rs
blob: 62e1facb72b81771bce698976f52797816c34797 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use leptos::prelude::*;
use leptos::ev::MouseEvent;

#[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>
    }
}