From 3757b1923bbd5bc75d19d2459949973938c681fa Mon Sep 17 00:00:00 2001 From: Alexander Baranov Date: Fri, 22 May 2026 15:37:16 +0300 Subject: [PATCH] =?UTF-8?q?smart-house-web:=20=D1=84=D1=80=D0=BE=D0=BD?= =?UTF-8?q?=D1=82=20=D1=8D=D1=81=D1=81=D0=BF=D0=B5=D1=80=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smart-house-web/frontend/Cargo.toml | 3 ++- smart-house-web/frontend/src/backend.rs | 0 .../frontend/src/components/favorites.rs | 6 ++++++ smart-house-web/frontend/src/components/mod.rs | 7 +++++++ smart-house-web/frontend/src/components/nav.rs | 15 +++++++++++++++ .../frontend/src/components/view.rs | 0 smart-house-web/frontend/src/main.rs | 18 ++++++++++++++++-- 7 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 smart-house-web/frontend/src/backend.rs create mode 100644 smart-house-web/frontend/src/components/favorites.rs create mode 100644 smart-house-web/frontend/src/components/mod.rs create mode 100644 smart-house-web/frontend/src/components/nav.rs create mode 100644 smart-house-web/frontend/src/components/view.rs diff --git a/smart-house-web/frontend/Cargo.toml b/smart-house-web/frontend/Cargo.toml index 91f1117..fc2f171 100644 --- a/smart-house-web/frontend/Cargo.toml +++ b/smart-house-web/frontend/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -dioxus = { version = "0.7", features = [] } +dioxus = { version = "0.7", features = ["fullstack", "router"] } reqwest = { version = "0.13", features = ["json"] } serde = { version = "1.0", features = ["derive"] } @@ -13,3 +13,4 @@ default = ["web"] web = ["dioxus/web"] desktop = ["dioxus/desktop"] mobile = ["dioxus/mobile"] +server = ["dioxus/server"] diff --git a/smart-house-web/frontend/src/backend.rs b/smart-house-web/frontend/src/backend.rs new file mode 100644 index 0000000..e69de29 diff --git a/smart-house-web/frontend/src/components/favorites.rs b/smart-house-web/frontend/src/components/favorites.rs new file mode 100644 index 0000000..60bd50b --- /dev/null +++ b/smart-house-web/frontend/src/components/favorites.rs @@ -0,0 +1,6 @@ +use dioxus::prelude::*; + +#[component] +pub fn Favorites() -> Element { + rsx! { "favorites!" } +} diff --git a/smart-house-web/frontend/src/components/mod.rs b/smart-house-web/frontend/src/components/mod.rs new file mode 100644 index 0000000..a3f4b20 --- /dev/null +++ b/smart-house-web/frontend/src/components/mod.rs @@ -0,0 +1,7 @@ +mod favorites; +mod nav; +mod view; + +pub use favorites::*; +pub use nav::*; +pub use view::*; diff --git a/smart-house-web/frontend/src/components/nav.rs b/smart-house-web/frontend/src/components/nav.rs new file mode 100644 index 0000000..5ed7855 --- /dev/null +++ b/smart-house-web/frontend/src/components/nav.rs @@ -0,0 +1,15 @@ +use crate::Route; +use dioxus::prelude::*; + +#[component] +pub fn NavBar() -> Element { + rsx! { + div { id: "title", + Link { to: Route::DogView, + h1 { "🌭 HotDog! " } + } + Link { to: Route::Favorites, id: "heart", "♥️" } + } + Outlet:: {} + } +} diff --git a/smart-house-web/frontend/src/components/view.rs b/smart-house-web/frontend/src/components/view.rs new file mode 100644 index 0000000..e69de29 diff --git a/smart-house-web/frontend/src/main.rs b/smart-house-web/frontend/src/main.rs index 23107f6..7f853bf 100644 --- a/smart-house-web/frontend/src/main.rs +++ b/smart-house-web/frontend/src/main.rs @@ -1,8 +1,13 @@ use dioxus::prelude::*; +use crate::components::{Favorites, NavBar}; + const FAVICON: Asset = asset!("/assets/favicon.ico"); const MAIN_CSS: Asset = asset!("/assets/main.css"); +mod backend; +mod components; + fn main() { dioxus::launch(App); } @@ -16,8 +21,7 @@ fn App() -> Element { rsx! { document::Link { rel: "icon", href: FAVICON } document::Stylesheet { href: MAIN_CSS } - Title { } - DogView { } + Router:: { } } } @@ -58,3 +62,13 @@ fn DogView() -> Element { } } } + +#[derive(Routable, Clone, PartialEq)] +enum Route { + #[layout(NavBar)] + #[route("/")] + DogView, + + #[route("/favorites")] + Favorites, +}