From fb586bb362d4bdea9d3c85c6bfbb92804d381903 Mon Sep 17 00:00:00 2001 From: Adam Doyle Date: Tue, 10 Sep 2024 01:59:35 -0400 Subject: [PATCH] even more responsive --- client/Cargo.toml | 2 +- client/index.html | 7 + client/src/components/auth.rs | 137 ++++++++-------- client/src/components/browser.rs | 44 +++--- client/src/components/browser/create_game.rs | 3 + client/src/components/chat.rs | 6 +- client/src/components/game.rs | 1 - client/src/components/mod.rs | 1 + client/src/components/theme_button.rs | 40 +++++ client/src/lib.rs | 12 +- client/src/pages/home.rs | 157 ++++++++++--------- 11 files changed, 243 insertions(+), 167 deletions(-) create mode 100644 client/src/components/theme_button.rs diff --git a/client/Cargo.toml b/client/Cargo.toml index bbdfba2..bb93d5c 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -14,7 +14,7 @@ console_error_panic_hook = "0.1" console_log = "1" log = "0.4" -leptos-use = "0.14.0-beta" +leptos-use = { version = "0.14.0-beta", features = ["use_media_query"] } # leptos-use = { path = "../../leptos-use" } # leptos-use = { git = "https://github.com/adoyle0/leptos-use.git", branch = "leptos-0.7" } codee = "0.2" diff --git a/client/index.html b/client/index.html index e041162..acc2d73 100644 --- a/client/index.html +++ b/client/index.html @@ -1,6 +1,13 @@ + diff --git a/client/src/components/auth.rs b/client/src/components/auth.rs index b2af65d..8c065bd 100644 --- a/client/src/components/auth.rs +++ b/client/src/components/auth.rs @@ -12,7 +12,6 @@ pub fn Auth() -> impl IntoView { let user_context = expect_context::>>(); let connected = move || websocket.ready_state.get() == ConnectionReadyState::Open; let new_username = RwSignal::new(String::new()); - let show_auth = RwSignal::new(false); Effect::new(move |_| { user_context.with(|new_user| { @@ -40,79 +39,71 @@ pub fn Auth() -> impl IntoView { }); view! { -
-

"Welcome " {move || username()}"!"

- -
-
- - - "Disconnected."

}> - - -

- "Sign In" -

-
-

- "You were already given a random name but if you'd like to change it this is the place." -

-

- "Identities are saved once created so if you leave or get disconnected just enter your old name here to \"log back in\"." -

-

- "Please don't steal each other's identities (yes, you can)." -

-
-
+ + + + + "Disconnected."

}> + + +

+ "Sign In" +

+
+

+ "You were already given a random name but if you'd like to change it this is the place." +

+

+ "Identities are saved once created so if you leave or get disconnected just enter your old name here to \"log back in\"." +

+

+ "Please don't steal each other's identities (yes, you can)." +

+
+
-
- - - - - - - - - - -
-
-
-
-
+ } + } + > + "Submit" + + + + + } } diff --git a/client/src/components/browser.rs b/client/src/components/browser.rs index 1dd10b5..e276b5f 100644 --- a/client/src/components/browser.rs +++ b/client/src/components/browser.rs @@ -24,20 +24,29 @@ pub fn Browser() -> impl IntoView { // Browser stuff let game_browser_context = expect_context::>>(); - let (join_id, set_join_id) = signal("".to_string()); - let (delete_id, set_delete_id) = signal("".to_string()); + let join_id = RwSignal::new("".to_string()); + let delete_id = RwSignal::new("".to_string()); + + let nav_context = expect_context::>(); Effect::new(move |_| { - set_websocket_send(to_string(&GameJoinRequest { id: join_id() }).unwrap()); + if join_id() != "" { + set_websocket_send(to_string(&GameJoinRequest { id: join_id() }).unwrap()); + nav_context.set("game".to_string()); + join_id.set("".to_string()); + } }); Effect::new(move |_| { - set_websocket_send( - to_string(&GameDeleteRequest { - delete_game_id: delete_id(), - }) - .unwrap(), - ); + if delete_id() != "" { + set_websocket_send( + to_string(&GameDeleteRequest { + delete_game_id: delete_id(), + }) + .unwrap(), + ); + delete_id.set("".to_string()); + } }); let show_create_game = RwSignal::new(false); @@ -51,14 +60,11 @@ pub fn Browser() -> impl IntoView { position=PopoverPosition::BottomStart > -

- "Game Browser" -

+