doordesk-js/doordesk-rs/src/app.rs

54 lines
1.7 KiB
Rust
Raw Normal View History

2023-07-02 04:52:35 -04:00
use crate::error_template::{AppError, ErrorTemplate};
use leptos::*;
use leptos_meta::*;
use leptos_router::*;
#[component]
pub fn App(cx: Scope) -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc.
provide_meta_context(cx);
view! {
cx,
// injects a stylesheet into the document <head>
// id=leptos means cargo-leptos will hot-reload this stylesheet
<Stylesheet id="leptos" href="/pkg/doordesk.css"/>
// sets the document title
<Title text="DoorDesk"/>
// content for this welcome page
<Router fallback=|cx| {
let mut outside_errors = Errors::default();
outside_errors.insert_with_default_key(AppError::NotFound);
view! { cx,
<ErrorTemplate outside_errors/>
}
.into_view(cx)
}>
<main>
<Routes>
<Route path="" view=|cx| view! { cx, <HomePage/> }/>
</Routes>
</main>
</Router>
}
}
/// Renders the home page of your application.
#[component]
fn HomePage(cx: Scope) -> impl IntoView {
let (count, set_count) = create_signal(cx, 0);
let on_click = move |_| set_count.update(|count| *count += 1);
view! { cx,
<article class="bg-zinc-700 mx-auto p-7 my-5 w-11/12 max-w-screen-xl rounded-md shadow-1g bg-opacity-10">
<h1 class="max-6-xs text-3xl text-orange-600 font-light capitalize">"Ligma."</h1>
<hr class="opacity-50" />
<span class="opacity-50 text-xs pt-0 m-t pb-3.5">"today"</span>
<button on:click=on_click>"Click Me: " {count}</button>
</article>
}
}