From 8cb42f07a2e93212ed2aefff5c0d27c3ba34d5b4 Mon Sep 17 00:00:00 2001 From: orion Date: Tue, 23 Jun 2026 06:05:58 +0200 Subject: [PATCH] WIP: Reworked input module for the terminal front-end --- src/modules/Login.svelte | 14 +++--- src/modules/Terminal.svelte | 8 ++-- src/modules/terminal/Input.svelte | 76 ++++++++++++++++++++++++------- src/routes/+page.server.ts | 16 +++++-- src/routes/+page.svelte | 7 ++- src/style/animations.css | 36 ++++++++------- 6 files changed, 107 insertions(+), 50 deletions(-) diff --git a/src/modules/Login.svelte b/src/modules/Login.svelte index 093c902..673e1af 100644 --- a/src/modules/Login.svelte +++ b/src/modules/Login.svelte @@ -73,7 +73,7 @@ >
@@ -83,13 +83,13 @@ placeholder="Password..." class=" ml-2 grow appearance-none px-3 py-2 outline-none" /> +
- diff --git a/src/modules/Terminal.svelte b/src/modules/Terminal.svelte index 7a4c0d8..66b9d72 100644 --- a/src/modules/Terminal.svelte +++ b/src/modules/Terminal.svelte @@ -1,6 +1,8 @@ +
+
+
+
e.key === 'Enter' && (inputValue = '')} - oninput={handleInput} + onkeydown={(e) => keyDown(e)} onfocus={() => (isFocused = true)} onblur={() => (isFocused = false)} type="text" @@ -44,10 +78,20 @@
$ -
{inputValue}
- _ + + {#each inputValue.split('') as char} + {char} + {/each} + + _
diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 3494fbd..4378338 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -1,6 +1,7 @@ import { db } from '$lib/server/db'; import { config } from '$lib/server/db/schema'; import { PASSWD } from '$lib/stores/bash/etc/userData'; +import { error } from '@sveltejs/kit'; import { eq } from 'drizzle-orm'; import type { Actions, PageServerLoad } from './$types'; @@ -22,11 +23,16 @@ export const actions = { } satisfies Actions; export const load: PageServerLoad = async () => { - return { - config: await db - .select({ config: config.value }) + try { + const rows = await db + .select({ value: config.value }) .from(config) .where(eq(config.value, 'maintenance')) - .limit(1) - }; + .limit(1); + return { config: rows }; + } catch (err) { + console.error('Full error:', err); + // Optionally, throw a user-friendly error + throw error(500, 'Database query failed'); + } }; diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index eddfd38..8d72076 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -7,6 +7,7 @@ let { form, data } = $props(); const MAINTENANCE = $derived(Boolean(data.config[0])); + let username = $state(''); function welcomeSequence() { //isWelcomeSequence = true; @@ -16,12 +17,16 @@ function initializer(formData: FormData) { console.log(formData); + username = formData.get('username')?.toString() ?? 'foo'; + if (form?.error) return; /* const password = formData.get('password')?.toString(); const username = formData.get('username')?.toString(); if (!password || !username) throw new Error('password or username is null or undefined'); terminalComponent.init(username, password); */ } + + console.log(username); {#if MAINTENANCE} @@ -37,7 +42,7 @@
- +
{/if} diff --git a/src/style/animations.css b/src/style/animations.css index 1b554ad..a9b269b 100644 --- a/src/style/animations.css +++ b/src/style/animations.css @@ -1,14 +1,11 @@ @theme { --animate-loading: loading 1s ease-in-out infinite; --animate-cursor-blink: blink 1s step-end infinite; - --animate-error-shake: shake 0.82s cubic-bezier(.36,.07,.19,.97) both; + --animate-error-shake: shake 0.82s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; @keyframes blink { - 0% { - opacity: 0; - } 50% { - opacity: 1; + opacity: 0; } } @@ -26,17 +23,22 @@ } @keyframes shake { - 10%, 90% { - transform: translate3d(-1px, 0, 0); - } - 20%, 80% { - transform: translate3d(2px, 0, 0); - } - 30%, 50%, 70% { - transform: translate3d(-4px, 0, 0); - } - 40%, 60% { - transform: translate3d(4px, 0, 0); - } + 10%, + 90% { + transform: translate3d(-1px, 0, 0); + } + 20%, + 80% { + transform: translate3d(2px, 0, 0); + } + 30%, + 50%, + 70% { + transform: translate3d(-4px, 0, 0); + } + 40%, + 60% { + transform: translate3d(4px, 0, 0); + } } }