nova_forms/components/
section.rs

1use leptos::*;
2
3use crate::{Group, QueryStringPart};
4
5#[component]
6pub fn Section(
7    #[prop(into)] title: TextProp,
8    #[prop(into, optional)] description: Option<TextProp>,
9    #[prop(optional)] children: Option<Children>,
10    /// An optional binding that creates a new group.
11    #[prop(into, optional)] bind: Option<QueryStringPart>,
12) -> impl IntoView {
13
14    let label_clone = title.clone();
15
16    let section = move || view! {
17        <section class="section">
18            <h3 class="section-title">{title}</h3>
19            {if let Some(description) = description { view! {
20                <p class="section-description">{description}</p>
21            }.into_view() } else { View::default() }}
22            {if let Some(children) = children { children().into_view() } else { View::default() }}
23        </section>
24    };
25    
26    if let Some(bind) = bind {
27       view! {
28            <Group bind=bind label=label_clone>
29                {section()}
30            </Group>
31       }.into_view()
32    } else {
33        section().into_view()
34    }
35}