From b88ecb29c002827e9d0f895cc6cbc2dc39252604 Mon Sep 17 00:00:00 2001 From: Adam <24621027+adoyle0@users.noreply.github.com> Date: Tue, 23 Jul 2024 22:45:45 -0400 Subject: [PATCH] break out chat --- client/src/components/chat.rs | 105 ++++++++++++++++++++++++++ client/src/components/mod.rs | 1 + client/src/components/websocket.rs | 114 +---------------------------- client/src/pages/home.rs | 14 +++- 4 files changed, 121 insertions(+), 113 deletions(-) create mode 100644 client/src/components/chat.rs diff --git a/client/src/components/chat.rs b/client/src/components/chat.rs new file mode 100644 index 0000000..e640449 --- /dev/null +++ b/client/src/components/chat.rs @@ -0,0 +1,105 @@ +use crate::components::websocket::WebSocketContext; +use html::{Input, Textarea}; +use leptos::*; +use leptos_use::core::ConnectionReadyState; +use lib::models::*; + +#[component] +pub fn Chat() -> impl IntoView { + let websocket = expect_context::(); + + // Chat stuff + let (chat_history, set_chat_history) = create_signal::>(vec![]); + let chat_history_ref = create_node_ref:: +
+ + + + +
+ + } +} diff --git a/client/src/components/mod.rs b/client/src/components/mod.rs index 6eba44d..29c6011 100644 --- a/client/src/components/mod.rs +++ b/client/src/components/mod.rs @@ -1 +1,2 @@ +pub mod chat; pub mod websocket; diff --git a/client/src/components/websocket.rs b/client/src/components/websocket.rs index 7a76679..44449b7 100644 --- a/client/src/components/websocket.rs +++ b/client/src/components/websocket.rs @@ -1,6 +1,5 @@ use std::rc::Rc; -use html::{Input, Textarea}; use leptos::*; use leptos_use::{core::ConnectionReadyState, use_websocket, UseWebsocketReturn}; use lib::models::*; @@ -109,7 +108,7 @@ pub fn Websocket() -> impl IntoView { }); view! { -
+

Server Info:

"Users Online: " {online_users}

@@ -122,115 +121,10 @@ pub fn Websocket() -> impl IntoView { +
-
- -
- -
- -
- } -} - -#[component] -pub fn Chat() -> impl IntoView { - let websocket = expect_context::(); - - // Chat stuff - let (chat_history, set_chat_history) = create_signal::>(vec![]); - let chat_history_ref = create_node_ref:: -
- - - - -
} } diff --git a/client/src/pages/home.rs b/client/src/pages/home.rs index 0d5418e..b9b1d08 100644 --- a/client/src/pages/home.rs +++ b/client/src/pages/home.rs @@ -1,4 +1,5 @@ -use crate::components::websocket::Websocket; +use crate::components::websocket::*; +use crate::components::chat::*; use leptos::*; /// Default Home Page @@ -26,8 +27,15 @@ pub fn Home() -> impl IntoView {

"Cards For Humanity"

- - git +
+ +
+ +
+ +
+ git +
}