Skip to main content

orbital_base_components/collection/primitives/
root.rs

1use leptos::{context::Provider, prelude::*};
2
3use crate::collection::state::{CollectionState, CollectionStateInjection};
4
5#[component]
6pub fn BaseCollectionRoot(
7    #[prop(into)] class: Signal<String>,
8    #[prop(optional, default = "tree")] role: &'static str,
9    #[prop(into)] collection_state: CollectionState,
10    #[prop(optional, default = "orbital-collection")] base_class: &'static str,
11    children: Children,
12) -> impl IntoView {
13    view! {
14        <div
15            class=move || {
16                let mut parts = vec![base_class.to_string()];
17                let extra = class.get();
18                if !extra.is_empty() {
19                    parts.push(extra);
20                }
21                parts.join(" ")
22            }
23            role=role
24        >
25            <Provider value=CollectionStateInjection(collection_state)>{children()}</Provider>
26        </div>
27    }
28}