2023-06-04 12:37:22 +02:00
|
|
|
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
|
2023-06-04 20:11:02 +02:00
|
|
|
<Stylesheet id="leptos" href="/pkg/como_web.css"/>
|
2023-06-04 12:37:22 +02:00
|
|
|
|
|
|
|
// sets the document title
|
|
|
|
<Title text="Welcome to Leptos"/>
|
|
|
|
|
|
|
|
// content for this welcome page
|
|
|
|
<Router>
|
|
|
|
<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 {
|
|
|
|
// Creates a reactive value to update the button
|
|
|
|
let (count, set_count) = create_signal(cx, 0);
|
|
|
|
let on_click = move |_| set_count.update(|count| *count += 1);
|
|
|
|
|
|
|
|
view! { cx,
|
2023-06-04 12:58:23 +02:00
|
|
|
<h1 class="text-xl text-red-50">"Welcome to Leptos!"</h1>
|
2023-06-04 12:37:22 +02:00
|
|
|
<button on:click=on_click>"Click Me: " {count}</button>
|
|
|
|
}
|
|
|
|
}
|