2023-09-28 14:54:00 +00:00
|
|
|
mod content;
|
|
|
|
mod state;
|
2023-09-28 11:08:15 +00:00
|
|
|
mod topbar;
|
|
|
|
|
2023-09-28 14:54:00 +00:00
|
|
|
use content::{error, home::Home};
|
|
|
|
use state::State;
|
|
|
|
use std::rc::Rc;
|
2023-09-28 13:43:44 +00:00
|
|
|
use topbar::TopBar;
|
2023-09-28 11:08:15 +00:00
|
|
|
use yew::prelude::*;
|
2023-09-28 12:23:12 +00:00
|
|
|
use yew_router::prelude::*;
|
2023-09-28 11:08:15 +00:00
|
|
|
|
2023-09-28 12:23:12 +00:00
|
|
|
#[derive(Clone, Routable, PartialEq)]
|
|
|
|
enum Route {
|
|
|
|
#[at("/")]
|
|
|
|
Home,
|
|
|
|
#[at("/services")]
|
|
|
|
Services,
|
|
|
|
#[at("/community")]
|
|
|
|
Community,
|
|
|
|
#[at("/about")]
|
|
|
|
About,
|
|
|
|
#[not_found]
|
|
|
|
#[at("/404")]
|
|
|
|
NotFound,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn switch(routes: Route) -> Html {
|
|
|
|
match routes {
|
2023-09-28 14:54:00 +00:00
|
|
|
Route::Home => html! { <Home/> },
|
2023-09-28 12:23:12 +00:00
|
|
|
Route::Services => html! {<h1>{ "Services" }</h1>},
|
|
|
|
Route::Community => html! {<h1>{ "Community" }</h1>},
|
|
|
|
Route::About => html! {<h1>{ "About" }</h1>},
|
2023-09-28 14:54:00 +00:00
|
|
|
Route::NotFound => html! { <error::NotFound/> },
|
2023-09-28 12:23:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-09-28 11:08:15 +00:00
|
|
|
#[function_component]
|
2023-09-28 11:58:08 +00:00
|
|
|
fn App() -> Html {
|
2023-09-28 14:54:00 +00:00
|
|
|
let state = use_memo(|_| State::default(), ());
|
|
|
|
|
2023-09-28 11:08:15 +00:00
|
|
|
html! {
|
2023-09-28 14:54:00 +00:00
|
|
|
<ContextProvider<Rc<State>> context={state}>
|
2023-09-28 12:23:12 +00:00
|
|
|
<TopBar/>
|
|
|
|
<main>
|
|
|
|
<BrowserRouter>
|
|
|
|
<Switch<Route> render={switch} />
|
|
|
|
</BrowserRouter>
|
|
|
|
</main>
|
2023-09-28 14:54:00 +00:00
|
|
|
</ContextProvider<Rc<State>>>
|
2023-09-28 11:08:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2023-09-28 11:58:08 +00:00
|
|
|
yew::Renderer::<App>::new().render();
|
2023-09-28 11:08:15 +00:00
|
|
|
}
|