biji_ui/components/menubar/
root.rs1use leptos::{context::Provider, prelude::*};
2
3use crate::components::menubar::context::{MenubarContext, RootContext};
4
5#[component]
6pub fn Root(
7 children: Children,
8 #[prop(into, optional)] class: String,
9 #[prop(default = false)] allow_menu_loop: bool,
10 #[prop(default = false)] allow_item_loop: bool,
11) -> impl IntoView {
12 let menubar_ref = NodeRef::new();
13
14 let root_ctx = RootContext {
15 allow_item_loop,
16 allow_menu_loop,
17 ..RootContext::default()
18 };
19 let ctx = MenubarContext {
20 menubar_ref,
21 root: RwSignal::new(root_ctx),
22 };
23
24 view! {
25 <Provider value={ctx}>
26 <div node_ref={menubar_ref} class={class}>
27 <Provider value={root_ctx}>{children()}</Provider>
28 </div>
29 </Provider>
30 }
31}