a bit of front-end work, changing users almost done on login, "drunk-code" no more (id hope), continuous processes and keybinds still not done.
This commit is contained in:
@@ -1,21 +1,55 @@
|
||||
<script lang="ts">
|
||||
import { enhance } from "$app/forms";
|
||||
import { ArrowRight, CircleAlert, Lock } from "@lucide/svelte";
|
||||
import { PASSWD } from "$lib/stores/bash/etc/userData";
|
||||
import { ArrowRight, ChevronLeft, ChevronRight, CircleAlert, Lock } from "@lucide/svelte";
|
||||
import type { effect } from "zod/v3";
|
||||
|
||||
let formElem: HTMLElement;
|
||||
let {init, form}: { init: (formData: FormData) => void, form: any} = $props();
|
||||
|
||||
const basePath: string = '/src/lib/assets/login/';
|
||||
|
||||
let userIndex: number = $state(3);
|
||||
|
||||
$inspect(userIndex);
|
||||
|
||||
let username: string = $state('gornodox');
|
||||
let userImage: string = $derived(`${basePath}${username}.png`);
|
||||
|
||||
function changeUser(direction: 0 | 1) {
|
||||
if(direction === 0) {
|
||||
userIndex--;
|
||||
document.getElementById('username')?.classList.add('switchR');
|
||||
}
|
||||
else {
|
||||
userIndex++;
|
||||
document.getElementById('username')?.classList.add('switchL');
|
||||
}
|
||||
if(userIndex >= PASSWD.length) userIndex = 0;
|
||||
if(userIndex < 0) userIndex = PASSWD.length - 1;
|
||||
|
||||
|
||||
|
||||
const user = PASSWD[userIndex];
|
||||
username = user.username;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div id="wrapper" class=" flex flex-col items-center" class:outro={form?.success}>
|
||||
<img class="rounded-full mb-4 border-primary-dark border-2" src="/src/lib/assets/login-avatar.png" alt="" width="80" height="80" />
|
||||
<div id="name" class="flex flex-row items-center text-text-muted-dark justify-center gap-4">
|
||||
<strong>gornodox</strong>
|
||||
<img class="rounded-full mb-4 border-primary-dark border-2" src={userImage} alt="" width="80" height="80" />
|
||||
<div id="name" class=" relative flex flex-row items-center text-text-muted-dark justify-center gap-4 w-1/2">
|
||||
<button onclick={() => changeUser(0)}
|
||||
class=" active:-translate-x-0.5 hover:text-primary-hover-dark"><ChevronLeft size={16} strokeWidth={2} /></button>
|
||||
<strong id="username" class=" mx-auto" onanimationend={(event) => {event.currentTarget.innerText = username; event.currentTarget.classList.remove('switchR', 'switchL');}}>gornodox</strong>
|
||||
<button onclick={() => changeUser(1)}
|
||||
class=" active:translate-x-0.5 hover:text-primary-hover-dark"><ChevronRight size={16} strokeWidth={2} /></button>
|
||||
</div>
|
||||
<form bind:this={formElem} onanimationend={() => {formElem.classList.remove('invalid')}} use:enhance={({ formData }) =>
|
||||
{
|
||||
init(formData);
|
||||
}
|
||||
} method="POST" action="?/login" class:invalid={form?.error} name="login-form" autocomplete="off" class="mt-6 flex flex-row gap-1">
|
||||
<input name="username" value={username} class=" hidden ">
|
||||
<div class=" bg-bg-lighter-dark flex flex-row ml-4 items-center rounded outline-none border border-transparent text-sm p-1.5 w-2xs text-text-dark focus-within:bg-bg-light-dark focus-within:border-primary-dark {form?.error ? 'focus-within:border-warning-dark text-warning-dark' : ''}">
|
||||
<Lock size={16} strokeWidth={2} />
|
||||
<input autofocus name="password" type="password" autocomplete="off" placeholder="Password..." class=" placeholder-text-dark {form?.error ? 'placeholder-warning-dark' : ''} grow ml-2 appearance-none outline-none">
|
||||
@@ -35,6 +69,45 @@
|
||||
animation: fadeIn 0.2s forwards cubic-bezier(.4,.7,0,.99);
|
||||
}
|
||||
|
||||
.switchL {
|
||||
animation: fadeSlideLeft 1s forwards cubic-bezier(.4,.7,0,.99);
|
||||
}
|
||||
|
||||
.switchR {
|
||||
animation: fadeSlideRight 1s forwards cubic-bezier(.4,.7,0,.99);
|
||||
}
|
||||
|
||||
|
||||
@keyframes fadeSlideLeft {
|
||||
25% {
|
||||
transform: translateX(-1rem);
|
||||
opacity: 0;
|
||||
}
|
||||
50% {
|
||||
transform: translateX(1rem);
|
||||
opacity: 0;
|
||||
}
|
||||
75% {
|
||||
transform: none;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeSlideRight {
|
||||
25% {
|
||||
transform: translateX(1rem);
|
||||
opacity: 0;
|
||||
}
|
||||
50% {
|
||||
transform: translateX(-1rem);
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
transform: none;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
to {
|
||||
opacity: 1;
|
||||
|
||||
Reference in New Issue
Block a user