Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

design(W2): ein Primaer-Rezept und die Hellmodus-Luecken, mit gerechnetem Kontrast

Davidf336b91eb1eb
diff --git a/src/components/__tests__/primary-recipe.test.ts b/src/components/__tests__/primary-recipe.test.ts
new file mode 100644
index 00000000..8ed92395
--- /dev/null
+++ b/src/components/__tests__/primary-recipe.test.ts
@@ -0,0 +1,173 @@
+/**
+ * Das Primaer-Rezept `.lu-primary` und die Hellmodus-Zusicherungen dazu.
+ *
+ * Warum als Test und nicht als Sichtpruefung: die Testumgebung ist
+ * `environment: 'node'` ohne DOM, also kann hier nichts gerendert werden.
+ * Was sich aber OHNE DOM pruefen laesst, ist die Eigenschaft, um die es
+ * eigentlich geht — dass die Textfarbe auf der Akzentflaeche den
+ * WCAG-Kontrast wirklich erreicht. Der Kontrast wird hier aus den echten
+ * Tokens in index.css AUSGERECHNET, nicht als Zahl abgeschrieben: wer den
+ * Akzent verschiebt, faellt hier durch statt still unlesbar zu werden.
+ */
+import { describe, it, expect } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { resolve } from 'node:path'
+
+const css = readFileSync(resolve(__dirname, '../../index.css'), 'utf-8')
+const read = (rel: string) => readFileSync(resolve(__dirname, rel), 'utf-8')
+
+/** WCAG 2.1 relative Luminanz eines #rrggbb-Werts. */
+function luminance(hex: string): number {
+ const h = hex.replace('#', '')
+ const channel = (i: number) => {
+ const c = parseInt(h.slice(i, i + 2), 16) / 255
+ return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4
+ }
+ return 0.2126 * channel(0) + 0.7152 * channel(2) + 0.0722 * channel(4)
+}
+
+/** WCAG 2.1 Kontrastverhaeltnis zweier #rrggbb-Werte, immer >= 1. */
+function contrast(a: string, b: string): number {
+ const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x)
+ return (hi + 0.05) / (lo + 0.05)
+}
+
+/** Liest einen `--color-*: #rrggbb;`-Token aus dem @theme-Block. */
+function token(name: string): string {
+ const m = css.match(new RegExp(`--${name}:\\s*(#[0-9a-fA-F]{6})\\s*;`))
+ if (!m) throw new Error(`Token --${name} fehlt in index.css`)
+ return m[1]
+}
+
+describe('Kontrastfunktion (Referenzwerte aus der WCAG-Spec)', () => {
+ it('rechnet die bekannten Eckwerte richtig', () => {
+ expect(contrast('#000000', '#ffffff')).toBeCloseTo(21, 5)
+ expect(contrast('#ffffff', '#ffffff')).toBeCloseTo(1, 5)
+ // Symmetrisch — die Reihenfolge der Argumente darf nichts aendern.
+ expect(contrast('#a094f8', '#111827')).toBeCloseTo(contrast('#111827', '#a094f8'), 10)
+ })
+})
+
+describe('Primaer-Rezept: Kontrast auf der Akzentflaeche', () => {
+ const accent = () => token('color-lu-accent')
+ const accentHover = () => token('color-lu-accent-hover')
+ const onAccent = () => token('color-lu-on-accent')
+
+ it('Text auf dem Akzent erreicht WCAG AA (4.5:1) — im Ruhezustand', () => {
+ // Gemessen 2.6.7: #a094f8 gegen #111827 = 6.83:1
+ expect(contrast(accent(), onAccent())).toBeGreaterThanOrEqual(4.5)
+ })
+
+ it('Text auf dem Akzent erreicht WCAG AA auch im Hover-Zustand', () => {
+ // Gemessen 2.6.7: #b1a6ff gegen #111827 = 8.25:1
+ expect(contrast(accentHover(), onAccent())).toBeGreaterThanOrEqual(4.5)
+ })
+
+ it('weisser Text auf dem Akzent wuerde durchfallen — deshalb dunkler Text', () => {
+ // Das ist der Grund fuer --color-lu-on-accent. Faellt diese Zusicherung,
+ // ist der Akzent so dunkel geworden, dass weisser Text wieder ginge —
+ // dann gehoert die Textfarbe neu entschieden, nicht der Test gestrichen.
+ expect(contrast(accent(), '#ffffff')).toBeLessThan(4.5)
+ })
+
+ it('die Hellmodus-Kante erreicht 3:1 gegen Weiss (WCAG 1.4.11)', () => {
+ // Die Akzentflaeche selbst steht nur 2.6:1 gegen Weiss; die Kante traegt
+ // die Buttongrenze im Hellmodus.
+ expect(contrast(token('color-lu-accent-edge'), '#ffffff')).toBeGreaterThanOrEqual(3)
+ })
+
+ it('die Flaeche steht auf dem dunklen App-Grund fuer sich', () => {
+ expect(contrast(accent(), '#1e1e1e')).toBeGreaterThanOrEqual(3)
+ })
+})
+
+describe('Primaer-Rezept: genau einmal definiert', () => {
+ it('.lu-primary hat genau eine Basisregel in index.css', () => {
+ const base = css.match(/^\.lu-primary\s*\{/gm) ?? []
+ expect(base).toHaveLength(1)
+ })
+
+ it('das Rezept nennt keine Farbe als Literal, nur Tokens', () => {
+ const block = css.match(/^\.lu-primary\s*\{[^}]*\}/m)?.[0] ?? ''
+ expect(block).not.toMatch(/#[0-9a-fA-F]{3,8}/)
+ expect(block).toMatch(/var\(--color-lu-accent\)/)
+ expect(block).toMatch(/var\(--color-lu-on-accent\)/)
+ })
+
+ it('deckt Hover, Fokus und disabled ab — nicht nur die Ruhefarbe', () => {
+ expect(css).toMatch(/\.lu-primary:hover:not\(:disabled\)\s*\{/)
+ expect(css).toMatch(/\.lu-primary:focus-visible\s*\{/)
+ expect(css).toMatch(/\.lu-primary:disabled\s*\{/)
+ })
+
+ it('der Fokusring ist in beiden Modi gesetzt und liegt neben der Flaeche', () => {
+ const focus = css.match(/\.lu-primary:focus-visible\s*\{[^}]*\}/)?.[0] ?? ''
+ expect(focus).toMatch(/outline:\s*2px solid/)
+ // Abstand > 0, damit der Ring auf dem Hintergrund liegt und nicht auf dem
+ // Akzent selbst (dort haette er kaum Kontrast).
+ expect(focus).toMatch(/outline-offset:\s*[1-9]/)
+ // Dunkelmodus bekommt eine eigene, helle Ringfarbe.
+ expect(css).toMatch(/\.dark \.lu-primary:focus-visible\s*\{[^}]*outline-color/)
+ })
+
+ it('disabled sieht nicht aus wie die aktive Variante', () => {
+ const dis = css.match(/\.lu-primary:disabled\s*\{[^}]*\}/)?.[0] ?? ''
+ // Entsaettigen UND dimmen — Dimmen allein liesse die Flaeche noch violett
+ // und damit wie die aktive Primaeraktion aussehen.
+ expect(dis).toMatch(/grayscale\(1\)/)
+ expect(dis).toMatch(/opacity:\s*0?\.\d+/)
+ })
+})
+
+describe('Primaer-Rezept: alle drei Bildschirme benutzen dasselbe', () => {
+ const SITES: Array<[string, string]> = [
+ ['Create (Generate)', '../create/ui/Button.tsx'],
+ ['Account (Sign in)', '../auth/AccountPanel.tsx'],
+ ['Chat (Send)', '../chat/ChatInput.tsx'],
+ ]
+
+ it.each(SITES)('%s traegt .lu-primary', (_name, rel) => {
+ expect(read(rel)).toContain('lu-primary')
+ })
+
+ it.each(SITES)('%s schreibt kein eigenes Graustufen-Rezept mehr ab', (_name, rel) => {
+ const src = read(rel)
+ // Genau die drei Fuellungen, die das Audit als "drei graue Primaerbuttons"
+ // gefunden hatte. Keine davon darf zurueckkehren.
+ expect(src).not.toContain('bg-gray-900 text-white')
+ expect(src).not.toContain('dark:bg-white/10 dark:text-white')
+ expect(src).not.toContain('bg-white/8 text-gray-300')
+ })
+})
+
+describe('Hellmodus: keine dark-only Flaeche ohne Gegenstueck', () => {
+ // Die Dateien, die in dieser Welle re-verifiziert und bereinigt wurden.
+ // Jedes `bg-[#...]` darin muss entweder ein `dark:`-Praefix tragen oder
+ // eine Akzentfarbe sein, die in beiden Modi gilt.
+ const FILES = [
+ '../chat/ChatView.tsx',
+ '../chat/ChatInput.tsx',
+ '../create/experimental/CreateExperimental.tsx',
+ '../create/ui/Button.tsx',
+ '../auth/AccountPanel.tsx',
+ ]
+
+ it.each(FILES)('%s: jede Hex-Flaeche ist modus-bewusst', (rel) => {
+ const src = read(rel)
+ const offenders: string[] = []
+ for (const m of src.matchAll(/(\S*?)bg-\[(#[0-9a-fA-F]{3,8})\]/g)) {
+ const prefix = m[1]
+ // `dark:bg-[#...]` ist in Ordnung; `bg-[#7c3aed]` ist der Cloud-Akzent,
+ // der bewusst in beiden Modi dieselbe Farbe traegt.
+ if (prefix.includes('dark:')) continue
+ if (m[2].toLowerCase() === '#7c3aed') continue
+ offenders.push(m[0])
+ }
+ expect(offenders).toEqual([])
+ })
+
+ it('die Create-Wurzel setzt ihre Textfarbe nicht mehr fuer beide Modi', () => {
+ const src = read('../create/experimental/CreateExperimental.tsx')
+ expect(src).toContain('text-gray-900 dark:text-gray-200')
+ })
+})
diff --git a/src/components/auth/AccountPanel.tsx b/src/components/auth/AccountPanel.tsx
index ed1328ad..a59586bd 100644
--- a/src/components/auth/AccountPanel.tsx
+++ b/src/components/auth/AccountPanel.tsx
@@ -198,18 +198,20 @@ export function AccountPanel() {
<button
type="submit"
disabled={busy || !email || !password}
- className="flex items-center gap-1.5 px-3 py-1.5 rounded text-[0.7rem] font-medium bg-gray-900 text-white dark:bg-white dark:text-gray-900 disabled:opacity-40 hover:opacity-90 transition-opacity"
+ className="lu-primary flex items-center gap-1.5 px-3 py-1.5 rounded text-[0.7rem] disabled:opacity-40 transition-colors"
>
{busy ? <Loader2 size={11} className="animate-spin" /> : (
- /* Monogram, not the stock cloud glyph. The button is dark on light
- and light on dark, so the invert flips the other way here. */
+ /* Monogram, not the stock cloud glyph. Der Knopf traegt jetzt in
+ BEIDEN Modi die Akzentflaeche mit dunklem Text (.lu-primary),
+ also muss das Monogramm auch in beiden Modi dunkel sein —
+ vorher kippte es mit dem Modus, weil der Knopf das tat. */
<img
src="/LU-monogram-bw.png"
alt=""
width={12}
height={12}
draggable={false}
- className="shrink-0 select-none invert-0 dark:invert"
+ className="shrink-0 select-none invert"
/>
)}
{mode === 'signin' ? 'Sign in' : 'Create account'}
diff --git a/src/components/chat/ChatInput.tsx b/src/components/chat/ChatInput.tsx
index 72b62e29..1d3c7a48 100644
--- a/src/components/chat/ChatInput.tsx
+++ b/src/components/chat/ChatInput.tsx
@@ -521,7 +521,7 @@ export function ChatInput({ onSend, onStop, isGenerating, pendingApproval, onApp
<motion.button
onClick={handleSend}
disabled={(!input.trim() && images.length === 0) || isTranscribing}
- className="w-full h-full flex items-center justify-center rounded-md bg-white/8 text-gray-300 hover:bg-white/12 disabled:opacity-20 disabled:cursor-not-allowed transition-all"
+ className="lu-primary w-full h-full flex items-center justify-center rounded-md disabled:opacity-40 transition-colors"
whileTap={{ scale: 0.9 }}
aria-label="Send message"
>
diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx
index 0834ce00..42561ca9 100644
--- a/src/components/chat/ChatView.tsx
+++ b/src/components/chat/ChatView.tsx
@@ -449,7 +449,7 @@ export function ChatView() {
{/* RAG Panel */}
<AnimatePresence>
{ragPanelOpen && activeConversationId && (
- <ErrorBoundary fallbackClassName="w-[280px] shrink-0 h-full border-l border-white/5 bg-[#363636] flex flex-col items-center justify-center p-6 gap-3">
+ <ErrorBoundary fallbackClassName="w-[280px] shrink-0 h-full border-l border-gray-200 dark:border-white/5 bg-white dark:bg-lu-overlay flex flex-col items-center justify-center p-6 gap-3">
<RAGPanel conversationId={activeConversationId} onClose={() => setRagPanelOpen(false)} />
</ErrorBoundary>
)}
@@ -464,7 +464,7 @@ export function ChatView() {
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 12 }}
transition={{ duration: 0.18 }}
- className="fixed bottom-6 left-1/2 -translate-x-1/2 z-[120] px-4 py-2 rounded-lg bg-[#262626] border border-green-500/30 text-green-400 text-[0.7rem] shadow-xl max-w-[min(90vw,520px)] truncate"
+ className="fixed bottom-6 left-1/2 -translate-x-1/2 z-[120] px-4 py-2 rounded-lg bg-white dark:bg-lu-panel border border-green-600/40 dark:border-green-500/30 text-green-700 dark:text-green-400 text-[0.7rem] shadow-xl max-w-[min(90vw,520px)] truncate"
>
{exportToast}
</motion.div>
diff --git a/src/components/create/experimental/CreateExperimental.tsx b/src/components/create/experimental/CreateExperimental.tsx
index fe6fba3c..ceea365d 100644
--- a/src/components/create/experimental/CreateExperimental.tsx
+++ b/src/components/create/experimental/CreateExperimental.tsx
@@ -193,7 +193,7 @@ function CreateExperimentalInner() {
}, [intent])
return (
- <div className="relative h-full w-full flex flex-col bg-white dark:bg-[#141414] text-gray-200 overflow-hidden">
+ <div className="relative h-full w-full flex flex-col bg-white dark:bg-[#141414] text-gray-900 dark:text-gray-200 overflow-hidden">
<IntentBar />
<AnimatePresence>
diff --git a/src/components/create/ui/Button.tsx b/src/components/create/ui/Button.tsx
index 1ca558b2..5ebfc879 100644
--- a/src/components/create/ui/Button.tsx
+++ b/src/components/create/ui/Button.tsx
@@ -35,11 +35,13 @@ const SIZE_PX: Record<Size, string> = {
}
const ICON_SIZE: Record<Size, number> = { sm: 13, md: 14, lg: 16 }
-// Matches the live app exactly: the primary action (Generate) is a neutral
-// white-translucent button — the app uses NO loud accent fill. Emphasis comes
-// from the icon + size, not colour.
+// Die Primaeraktion traegt das gemeinsame Rezept `.lu-primary` (index.css) —
+// Flaeche, Textfarbe, Hover, Fokusring und disabled liegen dort, an genau
+// einer Stelle, geteilt mit AccountPanel (Sign in) und ChatInput (Send).
+// Vorher stand hier ein eigenes Graustufen-Rezept, das die wichtigste Aktion
+// des Bildschirms wie eine Nebenaktion aussehen liess.
const VARIANT: Record<Variant, string> = {
- primary: 'bg-gray-900 text-white dark:bg-white/10 dark:text-white hover:bg-gray-700 dark:hover:bg-white/15 font-medium',
+ primary: 'lu-primary',
secondary: 'bg-white/10 text-gray-100 hover:bg-white/15',
ghost: 'bg-transparent text-gray-400 hover:text-white hover:bg-white/8',
danger: 'bg-red-500/15 text-red-500 dark:text-red-400 hover:bg-red-500/25',
diff --git a/src/index.css b/src/index.css
index f4a933e3..1d8d0824 100644
--- a/src/index.css
+++ b/src/index.css
@@ -43,6 +43,18 @@
--color-lu-accent-soft: rgba(160, 148, 248, 0.14);
--color-lu-accent-ring: rgba(160, 148, 248, 0.55);
+ /* ── Primaeraktion: Text auf der Akzentflaeche ──
+ Gemessen (WCAG 2.1 relative Luminanz):
+ #a094f8 (Ruhe) gegen #111827 → 6.83:1 (AA Fliesstext, AAA gross)
+ #b1a6ff (Hover) gegen #111827 → 8.25:1
+ #a094f8 gegen #ffffff → 2.60:1 ← weisser Text faellt durch,
+ deshalb traegt die Akzentflaeche DUNKLEN Text, in beiden Modi gleich.
+ --color-lu-accent-edge ist die Kante fuer den Hellmodus: die Flaeche
+ selbst steht nur 2.60:1 gegen Weiss, die Kante schafft 3.37:1 und
+ erfuellt damit 1.4.11 (Nicht-Text-Kontrast) fuer die Buttongrenze. */
+ --color-lu-on-accent: #111827;
+ --color-lu-accent-edge: #8b7cf0;
+
/* ── Motion — eine benannte Leiter statt verstreuter Zahlen ──
Dauer und Kurve standen bisher als Literale in den Komponenten. Erhoben
wurde, was tatsächlich benutzt wird (framer-motion + Tailwind, Stand 2.6.7):
@@ -456,6 +468,49 @@ input[type="range"]::-webkit-slider-thumb {
outline-offset: 1px;
}
+/* ──────────────────────────────────────────────────────────────────
+ .lu-primary — DAS Primaer-Rezept. Genau einmal definiert, benutzt von
+ allen drei Primaeraktionen der App:
+ • create/ui/Button.tsx (Variante `primary`, u.a. Generate)
+ • auth/AccountPanel.tsx (Sign in / Create account)
+ • chat/ChatInput.tsx (Send)
+ Vorher waren das drei getrennte Graustufen-Rezepte (`bg-gray-900`,
+ `dark:bg-white/10`, `bg-white/8`) — die wichtigste Aktion des Bildschirms
+ sah aus wie eine beliebige Nebenaktion.
+
+ Farbe kommt ausschliesslich aus dem @theme-Block, kein Literal hier.
+ Der Zustand `disabled` entsaettigt die Flaeche zusaetzlich zum Dimmen,
+ damit er nicht als die aktive Variante durchgeht; die Call-Sites bringen
+ ihr eigenes `disabled:opacity-*` mit, das sich damit addiert.
+ Fokus: 2px Ring mit 2px Abstand, damit er auf dem HINTERGRUND liegt und
+ nicht auf der Akzentflaeche — dunkel im Hellmodus, weiss im Dunkelmodus.
+ Er ueberschreibt den globalen 1px-Ring (Spezifitaet 0,2,0 vs 0,1,1).
+ ───────────────────────────────────────────────────────────────── */
+.lu-primary {
+ background-color: var(--color-lu-accent);
+ color: var(--color-lu-on-accent);
+ border: 1px solid var(--color-lu-accent);
+ font-weight: 500;
+}
+.light .lu-primary { border-color: var(--color-lu-accent-edge); }
+
+.lu-primary:hover:not(:disabled) {
+ background-color: var(--color-lu-accent-hover);
+ border-color: var(--color-lu-accent-hover);
+}
+
+.lu-primary:focus-visible {
+ outline: 2px solid var(--color-lu-on-accent);
+ outline-offset: 2px;
+}
+.dark .lu-primary:focus-visible { outline-color: white; }
+
+.lu-primary:disabled {
+ filter: grayscale(1);
+ opacity: 0.45;
+ cursor: not-allowed;
+}
+
/* Checkerboard backing so transparent (background-removed) PNGs don't read
as solid black in the Stage / gallery. */
.lu-checker {