summary refs log tree commit diff stats
path: root/src/lib.rs
blob: 7d587352862ced03dfb88c7d0f047b2cfb262bc5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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>
    }
}