Skip to content

Modern Docker Management, Designed for Everyone

refactor: use field group components for specific pages

Kyle Mendella01787b0f227
diff --git a/frontend/knip.json b/frontend/knip.json
index 85c3ea533..1797bf507 100644
--- a/frontend/knip.json
+++ b/frontend/knip.json
@@ -1,30 +1,24 @@
{
- "$schema": "https://unpkg.com/knip@5/schema.json",
- "entry": [
- "src/routes/**/*.{svelte,ts,js}",
- "src/hooks.*.ts",
- "src/service-worker.ts",
- "svelte.config.js",
- "vite.config.ts",
- "src/lib/paraglide/messages/_index.js"
- ],
- "project": ["src/**/*.{svelte,ts,js}"],
- "ignore": [
- "src/lib/components/ui/**/index.ts",
- "src/lib/paraglide/runtime.js",
- "src/lib/paraglide/registry.js",
- "src/lib/paraglide/server.js"
- ],
- "ignoreDependencies": [
- "formsnap",
- "paneforge",
- "svelte-toolbelt",
- "sveltekit-superforms",
- "isomorphic-dompurify"
- ],
- "ignoreExportsUsedInFile": {
- "interface": true,
- "type": true
- },
- "tags": ["-lintignore"]
+ "$schema": "https://unpkg.com/knip@5/schema.json",
+ "entry": [
+ "src/routes/**/*.{svelte,ts,js}",
+ "src/hooks.*.ts",
+ "src/service-worker.ts",
+ "svelte.config.js",
+ "vite.config.ts",
+ "src/lib/paraglide/messages/_index.js"
+ ],
+ "project": ["src/**/*.{svelte,ts,js}"],
+ "ignore": [
+ "src/lib/components/ui/**/index.ts",
+ "src/lib/paraglide/runtime.js",
+ "src/lib/paraglide/registry.js",
+ "src/lib/paraglide/server.js"
+ ],
+ "ignoreDependencies": ["formsnap", "paneforge", "svelte-toolbelt", "sveltekit-superforms", "isomorphic-dompurify"],
+ "ignoreExportsUsedInFile": {
+ "interface": true,
+ "type": true
+ },
+ "tags": ["-lintignore"]
}
diff --git a/frontend/messages/en.json b/frontend/messages/en.json
index 3da3dbf45..704049c8b 100644
--- a/frontend/messages/en.json
+++ b/frontend/messages/en.json
@@ -744,7 +744,7 @@
"environments_refreshing": "Refreshing…",
"environments_name_placeholder": "My Lab Server",
"environments_name_too_long": "Name too long (max 25 characters)",
- "environments_api_url_placeholder": "http://192.168.1.100:3553",
+ "environments_api_url_placeholder": "192.168.1.100:3553",
"environments_api_url_description": "Full URL to the Arcane server endpoint",
"environments_name_required": "Environment name is required",
"environments_server_url_required": "Server URL is required",
diff --git a/frontend/src/lib/components/form/url-input.svelte b/frontend/src/lib/components/form/url-input.svelte
new file mode 100644
index 000000000..50844b95e
--- /dev/null
+++ b/frontend/src/lib/components/form/url-input.svelte
@@ -0,0 +1,70 @@
+<script lang="ts">
+ import * as DropdownMenu from '$lib/components/ui/dropdown-menu/index.js';
+ import * as ButtonGroup from '$lib/components/ui/button-group/index.js';
+ import * as InputGroup from '$lib/components/ui/input-group/index.js';
+ import { Label } from '$lib/components/ui/label/index.js';
+ import { Button } from '$lib/components/ui/button/index.js';
+ import ChevronDownIcon from '@lucide/svelte/icons/chevron-down';
+
+ type Props = {
+ id?: string;
+ label?: string;
+ description?: string;
+ placeholder?: string;
+ value?: string;
+ protocol?: 'https' | 'http';
+ disabled?: boolean;
+ required?: boolean;
+ error?: string;
+ };
+
+ let {
+ id = 'url-input',
+ label,
+ description,
+ placeholder = 'example.com',
+ value = $bindable(''),
+ protocol = $bindable('https'),
+ disabled = false,
+ required = false,
+ error
+ }: Props = $props();
+
+ function selectProtocol(p: 'https' | 'http') {
+ protocol = p;
+ }
+</script>
+
+<div class="grid gap-2">
+ {#if label}
+ <Label for={id} class="text-xs">{label}</Label>
+ {/if}
+
+ <ButtonGroup.Root class="w-full">
+ <DropdownMenu.Root>
+ <DropdownMenu.Trigger>
+ {#snippet child({ props })}
+ <Button {...props} variant="secondary" class="w-[5.5rem] shrink-0 justify-between gap-1 text-sm" {disabled}>
+ {protocol}://
+ <ChevronDownIcon class="size-3 opacity-50" />
+ </Button>
+ {/snippet}
+ </DropdownMenu.Trigger>
+ <DropdownMenu.Content align="center" class="min-w-0">
+ <DropdownMenu.Item class="px-2 py-1.5" onclick={() => selectProtocol('https')}>https://</DropdownMenu.Item>
+ <DropdownMenu.Item class="px-2 py-1.5" onclick={() => selectProtocol('http')}>http://</DropdownMenu.Item>
+ </DropdownMenu.Content>
+ </DropdownMenu.Root>
+ <InputGroup.Root class={['flex-1', error ? 'border-destructive' : ''].filter(Boolean).join(' ')}>
+ <InputGroup.Input {id} bind:value {placeholder} {disabled} {required} aria-invalid={!!error} />
+ </InputGroup.Root>
+ </ButtonGroup.Root>
+
+ {#if description && !error}
+ <p class="text-muted-foreground text-xs">{description}</p>
+ {/if}
+
+ {#if error}
+ <p class="text-destructive text-xs">{error}</p>
+ {/if}
+</div>
diff --git a/frontend/src/lib/components/sheets/new-environment-sheet.svelte b/frontend/src/lib/components/sheets/new-environment-sheet.svelte
index 32b92f555..214ca5994 100644
--- a/frontend/src/lib/components/sheets/new-environment-sheet.svelte
+++ b/frontend/src/lib/components/sheets/new-environment-sheet.svelte
@@ -3,6 +3,7 @@
import * as Sheet from '$lib/components/ui/sheet/index.js';
import { Button } from '$lib/components/ui/button/index.js';
import FormInput from '$lib/components/form/form-input.svelte';
+ import UrlInput from '$lib/components/form/url-input.svelte';
import { Spinner } from '$lib/components/ui/spinner/index.js';
import ServerIcon from '@lucide/svelte/icons/server';
import * as Card from '$lib/components/ui/card';
@@ -21,9 +22,22 @@
let isSubmitting = $state(false);
+ let urlProtocol = $state<'https' | 'http'>('https');
+ let urlHost = $state('');
+
+ $effect(() => {
+ if (open) {
+ urlProtocol = 'https';
+ urlHost = '';
+ formData.name = '';
+ formData.apiUrl = '';
+ formData.bootstrapToken = '';
+ }
+ });
+
const formSchema = z.object({
name: z.string().min(1, m.environments_name_required()).max(25, m.environments_name_too_long()),
- apiUrl: z.url(m.common_invalid_url()).min(1, m.environments_server_url_required()),
+ apiUrl: z.string().min(1, m.environments_server_url_required()),
bootstrapToken: z.string()
});
@@ -33,6 +47,10 @@
bootstrapToken: ''
});
+ $effect(() => {
+ formData.apiUrl = urlHost;
+ });
+
let { inputs, ...form } = $derived(createForm<typeof formSchema>(formSchema, formData));
async function handleSubmit() {
@@ -42,9 +60,12 @@
try {
isSubmitting = true;
+ // Construct full URL from protocol and host
+ const fullUrl = `${urlProtocol}://${urlHost}`;
+
const dto: CreateEnvironmentDTO = {
name: data.name,
- apiUrl: data.apiUrl,
+ apiUrl: fullUrl,
bootstrapToken: data.bootstrapToken
};
@@ -100,12 +121,16 @@
<form onsubmit={preventDefault(handleSubmit)} class="space-y-4">
<FormInput label={m.common_name()} placeholder={m.environments_name_placeholder()} bind:input={$inputs.name} />
- <FormInput
+ <UrlInput
+ id="environment-api-url"
label={m.environments_api_url()}
- type="text"
placeholder={m.environments_api_url_placeholder()}
description={m.environments_api_url_description()}
- bind:input={$inputs.apiUrl}
+ bind:value={urlHost}
+ bind:protocol={urlProtocol}
+ disabled={isSubmitting}
+ required
+ error={$inputs.apiUrl.error ?? undefined}
/>
<FormInput
diff --git a/frontend/src/lib/components/ui/button-group/button-group-text.svelte b/frontend/src/lib/components/ui/button-group/button-group-text.svelte
index 37b6e29d6..c22e8b70b 100644
--- a/frontend/src/lib/components/ui/button-group/button-group-text.svelte
+++ b/frontend/src/lib/components/ui/button-group/button-group-text.svelte
@@ -13,7 +13,7 @@
const classes = $derived(
cn(
- "bg-muted shadow-xs flex items-center gap-2 rounded-md border px-4 text-sm font-medium [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",
+ "bg-input/80 shadow-xs flex items-center gap-2 rounded-lg border px-4 text-sm font-medium backdrop-blur-sm [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none",
className
)
);
diff --git a/frontend/src/lib/components/ui/input-group/input-group-input.svelte b/frontend/src/lib/components/ui/input-group/input-group-input.svelte
index 112fbeab5..bcdab735e 100644
--- a/frontend/src/lib/components/ui/input-group/input-group-input.svelte
+++ b/frontend/src/lib/components/ui/input-group/input-group-input.svelte
@@ -1,14 +1,16 @@
<script lang="ts">
import { cn } from '$lib/utils.js';
- import type { ComponentProps } from 'svelte';
- import { Input } from '$lib/components/ui/input/index.js';
+ import type { HTMLInputAttributes } from 'svelte/elements';
- let { value = $bindable(), class: className, ...props }: ComponentProps<typeof Input> = $props();
+ let { value = $bindable(), class: className, ...props }: HTMLInputAttributes & { value?: string } = $props();
</script>
-<Input
+<input
data-slot="input-group-control"
- class={cn('flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent', className)}
+ class={cn(
+ 'selection:bg-primary selection:text-primary-foreground placeholder:text-muted-foreground flex h-full w-full min-w-0 flex-1 bg-transparent px-3 py-1 text-base transition-all outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
+ className
+ )}
bind:value
{...props}
/>
diff --git a/frontend/src/lib/components/ui/input-group/input-group.svelte b/frontend/src/lib/components/ui/input-group/input-group.svelte
index ce7e371ef..4fa856771 100644
--- a/frontend/src/lib/components/ui/input-group/input-group.svelte
+++ b/frontend/src/lib/components/ui/input-group/input-group.svelte
@@ -9,7 +9,7 @@
data-slot="input-group"
role="group"
class={cn(
- 'group/input-group border-input dark:bg-input/30 relative flex w-full items-center rounded-md border shadow-xs transition-[color,box-shadow] outline-none',
+ 'group/input-group bg-input/80 relative flex w-full items-center overflow-hidden rounded-lg border shadow-xs backdrop-blur-sm transition-all outline-none',
'h-9 has-[>textarea]:h-auto',
// Variants based on alignment.
@@ -19,7 +19,7 @@
'has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-end]]:[&>input]:pt-3',
// Focus state.
- 'has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px]',
+ 'has-[[data-slot=input-group-control]:focus-visible]:bg-input/90 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot=input-group-control]:focus-visible]:ring-[3px] has-[[data-slot=input-group-control]:focus-visible]:backdrop-blur-md',
// Error state.
'has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[[data-slot][aria-invalid=true]]:border-destructive dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40',
diff --git a/frontend/src/routes/auth/login/+page.svelte b/frontend/src/routes/auth/login/+page.svelte
index 5e2945d23..6c64e5b2c 100644
--- a/frontend/src/routes/auth/login/+page.svelte
+++ b/frontend/src/routes/auth/login/+page.svelte
@@ -1,9 +1,9 @@
<script lang="ts">
import { Button } from '$lib/components/ui/button/index.js';
- import { Input } from '$lib/components/ui/input/index.js';
import { Label } from '$lib/components/ui/label/index.js';
import * as Card from '$lib/components/ui/card/index.js';
import * as Alert from '$lib/components/ui/alert/index.js';
+ import * as InputGroup from '$lib/components/ui/input-group/index.js';
import CircleAlertIcon from '@lucide/svelte/icons/alert-circle';
import LogInIcon from '@lucide/svelte/icons/log-in';
import LockIcon from '@lucide/svelte/icons/lock';
@@ -167,41 +167,39 @@
<form onsubmit={handleLogin} class="space-y-4">
<div class="space-y-2">
<Label for="username" class="text-xs">{m.common_username()}</Label>
- <div class="relative">
- <div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
- <UserIcon class="text-muted-foreground size-4" />
- </div>
- <Input
+ <InputGroup.Root>
+ <InputGroup.Addon>
+ <UserIcon />
+ </InputGroup.Addon>
+ <InputGroup.Input
id="username"
name="username"
type="text"
autocomplete="username"
required
bind:value={username}
- class="glass-light pl-9"
placeholder={m.auth_username_placeholder()}
disabled={loading}
/>
- </div>
+ </InputGroup.Root>
</div>
<div class="space-y-2">
<Label for="password" class="text-xs">{m.common_password()}</Label>
- <div class="relative">
- <div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
- <LockIcon class="text-muted-foreground size-4" />
- </div>
- <Input
+ <InputGroup.Root>
+ <InputGroup.Addon>
+ <LockIcon />
+ </InputGroup.Addon>
+ <InputGroup.Input
id="password"
name="password"
type="password"
autocomplete="current-password"
required
bind:value={password}
- class="glass-light pl-9"
placeholder={m.auth_password_placeholder()}
disabled={loading}
/>
- </div>
+ </InputGroup.Root>
</div>
<Button type="submit" class="hover-lift w-full" size="lg" disabled={loading} aria-busy={loading}>
{#if loading}