fix forms

This commit is contained in:
Adam 2024-07-26 23:33:20 -04:00
parent afa265cdfc
commit cafac264a7
2 changed files with 14 additions and 5 deletions

View file

@ -7,7 +7,7 @@ use serde_json::to_string;
#[component]
pub fn Auth() -> impl IntoView {
let websocket = expect_context::<WebSocketContext>();
let (username, _set_username) = create_signal("Anonymous");
let (username, set_username) = create_signal("Anonymous".to_string());
let username_input_ref = create_node_ref::<Input>();
let send_login = move |_| {
@ -17,6 +17,8 @@ pub fn Auth() -> impl IntoView {
})
.unwrap(),
);
set_username.set(username_input_ref.get().unwrap().value());
username_input_ref.get().unwrap().set_value("");
logging::log!("sent");
};
@ -24,18 +26,22 @@ pub fn Auth() -> impl IntoView {
<div class="p-1">
<h2 class="text-2xl">Sign in:</h2>
<p>Username:</p>
<form
onsubmit="return false"
on:submit=send_login
>
<input
class="w-96 font-mono rounded-sm bg-slate-900 text-slate-200"
placeholder=move || username.get()
node_ref=username_input_ref
on:change=send_login.clone()
/>
<br />
<input
class="py-2 px-4 pl-4 font-bold text-white rounded border-b-4 bg-slate-600 border-slate-800 hover:bg-slate-700 hover:border-slate-500"
type="submit"
value="Send"
on:change=send_login.clone()
/>
</form>
</div>
}
}

View file

@ -84,18 +84,21 @@ pub fn Chat() -> impl IntoView {
</textarea>
<br/>
<span>
<form
onsubmit="return false"
on:submit=send_message
>
<input
class="w-80 h-11 font-mono rounded-sm bg-slate-900 text-slate-200"
placeholder="talk shit..."
node_ref=chat_input_ref
on:change=send_message.clone()
/>
<input
class="py-2 px-4 pl-4 font-bold text-white rounded border-b-4 bg-slate-600 border-slate-800 hover:bg-slate-700 hover:border-slate-500"
type="submit"
value="Send"
on:change=send_message.clone()
/>
</form>
</span>
<br/>
</div>