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



                                                      
                           
                       

            



                                                       
           





                                                     
             
         



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