auth: use placeholders instead of labels, add username note
This commit is contained in:
parent
e3e9ccdd6c
commit
de616755f5
2 changed files with 91 additions and 58 deletions
|
|
@ -14,6 +14,9 @@
|
||||||
let email = $state(form?.email ?? '')
|
let email = $state(form?.email ?? '')
|
||||||
let password = $state('')
|
let password = $state('')
|
||||||
let isSubmitting = $state(false)
|
let isSubmitting = $state(false)
|
||||||
|
|
||||||
|
const placeholders = ['gran@grancypher.com', 'djeeta@grancypher.com']
|
||||||
|
const randomPlaceholder = placeholders[Math.floor(Math.random() * placeholders.length)]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|
@ -34,7 +37,7 @@
|
||||||
<Input
|
<Input
|
||||||
type="email"
|
type="email"
|
||||||
name="email"
|
name="email"
|
||||||
label={m.auth_login_email()}
|
placeholder={m.auth_login_email()}
|
||||||
bind:value={email}
|
bind:value={email}
|
||||||
autocomplete="email"
|
autocomplete="email"
|
||||||
required
|
required
|
||||||
|
|
@ -45,7 +48,7 @@
|
||||||
<Input
|
<Input
|
||||||
type="password"
|
type="password"
|
||||||
name="password"
|
name="password"
|
||||||
label={m.auth_login_password()}
|
placeholder={m.auth_login_password()}
|
||||||
bind:value={password}
|
bind:value={password}
|
||||||
autocomplete="current-password"
|
autocomplete="current-password"
|
||||||
minlength={8}
|
minlength={8}
|
||||||
|
|
|
||||||
|
|
@ -206,11 +206,23 @@
|
||||||
|
|
||||||
// Derive validation icon states
|
// Derive validation icon states
|
||||||
const usernameIcon = $derived(
|
const usernameIcon = $derived(
|
||||||
isCheckingUsername ? 'loader' : usernameAvailable === true ? 'check' : usernameAvailable === false ? 'x' : undefined
|
isCheckingUsername
|
||||||
|
? 'loader'
|
||||||
|
: usernameAvailable === true
|
||||||
|
? 'check'
|
||||||
|
: usernameAvailable === false
|
||||||
|
? 'x'
|
||||||
|
: undefined
|
||||||
)
|
)
|
||||||
|
|
||||||
const emailIcon = $derived(
|
const emailIcon = $derived(
|
||||||
isCheckingEmail ? 'loader' : emailAvailable === true ? 'check' : emailAvailable === false ? 'x' : undefined
|
isCheckingEmail
|
||||||
|
? 'loader'
|
||||||
|
: emailAvailable === true
|
||||||
|
? 'check'
|
||||||
|
: emailAvailable === false
|
||||||
|
? 'x'
|
||||||
|
: undefined
|
||||||
)
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -229,62 +241,67 @@
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Input
|
<section class="input-group">
|
||||||
type="text"
|
<Input
|
||||||
name="username"
|
type="text"
|
||||||
label={m.auth_register_username()}
|
name="username"
|
||||||
value={username}
|
placeholder={m.auth_register_username()}
|
||||||
oninput={onUsernameInput}
|
value={username}
|
||||||
autocomplete="username"
|
oninput={onUsernameInput}
|
||||||
minlength={3}
|
minlength={3}
|
||||||
maxLength={20}
|
maxLength={20}
|
||||||
required
|
required
|
||||||
fullWidth
|
fullWidth
|
||||||
contained
|
contained
|
||||||
error={usernameError}
|
error={usernameError}
|
||||||
rightIcon={usernameIcon}
|
rightIcon={usernameIcon}
|
||||||
/>
|
no1password
|
||||||
|
/>
|
||||||
|
<span class="note">{m.auth_register_usernameNote()}</span>
|
||||||
|
</section>
|
||||||
|
|
||||||
<Input
|
<section class="input-group">
|
||||||
type="email"
|
<Input
|
||||||
name="email"
|
type="email"
|
||||||
label={m.auth_register_email()}
|
name="email"
|
||||||
value={email}
|
placeholder={m.auth_register_email()}
|
||||||
oninput={onEmailInput}
|
value={email}
|
||||||
autocomplete="email"
|
oninput={onEmailInput}
|
||||||
required
|
autocomplete="email"
|
||||||
fullWidth
|
required
|
||||||
contained
|
fullWidth
|
||||||
error={emailError}
|
contained
|
||||||
rightIcon={emailIcon}
|
error={emailError}
|
||||||
/>
|
rightIcon={emailIcon}
|
||||||
|
/>
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
type="password"
|
type="password"
|
||||||
name="password"
|
name="password"
|
||||||
label={m.auth_register_password()}
|
placeholder={m.auth_register_password()}
|
||||||
value={password}
|
value={password}
|
||||||
oninput={onPasswordInput}
|
oninput={onPasswordInput}
|
||||||
autocomplete="new-password"
|
autocomplete="new-password"
|
||||||
minlength={8}
|
minlength={8}
|
||||||
required
|
required
|
||||||
fullWidth
|
fullWidth
|
||||||
contained
|
contained
|
||||||
error={passwordError}
|
error={passwordError}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
type="password"
|
type="password"
|
||||||
name="password_confirmation"
|
name="password_confirmation"
|
||||||
label={m.auth_register_confirmPassword()}
|
placeholder={m.auth_register_confirmPassword()}
|
||||||
value={passwordConfirmation}
|
value={passwordConfirmation}
|
||||||
oninput={onPasswordConfirmationInput}
|
oninput={onPasswordConfirmationInput}
|
||||||
autocomplete="new-password"
|
autocomplete="new-password"
|
||||||
required
|
required
|
||||||
fullWidth
|
fullWidth
|
||||||
contained
|
contained
|
||||||
error={passwordConfirmationError}
|
error={passwordConfirmationError}
|
||||||
/>
|
/>
|
||||||
|
</section>
|
||||||
|
|
||||||
{#if form?.error}
|
{#if form?.error}
|
||||||
<p class="error">{form.error}</p>
|
<p class="error">{form.error}</p>
|
||||||
|
|
@ -311,7 +328,20 @@
|
||||||
form {
|
form {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: $unit-2x;
|
gap: $unit-4x;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-group {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: $unit;
|
||||||
|
|
||||||
|
.note {
|
||||||
|
color: var(--text-secondary);
|
||||||
|
font-size: $font-small;
|
||||||
|
text-align: center;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
.error {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue