cards/client/src/pages/home.rs
2024-09-13 00:33:20 -04:00

90 lines
3.8 KiB
Rust

use crate::components::browser::create_game::*;
use crate::components::browser::*;
use crate::components::footer::*;
use crate::components::game::*;
use crate::components::header::*;
use leptos::prelude::*;
use thaw::*;
/// Default Home Page
#[component]
pub fn Home() -> impl IntoView {
let selected_value = RwSignal::new("home".to_string());
provide_context(selected_value);
view! {
<ErrorBoundary fallback=|errors| {
view! {
<h1>"Uh oh! Something went wrong!"</h1>
<p>"Errors: "</p>
// Render a list of errors as strings - good for development purposes
<ul>
{move || {
errors
.get()
.into_iter()
.map(|(_, e)| view! { <li>{e.to_string()}</li> })
.collect_view()
}}
</ul>
}
}>
<div class="lg:container m-auto relative">
<div
class="transition-all p-1 lg:p-5 lg:rounded-2xl lg:shadow-black lg:shadow-lg min-h-screen lg:min-h-0"
style="background-color: var(--colorNeutralBackground4);"
>
<Header />
<Show when=move || selected_value() == "home".to_string()>
<div class="p-4">
<h2 class="text-2xl">"Hey!"</h2>
<p class="indent-4 text-pretty my-3">
{"Welcome! Thank you for helping me test this. Please let me know about any issues you may come across. Chances are you already know how to contact me but in case you don't you can email me at "}
<Link href="mailto:adam@doordesk.net">adam@doordesk.net</Link>
{". The server may go down from time to time as bugs are found and as I add updates. If you manage to crash the server or notice it down for a long time please tell me about it."}
</p>
<p>Have fun!</p>
</div>
<div class="my-5 flex flex-wrap justify-around">
<Button
class="drop-shadow-md"
size=ButtonSize::Large
appearance=ButtonAppearance::Primary
icon=icondata::BsSearch
on_click=move |_| selected_value.set("browser".to_string())
>
"Find a Game"
</Button>
<Button
class="drop-shadow-md"
size=ButtonSize::Large
appearance=ButtonAppearance::Primary
icon=icondata::AiPlusOutlined
on_click=move |_| selected_value.set("create".to_string())
>
"Create a Game"
</Button>
</div>
</Show>
<Show when=move || selected_value() == "browser".to_string()>
<Browser />
</Show>
<Show when=move || selected_value() == "game".to_string()>
<Game />
</Show>
<Show when=move || selected_value() == "create".to_string()>
<CreateGame />
</Show>
<Footer />
</div>
</div>
</ErrorBoundary>
}
}