nova_forms/components/nova_form_wrapper.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
use leptos::*;
use crate::NovaFormsContext;
/// A container for a form.
/// Adds a header with a logo, title, and subtitle, as well as a footer with the title.
#[component]
pub fn NovaFormWrapper(
/// The URL of the logo to display in the header.
#[prop(into)] logo: String,
/// The title to display in the header and footer.
#[prop(into)] title: TextProp,
/// The subtitle to display in the header.
#[prop(into)] subtitle: TextProp,
#[prop(into, optional)] footer: Option<Children>,
children: Children,
) -> impl IntoView {
let nova_forms_context = expect_context::<NovaFormsContext>();
view! {
<header>
<div class="content">
<img id="logo" src=format!("{}{}", nova_forms_context.base_url, logo) />
<div id="name">
<span id="title">{title.clone()}</span>
<br />
<span id="subtitle">{subtitle}</span>
</div>
</div>
</header>
<nav>
<div class="content">
</div>
</nav>
<main>
<div class="content">
{children()}
</div>
</main>
{
if let Some(footer) = footer {
view! {
<footer>
<div class="content">
<span>{footer()}</span>
</div>
</footer>
}.into_view()
} else {
View::default()
}
}
}
}