Initial commit.
This commit is contained in:
commit
936ea3d853
40 changed files with 6851 additions and 0 deletions
56
desktop/src/main.rs
Normal file
56
desktop/src/main.rs
Normal file
|
@ -0,0 +1,56 @@
|
|||
use dioxus::prelude::*;
|
||||
|
||||
use ui::Navbar;
|
||||
use views::{Blog, Home};
|
||||
|
||||
|
||||
mod views;
|
||||
|
||||
#[derive(Debug, Clone, Routable, PartialEq)]
|
||||
#[rustfmt::skip]
|
||||
enum Route {
|
||||
#[layout(DesktopNavbar)]
|
||||
#[route("/")]
|
||||
Home {},
|
||||
#[route("/blog/:id")]
|
||||
Blog { id: i32 },
|
||||
}
|
||||
|
||||
|
||||
const MAIN_CSS: Asset = asset!("/assets/main.css");
|
||||
|
||||
fn main() {
|
||||
dioxus::launch(App);
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn App() -> Element {
|
||||
// Build cool things ✌️
|
||||
|
||||
rsx! {
|
||||
// Global app resources
|
||||
document::Link { rel: "stylesheet", href: MAIN_CSS }
|
||||
|
||||
Router::<Route> {}
|
||||
}
|
||||
}
|
||||
|
||||
/// A desktop-specific Router around the shared `Navbar` component
|
||||
/// which allows us to use the desktop-specific `Route` enum.
|
||||
#[component]
|
||||
fn DesktopNavbar() -> Element {
|
||||
rsx! {
|
||||
Navbar {
|
||||
Link {
|
||||
to: Route::Home {},
|
||||
"Home"
|
||||
}
|
||||
Link {
|
||||
to: Route::Blog { id: 1 },
|
||||
"Blog"
|
||||
}
|
||||
}
|
||||
|
||||
Outlet::<Route> {}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue