From 3b91fad5903a26fdb5c46ff2fbbe8779a29af564 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 5 May 2026 15:55:51 +0100 Subject: [PATCH] Implement 'internal submit button' to the 'Textbox' component. Remove separate submit to the Headcode search card. Adjust the hover and active styles of the 'TrainService' expandable cards. --- src/lib/components/ui/Textbox.svelte | 75 +++++++++++++++++-- src/lib/components/ui/TrainService.svelte | 14 +++- .../ui/cards/HeadcodeSearchCard.svelte | 12 ++- 3 files changed, 85 insertions(+), 16 deletions(-) diff --git a/src/lib/components/ui/Textbox.svelte b/src/lib/components/ui/Textbox.svelte index 37018a9..8619f50 100644 --- a/src/lib/components/ui/Textbox.svelte +++ b/src/lib/components/ui/Textbox.svelte @@ -2,6 +2,8 @@ import { fade } from 'svelte/transition'; import type { HTMLInputAttributes } from 'svelte/elements'; + import { IconChevronRightFilled } from '@tabler/icons-svelte'; + interface Props extends HTMLInputAttributes { value?: string; label?: string; @@ -9,6 +11,7 @@ type?: 'text' | 'password' | 'email' | 'number' | 'search' | 'tel' | 'url'; error?: string; uppercase?: boolean; + onsubmit?: (val: string) => void | Promise; [key: string]: any; } @@ -19,10 +22,18 @@ type = 'text', error = '', uppercase = false, + onsubmit, ...rest }: Props = $props(); let isFocussed = $state(false); + + const handleSubmit = (e: Event) => { + e.preventDefault(); + if (onsubmit && value) { + onsubmit(value); + } + }
@@ -30,6 +41,7 @@ {/if} +
+ {#if onsubmit} + + {/if} +
+ {#if error} {error} {/if} @@ -50,11 +75,22 @@ .input-wrapper { display: flex; flex-direction: column; - gap: 8px; + gap: 0.4rem; width: 100%; font-family: 'URW Gothic', sans-serif; } + .input-container { + position: relative; + display: flex; + align-items: center; + width: 100%; + background-color: var(--color-title); + border-radius: 5000px; + transition: all 0.2s; + overflow: hidden; + } + label { font-size: 0.9rem; font-weight: 400; @@ -62,19 +98,46 @@ } input { + width: 100%; + background: transparent; min-height: 40px; - padding: 0 16px; - background-color: var(--color-title); - border: 2px solid transparent; - border-radius: 20px; + height: 100%; + line-height: normal; + padding: 0 48px; + border: none; color: var(--color-bg-dark); font-size: 1.2rem; transition: all 0.2s ease-in-out; outline: none; text-align: center; - box-shadow: var(--shadow-std); } + .submit-icon { + position: absolute; + background: transparent; + right: 0; + border: none; + color: var(--color-bg-dark); + cursor: pointer; + width: 48px; + height: 48px; + display: flex; + align-items: center; + justify-content: center; + opacity: 0.75; + transition: opacity 0.2s, transform 0.2s; + } + + .submit-icon:hover:not(:disabled) { + opacity: 1; + transform: translateX(2px); + } + + .submit-icon:disabled { + opacity: 0.5; + cursor: not-allowed; + } + .all-caps { text-transform: uppercase; } diff --git a/src/lib/components/ui/TrainService.svelte b/src/lib/components/ui/TrainService.svelte index b1cc9c4..820918d 100644 --- a/src/lib/components/ui/TrainService.svelte +++ b/src/lib/components/ui/TrainService.svelte @@ -93,7 +93,7 @@ }; -
+
- +
+ +