From 345e1cc5653dc52544413da623e77a7e392d0d5e Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Sun, 21 Jun 2026 16:45:53 -0400 Subject: [PATCH] Move Route and App out of main --- src/app.rs | 29 +++++++++++++++++++++++++++++ src/main.rs | 31 ++----------------------------- 2 files changed, 31 insertions(+), 29 deletions(-) create mode 100644 src/app.rs diff --git a/src/app.rs b/src/app.rs new file mode 100644 index 0000000..54c65ee --- /dev/null +++ b/src/app.rs @@ -0,0 +1,29 @@ +use dioxus::prelude::*; + +const TAILWIND_CSS: Asset = asset!("/assets/tailwind.css"); + +#[derive(Debug, Clone, Routable, PartialEq)] +#[rustfmt::skip] +enum Route { + #[route("/")] + Home {}, +} + +#[component] +pub fn App() -> Element { + rsx! { + document::Link { rel: "stylesheet", href: TAILWIND_CSS } + Router:: {} + } +} + +/// Home page +#[component] +fn Home() -> Element { + rsx! { + p { + class: "text-lg", + "Hello, world!" + } + } +} diff --git a/src/main.rs b/src/main.rs index a994663..88efb70 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ -use dioxus::prelude::*; - pub mod api; +pub mod app; pub mod components; pub mod models; pub mod pages; @@ -10,33 +9,7 @@ pub mod util; #[cfg(feature = "server")] pub mod server; -const TAILWIND_CSS: Asset = asset!("/assets/tailwind.css"); - -#[derive(Debug, Clone, Routable, PartialEq)] -#[rustfmt::skip] -enum Route { - #[route("/")] - Home {}, -} - -#[component] -fn App() -> Element { - rsx! { - document::Link { rel: "stylesheet", href: TAILWIND_CSS } - Router:: {} - } -} - -/// Home page -#[component] -fn Home() -> Element { - rsx! { - p { - class: "text-lg", - "Hello, world!" - } - } -} +use crate::app::App; fn tracing_setup() { #[cfg(debug_assertions)]