Files
rust_leptos/src/app.rs
2025-10-08 14:55:07 +02:00

75 lines
2.5 KiB
Rust

use leptos::*;
use leptos_meta::*;
use leptos_router::*;
use crate::routes::*;
#[component]
pub fn App() -> impl IntoView {
provide_meta_context();
view! {
<Stylesheet href="/pkg/rust_leptos.css"/>
<Title text="Bienvenue à la maison"/>
<div class="h-screen flex flex-col">
<Router>
<Navigation />
<main class="flex-1">
<Routes>
<Route path="/" view=move || view! { <Home/> }/>
<Route path="/liens" view=move || view! { <Links/> }/>
<Route path="/volets" view=move || view! { <Shutters/> }/>
//<Route path="/*any" view=move || view! { <NotFound/> }/>
</Routes>
</main>
<footer>
//<span>Footer</span>
//<ul>
// <li class="xs:block sm:hidden md:hidden lg:hidden xl:hidden">xs</li>
// <li class="sm:block xs:hidden md:hidden lg:hidden xl:hidden">sm</li>
// <li class="md:block xs:hidden sm:hidden lg:hidden xl:hidden">md</li>
// <li class="lg:block xs:hidden sm:hidden md:hidden xl:hidden">lg</li>
// <li class="xl:block xs:hidden sm:hidden mg:hidden lg:hidden">xl</li>
// <li class="md:hidden lg:hidden xl:hidden">sm</li>
//</ul>
</footer>
</Router>
</div>
}
}
#[component]
pub fn Navigation() -> impl IntoView {
let location = use_location();
view! {
<nav class="flex gap-5 px-2 py-1 text-lg">
<a href="/"
class="hover:text-third hover:border-b border-third inline-block transition-colors"
class:active-link=move || location.pathname.get() == "/">Home</a>
<a href="/liens"
class="hover:text-third hover:border-b border-third inline-block transition-colors"
class:active-link=move || location.pathname.get() == "/liens">Liens</a>
<a href="/volets"
class="hover:text-third hover:border-b border-third inline-block transition-colors"
class:active-link=move || location.pathname.get() == "/volets">Volets</a>
</nav>
}
}
#[component]
pub fn Home() -> impl IntoView {
view! {
<h1 class="m-2">Home</h1>
}
}
#[component]
pub fn NotFound() -> impl IntoView {
view! {
<h1>Not Found</h1>
}
}