Take the pain out of keeping all your calendars together
at main 1.7 kB view raw
1use leptos::prelude::*; 2use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title}; 3use leptos_router::{ 4 components::{Route, Router, Routes}, 5 StaticSegment, 6}; 7 8pub fn shell(options: LeptosOptions) -> impl IntoView { 9 view! { 10 <!DOCTYPE html> 11 <html lang="en"> 12 <head> 13 <meta charset="utf-8"/> 14 <meta name="viewport" content="width=device-width, initial-scale=1"/> 15 <AutoReload options=options.clone() /> 16 <HydrationScripts options/> 17 <MetaTags/> 18 </head> 19 <body> 20 <App/> 21 </body> 22 </html> 23 } 24} 25 26#[component] 27pub fn App() -> impl IntoView { 28 // Provides context that manages stylesheets, titles, meta tags, etc. 29 provide_meta_context(); 30 31 view! { 32 // injects a stylesheet into the document <head> 33 // id=leptos means cargo-leptos will hot-reload this stylesheet 34 <Stylesheet id="leptos" href="/pkg/calpoll.css"/> 35 36 // sets the document title 37 <Title text="Welcome to Leptos"/> 38 39 // content for this welcome page 40 <Router> 41 <main> 42 <Routes fallback=|| "Page not found.".into_view()> 43 <Route path=StaticSegment("") view=HomePage/> 44 </Routes> 45 </main> 46 </Router> 47 } 48} 49 50/// Renders the home page of your application. 51#[component] 52fn HomePage() -> impl IntoView { 53 // Creates a reactive value to update the button 54 let count = RwSignal::new(0); 55 let on_click = move |_| *count.write() += 1; 56 57 view! { 58 <h1>"Welcome to Leptos!"</h1> 59 <button on:click=on_click>"Click Me: " {count}</button> 60 } 61}