basic routing, <Nav> component

This commit is contained in:
YK committed 2025-09-20 11:06:39 +03:00
1 parent ae1193e6ce
commit 0620207877
5 files changed
+69 -7

No files matched your search

+16 -3
View File
@@ -5,7 +5,17 @@ use leptos_router::{
StaticSegment, WildcardSegment,
};
use crate::{ prelude::*, components::{ sidebar::Sidebar, header::Header, Dash } };
use crate::{
components::{
header::Header,
nav::Nav,
sidebar::Sidebar,
Character,
Inventories,
Wiki
},
prelude::*
};
#[component]
pub fn App() -> impl IntoView {
@@ -20,7 +30,7 @@ pub fn App() -> impl IntoView {
<Stylesheet id="leptos" href="/pkg/aex.css"/>
// sets the document title
<Title text="Welcome to Leptos"/>
<Title text="aex"/>
// content for this welcome page
<Router>
@@ -28,8 +38,11 @@ pub fn App() -> impl IntoView {
<Header />
<Sidebar />
<main>
<Nav />
<Routes fallback=move || "Not found.">
<Route path=StaticSegment("") view=Dash/>
<Route path=StaticSegment("") view=Character/>
<Route path=StaticSegment("inv") view=Inventories/>
<Route path=StaticSegment("wiki") view=Wiki />
<Route path=WildcardSegment("any") view=NotFound/>
</Routes>
</main>
+18 -3
View File
@@ -6,13 +6,28 @@ use crate::prelude::*;
pub mod header;
pub mod sidebar;
pub mod nav;
pub mod numput;
#[component]
pub fn Dash () -> impl IntoView {
pub fn Character () -> impl IntoView {
view! {
main
character
}
}
#[component]
pub fn Inventories () -> impl IntoView {
view! {
<div class="inventories">
</div>
}
}
#[component]
pub fn Wiki () -> impl IntoView {
view! {
books
}
}
+14
View File
@@ -0,0 +1,14 @@
use crate::prelude::*;
use leptos::prelude::*;
use leptos_router::components::A;
#[component]
pub fn Nav () -> impl IntoView {
view! {
<nav class="main-nav">
<A href="/">Персонаж</A>
<A href="/inv">Инвентарь</A>
<A href="/wiki">Информация</A>
</nav>
}
}