Redesign UI with new token system, primitives, and motion

Restraint-first design language: neutral gray surfaces + one blue accent
(cyan/amber/red reserved for state), 8pt spacing, softer radii, one
ambient + one raised shadow, standardized motion tokens. Alfa Slab One
demoted to BrandMark only; Inter carries all page copy.

New primitives (Button, Card, Badge, Stat, SectionHeader, Skeleton,
EmptyState, Tabs, Breadcrumbs, StatusPip, Field, Input, Select, Textarea)
plus motion utilities (tweenNumber, viewTransition) and a global toast
system. All eight route surfaces rewritten on top: Fleet gains an
overview hero, Server detail restructures into tabs, Deployments gets a
collapsible drift summary + per-server pipeline visual, and the
scripts/configs/plugins/betas flows adopt the new form primitives.

Sticky translucent nav with backdrop blur, view-transition cross-fades
between routes, staggered card entrance on Fleet, breathing status pip
halo, tabular-numeric player counts. Gmail-style g-key nav shortcuts.
Mobile stacks below 720px; prefers-reduced-motion neutralizes durations.
Legacy tokens preserved as aliases so any un-migrated code still renders.
This commit is contained in:
2026-09-14 19:48:48 -04:00
parent efd4a4fa66
commit a2d4a38925
34 changed files with 5093 additions and 3144 deletions
+256 -263
View File
@@ -1,5 +1,13 @@
<script lang="ts">
import { onMount } from 'svelte';
import Card from '$ui/components/primitives/Card.svelte';
import Badge from '$ui/components/primitives/Badge.svelte';
import Button from '$ui/components/primitives/Button.svelte';
import SectionHeader from '$ui/components/primitives/SectionHeader.svelte';
import EmptyState from '$ui/components/primitives/EmptyState.svelte';
import Field from '$ui/components/primitives/Field.svelte';
import Input from '$ui/components/primitives/Input.svelte';
import Select from '$ui/components/primitives/Select.svelte';
interface ScriptRow {
id: number;
@@ -10,22 +18,14 @@
current_version_id: number | null;
kind: 'script' | 'config' | 'plugin' | 'baseline';
latestVersion: {
id: number;
version: number;
sha256: string;
size: number;
state: 'untested' | 'tested' | 'test-failed';
uploaded_at: string;
id: number; version: number; sha256: string; size: number;
state: 'untested' | 'tested' | 'test-failed'; uploaded_at: string;
} | null;
versionCount: number;
servers: string[];
runningBetaId: number | null;
}
interface ScopeOptions {
games: string[];
mapsByGame: Record<string, string[]>;
}
interface ScopeOptions { games: string[]; mapsByGame: Record<string, string[]>; }
let scripts = $state<ScriptRow[]>([]);
let loading = $state(true);
@@ -34,7 +34,6 @@
let scopeOptions = $state<ScopeOptions>({ games: [], mapsByGame: {} });
let successBanner = $state<{ name: string; scriptId: number; version: number } | null>(null);
// Form state for creating a new script.
let newName = $state('');
let newScopeType = $state<'none' | 'game' | 'map'>('none');
let newScopeGame = $state('');
@@ -42,37 +41,20 @@
let newFile = $state<File | null>(null);
let newNotes = $state('');
// The scope value we send to the API — computed from the two selects so
// scope=map ships the map (game is just a filter narrowing the map list).
const scopeValue = $derived.by(() => {
if (newScopeType === 'game') return newScopeGame;
if (newScopeType === 'map') return newScopeMap;
return '';
});
// Live preview: which servers would this script land on? Empty when the
// scope matches nothing OR when scope=none (unscoped scripts only push to
// explicitly-chosen beta targets, so there's no promotion audience yet).
let serverCache = $state<Array<{ name: string; game: string | null; map: string | null }>>([]);
const matchingServers = $derived.by(() => {
if (newScopeType === 'none') return null;
if (!scopeValue) return null;
// scope-options carries fleet distincts, but not the (server → game/map)
// mapping. We derive the count by checking every server in `scripts`
// list responses — instead, use the /api/servers list. For simplicity
// we call a scoped preview against the API on the fly. Cheaper: reuse
// scope options — but we don't have server names. Fetch servers once.
return matchingServersFromCache();
});
let serverCache = $state<Array<{ name: string; game: string | null; map: string | null }>>([]);
function matchingServersFromCache(): string[] {
return serverCache
.filter((s) => {
const field = newScopeType === 'game' ? s.game : s.map;
return field === scopeValue;
})
.filter((s) => (newScopeType === 'game' ? s.game : s.map) === scopeValue)
.map((s) => s.name);
}
});
async function load(): Promise<void> {
const [scriptsRes, scopeRes, serversRes] = await Promise.all([
@@ -87,27 +69,22 @@
serverCache = sBody.servers;
loading = false;
}
onMount(load);
function pickFile(e: Event): void {
const t = e.target as HTMLInputElement;
newFile = t.files?.[0] ?? null;
// Every T5 script lands in a flat sp/ directory, so target rel path is
// just the filename — no need to ask the user.
if (!newName && newFile) newName = newFile.name.replace(/\.[^.]+$/, '');
}
async function createScript(e: Event): Promise<void> {
e.preventDefault();
if (uploading || !newFile || !newName.trim()) return;
// Guard: scope was set but no value picked yet.
if (newScopeType !== 'none' && !scopeValue) {
flash = `pick a ${newScopeType}`;
flash = `Pick a ${newScopeType}`;
return;
}
uploading = true;
flash = null;
uploading = true; flash = null;
const form = new FormData();
form.append('name', newName.trim());
form.append('scopeType', newScopeType);
@@ -117,8 +94,7 @@
try {
const res = await fetch('/api/scripts', { method: 'POST', body: form });
const body = (await res.json()) as {
ok: boolean;
error?: string;
ok: boolean; error?: string;
script?: { id: number; name: string };
versionId?: number;
};
@@ -129,12 +105,9 @@
successBanner = body.script
? { name: body.script.name, scriptId: body.script.id, version: 1 }
: null;
newName = '';
newScopeType = 'none';
newScopeGame = '';
newScopeMap = '';
newNotes = '';
newFile = null;
newName = ''; newScopeType = 'none';
newScopeGame = ''; newScopeMap = '';
newNotes = ''; newFile = null;
await load();
} finally {
uploading = false;
@@ -143,251 +116,271 @@
function scopeLabel(s: ScriptRow): string {
if (!s.scope_type) return 'unscoped';
return `${s.scope_type}=${s.scope_value ?? '?'}`;
return `${s.scope_type} · ${s.scope_value ?? '?'}`;
}
// Configs/baselines and plugins have their own detail routes; scripts fall
// through to /scripts/{id}. The "all scripts" list is still an everything
// view, but each row deep-links to the right family.
function detailHref(s: ScriptRow): string {
if (s.kind === 'config' || s.kind === 'baseline') return `/configs/${s.id}`;
if (s.kind === 'plugin') return `/plugins/${s.id}`;
return `/scripts/${s.id}`;
}
// What state tag to show on a script row. Distinguishes "never promoted"
// (whole script is untested) from "promoted but has a newer untested
// version" (existing production is fine, but there's unreleased work).
function scriptStateTag(s: ScriptRow): { label: string; cls: string } | null {
function stateVariantFor(s: ScriptRow): 'online' | 'warning' | 'danger' | 'neutral' | null {
if (!s.latestVersion) return null;
if (s.current_version_id === null) return { label: 'untested', cls: 'state-untested' };
if (s.current_version_id === null) return 'neutral';
if (s.latestVersion.id !== s.current_version_id) {
if (s.latestVersion.state === 'untested') return { label: `v${s.latestVersion.version} untested`, cls: 'state-untested' };
if (s.latestVersion.state === 'tested') return { label: `v${s.latestVersion.version} tested`, cls: 'state-tested' };
if (s.latestVersion.state === 'test-failed') return { label: `v${s.latestVersion.version} test-failed`, cls: 'state-test-failed' };
if (s.latestVersion.state === 'untested') return 'neutral';
if (s.latestVersion.state === 'tested') return 'online';
if (s.latestVersion.state === 'test-failed') return 'danger';
}
return null;
}
function stateLabel(s: ScriptRow): string {
if (!s.latestVersion) return '';
if (s.current_version_id === null) return 'untested';
if (s.latestVersion.id !== s.current_version_id) {
return `v${s.latestVersion.version} ${s.latestVersion.state.replace('-', ' ')}`;
}
return '';
}
let gameOptions = $derived([
{ value: '', label: '— Pick a game —', disabled: true },
...scopeOptions.games.map((g) => ({ value: g, label: g }))
]);
let mapOptions = $derived([
{ value: '', label: '— Pick a map —', disabled: true },
...(scopeOptions.mapsByGame[newScopeGame] ?? []).map((m) => ({ value: m, label: m }))
]);
let scopeTypeOptions = [
{ value: 'none', label: 'Unscoped' },
{ value: 'game', label: 'Game' },
{ value: 'map', label: 'Map' }
];
</script>
<h1>Scripts</h1>
<div class="page">
<SectionHeader title="Scripts" subtitle="Upload a script, then open a beta to test it before promotion." />
<section class="panel">
<h2>Upload a script</h2>
{#if successBanner}
<div class="banner banner-info">
<strong>v{successBanner.version} uploaded — untested.</strong>
<span>Open a beta on <a href="/scripts/{successBanner.scriptId}">{successBanner.name}</a> to test it before it can be promoted.</span>
</div>
{/if}
<form onsubmit={createScript} class="upload-form">
<label>
<span class="k">name</span>
<input type="text" bind:value={newName} placeholder="hud tweaks" disabled={uploading} />
</label>
<label>
<span class="k">scope</span>
<div class="scope-row">
<select bind:value={newScopeType} disabled={uploading}>
<option value="none">unscoped</option>
<option value="game">game</option>
<option value="map">map</option>
</select>
{#if newScopeType === 'game'}
<select bind:value={newScopeGame} disabled={uploading}>
<option value="">— pick a game —</option>
{#each scopeOptions.games as g (g)}
<option value={g}>{g}</option>
{/each}
</select>
{:else if newScopeType === 'map'}
<select bind:value={newScopeGame} disabled={uploading}>
<option value="">— pick a game —</option>
{#each scopeOptions.games as g (g)}
<option value={g}>{g}</option>
{/each}
</select>
<select bind:value={newScopeMap} disabled={uploading || !newScopeGame}>
<option value="">— pick a map —</option>
{#each (scopeOptions.mapsByGame[newScopeGame] ?? []) as m (m)}
<option value={m}>{m}</option>
{/each}
</select>
{/if}
<!-- Upload form -->
<Card padding="lg">
<h2 class="panel-title">Upload a script</h2>
{#if successBanner}
<div class="banner">
<strong>v{successBanner.version} uploaded — untested.</strong>
<span>
Open a beta on <a href="/scripts/{successBanner.scriptId}">{successBanner.name}</a>
to test it before it can be promoted.
</span>
</div>
{#if newScopeType !== 'none' && scopeValue}
{@const matches = matchingServers ?? []}
{#if matches.length === 0}
<p class="preview warn">⚠ no matching servers in the fleet — the promoted script will land nowhere</p>
{:else}
<p class="preview ok">{matches.length} matching server{matches.length === 1 ? '' : 's'}: {matches.join(', ')}</p>
{/if}
{/if}
</label>
<label>
<span class="k">notes (optional)</span>
<input type="text" bind:value={newNotes} placeholder="what changed" disabled={uploading} />
</label>
<label>
<span class="k">file</span>
<input type="file" onchange={pickFile} disabled={uploading} />
</label>
<button type="submit" class="primary" disabled={uploading || !newFile || !newName}>
{uploading ? 'uploading…' : 'upload script'}
</button>
</form>
{#if flash}<p class="flash">{flash}</p>{/if}
</section>
{/if}
<section class="panel">
<h2>All scripts</h2>
{#if loading}
<p class="empty">loading…</p>
{:else if scripts.length === 0}
<p class="empty">no scripts yet — upload one above</p>
{:else}
<div class="scripts">
{#each scripts as s (s.id)}
<a class="script-row" href={detailHref(s)}>
<div class="row-top">
<span class="script-name">{s.name}</span>
<span class="scope tag scope-{s.scope_type ?? 'none'}">{scopeLabel(s)}</span>
{#if scriptStateTag(s)}
{@const t = scriptStateTag(s)!}
<span class="tag {t.cls}">{t.label}</span>
{/if}
{#if s.runningBetaId}
<span class="tag beta">beta {s.runningBetaId} running</span>
{/if}
</div>
<div class="row-meta mono">
<span>{s.target_rel_path}</span>
<span>v{s.latestVersion?.version ?? '—'} · {s.versionCount} version{s.versionCount === 1 ? '' : 's'}</span>
<span>{s.servers.length ? `${s.servers.length} matching server${s.servers.length === 1 ? '' : 's'}` : ''}</span>
</div>
</a>
{/each}
<form onsubmit={createScript} class="upload-form">
<Field label="Name">
<Input bind:value={newName} placeholder="hud tweaks" disabled={uploading} />
</Field>
<Field label="Notes" hint="Optional. What changed in this version.">
<Input bind:value={newNotes} placeholder="what changed" disabled={uploading} />
</Field>
<Field label="Scope" hint="Where this script deploys. Unscoped ships wherever a beta targets it.">
<div class="scope-row">
<Select bind:value={newScopeType} options={scopeTypeOptions} disabled={uploading} />
{#if newScopeType === 'game' || newScopeType === 'map'}
<Select bind:value={newScopeGame} options={gameOptions} disabled={uploading} />
{/if}
{#if newScopeType === 'map'}
<Select bind:value={newScopeMap} options={mapOptions} disabled={uploading || !newScopeGame} />
{/if}
</div>
{#if newScopeType !== 'none' && scopeValue}
{@const matches = matchingServers ?? []}
{#if matches.length === 0}
<div class="preview warn">No matching servers — the promoted script will land nowhere.</div>
{:else}
<div class="preview ok">
{matches.length} matching server{matches.length === 1 ? '' : 's'}: {matches.join(', ')}
</div>
{/if}
{/if}
</Field>
<Field label="File">
<Input type="file" onchange={pickFile} disabled={uploading} />
</Field>
<div class="form-actions">
<Button
type="submit"
variant="primary"
disabled={uploading || !newFile || !newName}
loading={uploading}
>
Upload script
</Button>
{#if flash}<span class="flash">{flash}</span>{/if}
</div>
</form>
</Card>
<!-- Script list -->
<section class="section">
<div class="section-head">
<h2>All scripts</h2>
<Badge variant="neutral" size="sm">{scripts.length}</Badge>
</div>
{/if}
</section>
{#if loading}
<div class="loading">Loading…</div>
{:else if scripts.length === 0}
<EmptyState title="No scripts yet" description="Upload one above to get started." />
{:else}
<div class="rows">
{#each scripts as s (s.id)}
<a class="row" href={detailHref(s)}>
<div class="row-top">
<span class="name">{s.name}</span>
<Badge
variant={s.scope_type === 'game' ? 'info' :
s.scope_type === 'map' ? 'warning' : 'neutral'}
size="sm"
>
{scopeLabel(s)}
</Badge>
{#if stateVariantFor(s)}
{@const v = stateVariantFor(s)!}
<Badge variant={v} size="sm">{stateLabel(s)}</Badge>
{/if}
{#if s.runningBetaId}
<Badge variant="warning" size="sm">β{s.runningBetaId} running</Badge>
{/if}
</div>
<div class="row-meta">
<span class="path">{s.target_rel_path}</span>
<span>v{s.latestVersion?.version ?? '—'} · {s.versionCount} version{s.versionCount === 1 ? '' : 's'}</span>
{#if s.servers.length}
<span>{s.servers.length} matching server{s.servers.length === 1 ? '' : 's'}</span>
{/if}
</div>
</a>
{/each}
</div>
{/if}
</section>
</div>
<style>
h1 {
color: var(--cream);
font-family: var(--font-display);
font-size: var(--text-3xl);
letter-spacing: var(--tracking-display);
line-height: var(--leading-tight);
margin: 0 0 28px;
}
.panel {
background: var(--bg-nav);
border: 1px solid var(--border);
border-radius: var(--r-md);
padding: var(--pad-panel);
margin-bottom: 20px;
}
h2 {
margin: 0 0 14px;
.page { display: flex; flex-direction: column; gap: var(--space-6); }
.loading { text-align: center; padding: var(--space-12); color: var(--text-tertiary); }
.panel-title {
margin: 0 0 var(--space-4);
font-family: var(--font-body);
font-size: var(--text-xs);
font-weight: 700;
text-transform: uppercase;
letter-spacing: 1.5px;
color: var(--ink-300);
font-size: var(--text-md);
font-weight: var(--weight-semibold);
color: var(--text-primary);
}
.empty { color: var(--ink-500); font-family: var(--font-mono); font-size: var(--text-mono); margin: 0; }
.upload-form { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.upload-form label { display: flex; flex-direction: column; gap: 6px; font-size: var(--text-xs); }
.upload-form label .k { color: var(--ink-500); text-transform: uppercase; letter-spacing: 1px; }
.upload-form input[type=text], .upload-form select, .upload-form input[type=file] {
background: var(--bg-page);
color: var(--ink-100);
border: 1px solid var(--border);
border-radius: var(--r-sm);
padding: 10px 12px;
font-family: var(--font-mono);
font-size: var(--text-mono);
}
.upload-form input[type=text]:focus, .upload-form select:focus {
outline: none;
border-color: var(--accent);
box-shadow: var(--accent-glow);
}
.scope-row { display: flex; gap: 8px; flex-wrap: wrap; }
.scope-row select:nth-of-type(1) { flex: 0 0 120px; }
.primary {
grid-column: 1 / -1;
background: linear-gradient(180deg, var(--blue-500), var(--blue-600));
border: 1px solid var(--blue-400);
border-radius: var(--r-sm);
padding: 12px 18px;
color: var(--cream);
font-family: var(--font-body);
font-weight: 600;
cursor: pointer;
}
.primary:disabled { opacity: 0.4; cursor: default; }
.flash { color: var(--danger-500); font-family: var(--font-mono); font-size: var(--text-mono); margin-top: 12px; }
.scripts { display: flex; flex-direction: column; gap: 8px; }
.script-row {
display: flex;
flex-direction: column;
gap: 6px;
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--r-sm);
padding: 14px 16px;
text-decoration: none;
color: var(--ink-100);
}
.script-row:hover { border-color: var(--accent); box-shadow: var(--accent-glow); }
.row-top { display: flex; gap: 12px; align-items: center; }
.script-name { color: var(--cream); font-weight: 600; font-size: var(--text-md); }
.row-meta { display: flex; gap: 24px; color: var(--ink-500); font-size: var(--text-mono-sm); }
.mono { font-family: var(--font-mono); }
.tag {
font-family: var(--font-mono);
font-size: var(--text-xs);
padding: 3px 9px;
border-radius: var(--r-sm);
border: 1px solid transparent;
}
.scope-none { background: var(--bg-nav); border-color: var(--border); color: var(--ink-500); }
.scope-game { background: rgba(124, 212, 255, 0.10); border-color: rgba(124, 212, 255, 0.3); color: var(--spark-500); }
.scope-map { background: rgba(255, 176, 32, 0.10); border-color: rgba(255, 176, 32, 0.35); color: var(--amber-500); }
.beta { background: rgba(255, 176, 32, 0.10); border-color: rgba(255, 176, 32, 0.3); color: var(--amber-500); }
.state-untested { background: var(--bg-nav); border-color: var(--border); color: var(--ink-300); }
.state-tested { background: rgba(124, 212, 255, 0.10); border-color: rgba(124, 212, 255, 0.3); color: var(--spark-500); }
.state-test-failed { background: rgba(255, 92, 92, 0.10); border-color: rgba(255, 92, 92, 0.4); color: var(--danger-500); }
.banner {
grid-column: 1 / -1;
display: flex;
flex-direction: column;
gap: 4px;
border-radius: var(--r-sm);
padding: 12px 14px;
margin-bottom: 12px;
font-size: var(--text-mono);
padding: var(--space-3) var(--space-4);
margin-bottom: var(--space-4);
background: rgba(124, 212, 255, 0.06);
border: 1px solid rgba(124, 212, 255, 0.22);
border-radius: var(--radius-md);
font-size: var(--text-sm);
color: var(--text-primary);
}
.banner-info {
background: rgba(124, 212, 255, 0.08);
border: 1px solid rgba(124, 212, 255, 0.28);
color: var(--ink-100);
}
.banner-info a { color: var(--spark-500); text-decoration: underline; }
.banner a { color: var(--state-online); text-decoration: underline; }
.upload-form {
display: grid;
gap: var(--space-4);
grid-template-columns: 1fr 1fr;
}
.scope-row {
display: flex;
gap: var(--space-2);
flex-wrap: wrap;
}
.scope-row :global(.wrap) { flex: 1 1 140px; min-width: 140px; }
.preview {
grid-column: 1 / -1;
margin: 4px 0 0;
margin-top: var(--space-2);
padding: var(--space-2) var(--space-3);
border-radius: var(--radius-md);
font-size: var(--text-xs);
font-family: var(--font-mono);
font-size: var(--text-mono-sm);
}
.preview.ok { color: var(--ink-300); }
.preview.warn { color: var(--amber-500); }
.preview.ok { background: var(--surface-sunken); color: var(--text-secondary); }
.preview.warn { background: rgba(255, 176, 32, 0.06); color: var(--state-warning); border: 1px solid rgba(255, 176, 32, 0.28); }
.scope-row select:nth-of-type(2), .scope-row select:nth-of-type(3) { flex: 1; }
.form-actions {
grid-column: 1 / -1;
display: flex;
align-items: center;
gap: var(--space-4);
}
.flash {
color: var(--state-danger);
font-family: var(--font-mono);
font-size: var(--text-xs);
}
.section { display: flex; flex-direction: column; gap: var(--space-3); }
.section-head {
display: flex;
align-items: center;
gap: var(--space-3);
}
.section-head h2 {
margin: 0;
font-family: var(--font-body);
font-size: var(--text-md);
font-weight: var(--weight-semibold);
color: var(--text-primary);
}
.rows { display: flex; flex-direction: column; gap: var(--space-2); }
.row {
display: flex;
flex-direction: column;
gap: var(--space-2);
padding: var(--space-4) var(--space-5);
background: color-mix(in oklab, var(--surface) 88%, transparent);
border: 1px solid var(--border-subtle);
border-radius: var(--radius-md);
color: var(--text-primary);
text-decoration: none;
transition:
background-color var(--dur-fast) var(--ease-standard),
border-color var(--dur-fast) var(--ease-standard);
}
.row:hover { background: var(--surface-raised); border-color: var(--border-strong); }
.row:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.row-top {
display: flex;
gap: var(--space-2);
align-items: center;
flex-wrap: wrap;
}
.name {
font-size: var(--text-md);
font-weight: var(--weight-semibold);
color: var(--text-primary);
letter-spacing: var(--tracking-tight);
}
.row-meta {
display: flex;
gap: var(--space-5);
color: var(--text-tertiary);
font-family: var(--font-mono);
font-size: var(--text-xs);
flex-wrap: wrap;
}
.path { color: var(--text-secondary); }
@media (max-width: 720px) {
.upload-form { grid-template-columns: 1fr; }
}
</style>