1
Fork 0
bauke-xyz/source/main.rs

73 lines
1.5 KiB
Rust
Raw Normal View History

2021-08-26 15:52:13 +00:00
#![forbid(unsafe_code)]
#![warn(missing_docs, clippy::missing_docs_in_private_items)]
//! # [bauke.xyz](https://bauke.xyz)
use yew::prelude::*;
2021-08-30 13:55:08 +00:00
use yew_router::router::Router;
2021-08-26 15:52:13 +00:00
/// Components collection.
pub(crate) mod components;
2021-08-30 13:55:08 +00:00
/// Routes collection.
pub(crate) mod routes;
2021-08-26 15:52:13 +00:00
2021-08-30 13:55:08 +00:00
/// All routes.
#[derive(Clone, yew_router::Switch)]
pub(crate) enum Route {
2021-08-30 14:35:59 +00:00
#[to = "/userstyles"]
Userstyles,
2021-08-30 13:55:08 +00:00
#[to = "/{}"]
NotFound(String),
#[to = "/"]
Home,
}
2021-08-26 15:52:13 +00:00
/// The main component.
pub(crate) struct Model;
impl Component for Model {
type Message = ();
type Properties = ();
fn create(_props: Self::Properties, _link: ComponentLink<Self>) -> Self {
Self
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
false
}
fn view(&self) -> Html {
html! {
2021-08-30 13:55:08 +00:00
<Router<Route, ()>
render = Router::render(|route: Route| {
match route {
Route::NotFound(_) => html! {
<main class="error-404">
<p>{"🤷"}</p>
</main>
},
Route::Home => html! {
<routes::HomeRoute />
2021-08-30 14:35:59 +00:00
},
Route::Userstyles => html! {
<routes::UserstylesRoute />
2021-08-30 13:55:08 +00:00
}
}
})
/>
2021-08-26 15:52:13 +00:00
}
}
}
/// Our main function.
pub(crate) fn main() {
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
log::debug!("Initializing Yew");
yew::start_app::<Model>();
}