Skip to content

Move forgotPassword element #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: rewrite
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions src/routes/login/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

let name: string;
let password: string;
let passwordVisible: boolean;
let passwordInput: HTMLInputElement;
let error: HTMLSpanElement;

function submit() {
Expand All @@ -23,20 +25,32 @@
});
}

function togglePasswordVisibility() {
passwordVisible = !passwordVisible;
passwordInput.type = passwordVisible ? 'text' : 'password';
}

$: if (browser && $token) goto("/account");
</script>

<Centered>
<Form submit={submit} style="padding-right: calc(var(--container-padding) - var(--icon-size) - var(--button-padding));">
<Form submit={submit}>
<div style="display: inline-grid; align-items: center; row-gap: 10px; grid-template-columns: 1fr auto;">
<h1>Login</h1>

<!-- svelte-ignore a11y-autofocus -->
<input name="name" type="text" bind:value={name} placeholder="Username or Email" style="grid-column: 1;" required autofocus/>

<input name="password" type="password" bind:value={password} placeholder="Password" style="grid-column: 1;" required />
<div style="position: relative; grid-column: 1;">
<input name="password" bind:this={passwordInput} type="password" bind:value={password}
placeholder="Password" required style="padding-right: 34px;"/>

<button type="button" on:click={togglePasswordVisibility} id="password-toggle">
<Icon src={passwordVisible ? 'eye-off' : 'eye'}/>
</button>
</div>

<Link location="/forgotPassword" style="margin-inline: calc(var(--button-padding) / 2); grid-column: 2; width: fit-content;"><Icon src="help-circle" /></Link>
<Link location="/forgotPassword" style="grid-column: 1;">Password reset</Link>

<button type="submit" style="grid-column: 1;">Login</button>

Expand All @@ -46,3 +60,17 @@
</div>
</Form>
</Centered>

<style>
#password-toggle {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
padding: 0;
border: none !important;
background: none !important;
width: 24px;
height: 24px;
}
</style>
57 changes: 43 additions & 14 deletions src/routes/register/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<script lang="ts">
import Centered from "$lib/components/centered.svelte";
import Form from "$lib/components/form.svelte";
import { api } from "$lib/api";
import { browser } from "$app/environment";
import { token } from "$lib/user";
import { goto } from "$app/navigation";
import { Turnstile } from 'svelte-turnstile';
import Icon from "$lib/components/icon.svelte";
import {api} from "$lib/api";
import {browser} from "$app/environment";
import {token} from "$lib/user";
import {goto} from "$app/navigation";
import {Turnstile} from 'svelte-turnstile';

let username: string;
let email: string;
let password: string;
let passwordVisible: boolean;
let passwordInput: HTMLInputElement;
let cfToken: string;
let error: HTMLSpanElement;

Expand Down Expand Up @@ -40,6 +43,11 @@
});
}

function togglePasswordVisibility() {
passwordVisible = !passwordVisible;
passwordInput.type = passwordVisible ? 'text' : 'password';
}

if (browser && $token) goto("/account");
</script>

Expand All @@ -56,23 +64,44 @@

<input bind:value={email} type="email" placeholder="Email" id="email" name="email" required>

<input bind:value={password} type="password" placeholder="Password" id="password" name="password" required>
<div style="position: relative; grid-column: 1;">
<input name="password" bind:this={passwordInput} type="password" bind:value={password}
placeholder="Password" required style="padding-right: 34px;"/>

<button type="button" on:click={togglePasswordVisibility} id="password-toggle">
<Icon src={passwordVisible ? 'eye-off' : 'eye'}/>
</button>
</div>

<Turnstile
id="captcha"
siteKey="1x00000000000000000000AA"
theme="light"
on:turnstile-callback={onTurnstileSuccess}
on:turnstile-error={onTurnstileError}
on:turnstile-expired={onTurnstileError}
on:turnstile-timeout={onTurnstileError}
id="captcha"
siteKey="1x00000000000000000000AA"
theme="light"
on:turnstile-callback={onTurnstileSuccess}
on:turnstile-error={onTurnstileError}
on:turnstile-expired={onTurnstileError}
on:turnstile-timeout={onTurnstileError}
/>

<button type="submit">Register</button>

<p bind:this={error} class="error" style="display: none;" />
<p bind:this={error} class="error" style="display: none;"/>

<p>Have an account? <a href="/login">Login</a></p>
</Form>
{/if}
</Centered>

<style>
#password-toggle {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
padding: 0;
border: none !important;
background: none !important;
width: 24px;
height: 24px;
}
</style>
1 change: 1 addition & 0 deletions static/icons/eye-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/icons/eye.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions static/icons/help-circle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.