summary refs log tree commit diff stats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-09-26 17:43:43 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2025-09-26 17:43:43 +0200
commit32847efa04029d81f9d8cf7a37999cb3cbb1e145 (patch)
tree8a0a7bc135643a6fbf45bf48141d9dfcb2085183 /src/lib.rs
downloadweb-client-32847efa04029d81f9d8cf7a37999cb3cbb1e145.zip
chore: Initial Commit
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..7d58735
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,59 @@
+#![expect(
+    unreachable_pub,
+    reason = "leptos' component macro generates this warning"
+)]
+#![expect(
+    clippy::must_use_candidate,
+    reason = "Can't add it to leptos' components"
+)]
+
+mod components;
+mod pages;
+
+use std::sync::Arc;
+
+use leptos::prelude::{AddAnyAttr, IntoView, component, view};
+use leptos_meta::{Html, Meta, Title, provide_meta_context};
+use leptos_router::{
+    components::{Route, Router, Routes},
+    path,
+};
+use rocie_client::apis::configuration::Configuration;
+
+use crate::pages::home::Home;
+
+#[component]
+pub fn App() -> impl IntoView {
+    // Provides context that manages stylesheets, titles, meta tags, etc.
+    provide_meta_context();
+
+    let config = {
+        let mut config = Configuration::new();
+
+        config.user_agent = Some("rocie-mobile".to_owned());
+        config.base_path = "http://127.0.0.1:8080".to_owned();
+
+        Arc::new(config)
+    };
+
+    view! {
+        <Html attr:lang="en" attr:dir="ltr" attr:data-theme="light" />
+
+        <Title text="Welcome to Leptos CSR" />
+
+        <Meta charset="UTF-8" />
+        <Meta name="viewport" content="width=device-width, initial-scale=1.0" />
+
+        <Router>
+            <Routes fallback=|| view! { NotFound }>
+                <Route
+                    path=path!("/")
+                    view=move || {
+                        let local_config = Arc::clone(&config);
+                        view! { <Home config=local_config /> }
+                    }
+                />
+            </Routes>
+        </Router>
+    }
+}