Files
dioxus/example-projects/ecommerce-site/src/main.rs
T
Evan AlmloffandJonathan Kelley 519ec9d294 Move the document trait into a separate crate (#3035)
* add a default head method through eval
* remove the old document trait
* implement document for each platform
* pull out document into a dedicated crate to cut down on shared dependencies
---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
2024-10-14 10:33:37 -07:00

53 lines
1006 B
Rust

#![allow(non_snake_case)]
use components::home::Home;
use components::loading::ChildrenOrLoading;
use dioxus::prelude::*;
mod components {
pub mod error;
pub mod home;
pub mod loading;
pub mod nav;
pub mod product_item;
pub mod product_page;
}
mod api;
fn main() {
dioxus::launch(|| {
rsx! {
document::Link {
rel: "stylesheet",
href: asset!("./public/tailwind.css")
}
ChildrenOrLoading {
Router::<Route> {}
}
}
});
}
#[derive(Clone, Routable, Debug, PartialEq)]
enum Route {
#[route("/")]
Home {},
#[route("/details/:product_id")]
Details { product_id: usize },
}
#[component]
/// Render a more sophisticated page with ssr
fn Details(product_id: usize) -> Element {
rsx! {
div {
components::nav::nav {}
components::product_page::product_page {
product_id
}
}
}
}