feat: design system with light/dark themes and icon-first UI

Adds a real design system to replace the per-route ad-hoc styling:

- docs/design-system.md is the contract. Semantic CSS custom-property
  tokens (color/type/spacing/radii/shadows/z-index) with verified WCAG
  AA/AAA contrast ratios for both themes.
- frontend/src/lib/styles/tokens.css defines :root tokens + a
  [data-theme="dark"] override + base element resets, a .form-field
  helper, and a global prefers-reduced-motion rule.
- frontend/src/lib/theme.svelte.ts is a Svelte 5 runes store backing
  the theme state machine (system | light | dark). localStorage key
  'mangalord-theme'; matchMedia subscription that re-resolves on OS
  theme change while in 'system' mode; init() / destroy() lifecycle
  wired from +layout.svelte.
- frontend/src/app.html runs a synchronous inline script before
  %sveltekit.head% to set [data-theme] before first paint. No FOUC.
- /settings gains a System / Light / Dark radiogroup (real fieldset +
  legend + radios with lucide icons).
- Every route's <style> block is rewritten to consume tokens — home,
  auth, upload (drop-zone + page list), bookmarks, manga overview,
  reader.
- @lucide/svelte icons replace ad-hoc text controls per the spec:
  Search (icon-only primary), LogOut (icon-only muted), Upload /
  Bookmarks / Settings nav inline icons, ChevronLeft/Right for the
  reader, ArrowUp/Down/Trash2 for the upload page list. The bookmark
  toggle keeps its '☆ Bookmark' / '★ Bookmarked' text verbatim.
- Home search controls split into two rows: input + Search CTA on
  row 1, Sort (and future filters) on row 2.

Accessibility: every icon-only button carries aria-label, every
decorative SVG aria-hidden; existing image alt text preserved;
focus-visible rings reach every interactive element including the
visually-hidden theme radios; color is never the sole conveyor.

Version bump 0.12.0 → 0.13.0 across backend/Cargo.toml and
frontend/package.json (feat: → minor per CLAUDE.md).

Bars: svelte-check 0/0, vitest 51/51, playwright 18/18, cargo test
88/88, clippy -D warnings clean. Two rounds of independent review;
verdict ship-ready.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
MechaCat02
2026-05-17 11:52:58 +02:00
parent f0e57b0615
commit 567d56bfa1
17 changed files with 1271 additions and 237 deletions

View File

@@ -3,6 +3,14 @@
import { changePassword } from '$lib/api/auth';
import { ApiError } from '$lib/api/client';
import { session } from '$lib/session.svelte';
import { theme, type Theme } from '$lib/theme.svelte';
import Monitor from '@lucide/svelte/icons/monitor';
import Sun from '@lucide/svelte/icons/sun';
import Moon from '@lucide/svelte/icons/moon';
function setTheme(next: Theme) {
theme.set(next);
}
let currentPassword = $state('');
let newPassword = $state('');
@@ -57,10 +65,53 @@
<h1>Settings</h1>
<section class="card" aria-label="Appearance">
<h2>Appearance</h2>
<fieldset class="theme-picker">
<legend>Theme</legend>
<label class="theme-option" class:selected={theme.value === 'system'}>
<input
type="radio"
name="theme"
value="system"
checked={theme.value === 'system'}
onchange={() => setTheme('system')}
data-testid="theme-radio-system"
/>
<Monitor size={18} aria-hidden="true" />
<span>System</span>
</label>
<label class="theme-option" class:selected={theme.value === 'light'}>
<input
type="radio"
name="theme"
value="light"
checked={theme.value === 'light'}
onchange={() => setTheme('light')}
data-testid="theme-radio-light"
/>
<Sun size={18} aria-hidden="true" />
<span>Light</span>
</label>
<label class="theme-option" class:selected={theme.value === 'dark'}>
<input
type="radio"
name="theme"
value="dark"
checked={theme.value === 'dark'}
onchange={() => setTheme('dark')}
data-testid="theme-radio-dark"
/>
<Moon size={18} aria-hidden="true" />
<span>Dark</span>
</label>
</fieldset>
</section>
{#if !session.loaded}
<p data-testid="settings-loading">Loading…</p>
<p class="status" data-testid="settings-loading">Loading…</p>
{:else if !session.user}
<p data-testid="settings-signin">
<p class="status" data-testid="settings-signin">
<a href="/login">Sign in</a> to change your password.
</p>
{:else}
@@ -72,8 +123,8 @@
list if you want to invalidate them too.
</p>
<form onsubmit={submit} action="javascript:void(0)" data-testid="password-form">
<label>
Current password
<label class="form-field">
<span>Current password</span>
<input
type="password"
bind:value={currentPassword}
@@ -82,8 +133,8 @@
data-testid="current-password"
/>
</label>
<label>
New password
<label class="form-field">
<span>New password</span>
<input
type="password"
bind:value={newPassword}
@@ -93,8 +144,8 @@
data-testid="new-password"
/>
</label>
<label>
Confirm new password
<label class="form-field">
<span>Confirm new password</span>
<input
type="password"
bind:value={confirmPassword}
@@ -110,6 +161,7 @@
{/if}
</label>
<button
class="primary"
type="submit"
disabled={!canSubmit}
data-testid="password-submit"
@@ -127,34 +179,108 @@
{/if}
<style>
.status {
color: var(--text-muted);
}
.card {
border: 1px solid #ddd;
border-radius: 6px;
padding: 1rem;
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius-md);
padding: var(--space-4);
max-width: 32rem;
margin-bottom: var(--space-4);
}
.hint {
color: #555;
font-size: 0.95rem;
color: var(--text-muted);
font-size: var(--font-sm);
}
form {
display: flex;
flex-direction: column;
gap: 0.75rem;
gap: var(--space-3);
}
label {
display: flex;
flex-direction: column;
gap: 0.25rem;
.primary {
background: var(--primary);
color: var(--primary-contrast);
border-color: var(--primary);
margin-top: var(--space-1);
align-self: flex-start;
}
.primary:hover:not(:disabled) {
background: var(--primary-hover);
border-color: var(--primary-hover);
}
.field-error {
color: #b00020;
font-size: 0.9rem;
color: var(--danger);
font-size: var(--font-sm);
}
.form-error {
color: #b00020;
color: var(--danger);
}
.success {
color: #0a7d2c;
color: var(--success);
}
.theme-picker {
display: flex;
flex-wrap: wrap;
gap: var(--space-2);
border: none;
padding: 0;
margin: 0;
}
.theme-picker legend {
font-size: var(--font-sm);
color: var(--text);
padding: 0;
margin-bottom: var(--space-2);
}
.theme-option {
display: inline-flex;
align-items: center;
gap: var(--space-2);
padding: var(--space-2) var(--space-3);
border: 1px solid var(--border-strong);
border-radius: var(--radius-md);
background: var(--surface);
color: var(--text);
font-size: var(--font-sm);
cursor: pointer;
transition:
background var(--transition),
border-color var(--transition);
}
.theme-option:hover {
background: var(--surface-elevated);
}
.theme-option input[type='radio'] {
position: absolute;
opacity: 0;
pointer-events: none;
width: 0;
height: 0;
}
.theme-option.selected {
background: var(--primary-soft-bg);
border-color: var(--primary);
color: var(--text);
}
.theme-option:has(input:focus-visible) {
outline: 2px solid var(--focus-ring);
outline-offset: 2px;
}
</style>