fix: add Enter key handlers to all auth and nickname inputs
Pressing Enter on the username field in login/register or the nickname field in the join-game prompt now submits the form, matching user expectations. Also add *.templ to the gitignore allowlist.
This commit is contained in:
48
features/auth/pages/login.templ
Normal file
48
features/auth/pages/login.templ
Normal file
@@ -0,0 +1,48 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/ryanhamamura/c4/features/common/layouts"
|
||||
"github.com/starfederation/datastar-go/datastar"
|
||||
)
|
||||
|
||||
templ LoginPage() {
|
||||
@layouts.Base("Login") {
|
||||
<main class="max-w-sm mx-auto mt-8 text-center" data-signals="{username: '', password: '', error: ''}">
|
||||
<h1 class="text-3xl font-bold">Login</h1>
|
||||
<p class="mb-4">Sign in to your account</p>
|
||||
<div data-show="$error != ''" class="alert alert-error mb-4" data-text="$error"></div>
|
||||
<div>
|
||||
<fieldset class="fieldset">
|
||||
<label class="label" for="username">Username</label>
|
||||
<input
|
||||
class="input input-bordered w-full"
|
||||
id="username"
|
||||
type="text"
|
||||
placeholder="Enter your username"
|
||||
data-bind="username"
|
||||
data-on:keydown.key_enter={ datastar.PostSSE("/auth/login") }
|
||||
autofocus
|
||||
/>
|
||||
<label class="label" for="password">Password</label>
|
||||
<input
|
||||
class="input input-bordered w-full"
|
||||
id="password"
|
||||
type="password"
|
||||
placeholder="Enter your password"
|
||||
data-bind="password"
|
||||
data-on:keydown.key_enter={ datastar.PostSSE("/auth/login") }
|
||||
/>
|
||||
</fieldset>
|
||||
<button
|
||||
class="btn btn-primary w-full"
|
||||
data-on:click={ datastar.PostSSE("/auth/login") }
|
||||
>
|
||||
Login
|
||||
</button>
|
||||
</div>
|
||||
<p>
|
||||
Don't have an account? <a class="link" href="/register">Register</a>
|
||||
</p>
|
||||
</main>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user