summaryrefslogblamecommitdiffstats
path: root/src/components/modal.rs
blob: f0fd68ab3c55a569212a9ea0c0be9fd0cbf3b18b (plain) (tree)
1
2
3
4
5
6
7
8
9
                           
                       

            



                                                       
           





                                                     
             
         



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