Third phase of the DESIGN.md migration. Removes every raw Tailwind
color palette utility (bg-red-*, text-amber-*, border-blue-*, etc.)
from component source and replaces them with the semantic tokens
introduced in phases 1 and 2.
Scope:
- 84 files touched under ui/src/
- ~420 raw palette utility instances replaced
- 23 hardcoded hex fallbacks replaced with var(--token) refs
- Zero raw palette utilities remain in component source
(verified with rg '(bg|text|border|ring)-(red|blue|green|amber|
yellow|cyan|violet|purple|pink|slate|zinc|neutral|sky|teal|
emerald|indigo|rose|orange|fuchsia)-[0-9]+' ui/src)
Mapping rules applied:
- red-* -> destructive
- amber-/yellow-/orange-* -> warning
- green-/emerald-* -> success
- blue-/cyan-/sky-* -> primary (info/in-progress) or muted-foreground
- slate-/gray-/zinc-/neutral-* -> muted / muted-foreground / border
- violet-/purple-/pink-/indigo-/rose-/teal-* -> collapsed to
primary or muted (most were one-off decorative choices, not
role-bearing). Role-bearing uses go through lib/agent-role-colors
which was rewritten in phase 2.
- Opacity modifiers preserved (/10, /15, /20, etc.)
- dark: variant duplicates removed (theme tokens auto-switch)
Hardcoded hex fallbacks fixed:
- #6366f1 (indigo) -> var(--primary) / var(--volt)
- #64748b (slate) -> var(--muted-foreground) / var(--silver)
- #4f46e5 (indigo) -> var(--primary)
- #89b4fa (old Catppuccin blue) -> var(--primary) / #faff69
- OrgChart status dots (#22d3ee/#4ade80/#facc15/#f87171/#a3a3a3)
-> var(--primary) / var(--success) / var(--warning) /
var(--destructive) / var(--muted-foreground) per status
- VoiceWaveform fallback #89b4fa -> #faff69 (volt)
Legitimate hex values left untouched (12 total):
- lib/color-contrast.ts WCAG reference constants
- lib/worktree-branding.ts contrast fallback references
- lib/mention-chips.ts runtime-generated SVG fills
- context/ThemeContext.tsx theme metadata brand hexes
- components/ThemeSeedInput.tsx user-facing hex picker
Ambiguous decisions (flagged for visual QA):
- AgentDetail.tsx invocation-source badges (timer/assignment/
on_demand) collapsed to primary/muted — visual distinction
is reduced, labels still differ. Consider chart-role slots
if differentiation matters.
- AgentDetail.tsx mixed-opacity amber banners: bg-warning/60
against new warning base reads heavier than original amber-50
base.
- Live-state dots in KanbanBoard/AgentDetail: bg-blue-* ->
bg-primary — will glow volt in dark mode, probably desirable.
Verification:
- npx tsc --noEmit in ui/ — zero errors introduced. Pre-existing
errors in AgentConfigForm, command.tsx, useKeyboardShortcuts,
usePiperTts, useVadRecorder, PersonalAssistant remain, all
unrelated to color work.
- Dev server on :6100 returns 200.
Not changed in this commit:
- ui/src/lib/company-routes.ts — separate routing fix for broken
Assistant/ContentStudio/Convert links, committed next.
- Test files — a few will need assertion updates but are out of
phase 3 scope.
Phase 4 follow-ups (rounded-xl/2xl collapse, soft shadow removal,
gradient removal) noted in .planning/AUDIT-RADIUS-SHADOWS.md.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
99 lines
2.9 KiB
TypeScript
99 lines
2.9 KiB
TypeScript
import { useEffect, useState } from "react";
|
|
import { Link } from "@/lib/router";
|
|
import { X } from "lucide-react";
|
|
import { useToast, type ToastItem, type ToastTone } from "../context/ToastContext";
|
|
import { cn } from "../lib/utils";
|
|
|
|
const toneClasses: Record<ToastTone, string> = {
|
|
info: "border-primary/30 bg-primary/10 text-primary",
|
|
success: "border-success/30 bg-success/10 text-success",
|
|
warn: "border-warning/30 bg-warning/10 text-warning",
|
|
error: "border-destructive/30 bg-destructive/10 text-destructive",
|
|
};
|
|
|
|
const toneDotClasses: Record<ToastTone, string> = {
|
|
info: "bg-primary",
|
|
success: "bg-success",
|
|
warn: "bg-warning",
|
|
error: "bg-destructive",
|
|
};
|
|
|
|
function AnimatedToast({
|
|
toast,
|
|
onDismiss,
|
|
}: {
|
|
toast: ToastItem;
|
|
onDismiss: (id: string) => void;
|
|
}) {
|
|
const [visible, setVisible] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const frame = requestAnimationFrame(() => setVisible(true));
|
|
return () => cancelAnimationFrame(frame);
|
|
}, []);
|
|
|
|
return (
|
|
<li
|
|
className={cn(
|
|
"pointer-events-auto rounded-sm border shadow-lg backdrop-blur-xl transition-[transform,opacity] duration-200 ease-out",
|
|
visible
|
|
? "translate-y-0 opacity-100"
|
|
: "translate-y-3 opacity-0",
|
|
toneClasses[toast.tone],
|
|
)}
|
|
>
|
|
<div className="flex items-start gap-3 px-3 py-2.5">
|
|
<span className={cn("mt-1 h-2 w-2 shrink-0 rounded-full", toneDotClasses[toast.tone])} />
|
|
<div className="min-w-0 flex-1">
|
|
<p className="text-sm font-semibold leading-5">{toast.title}</p>
|
|
{toast.body && (
|
|
<p className="mt-1 text-xs leading-4 opacity-70">
|
|
{toast.body}
|
|
</p>
|
|
)}
|
|
{toast.action && (
|
|
<Link
|
|
to={toast.action.href}
|
|
onClick={() => onDismiss(toast.id)}
|
|
className="mt-2 inline-flex text-xs font-medium underline underline-offset-4 hover:opacity-90"
|
|
>
|
|
{toast.action.label}
|
|
</Link>
|
|
)}
|
|
</div>
|
|
<button
|
|
type="button"
|
|
aria-label="Dismiss notification"
|
|
onClick={() => onDismiss(toast.id)}
|
|
className="mt-0.5 shrink-0 rounded p-1 opacity-50 hover:bg-black/10 hover:opacity-100 dark:hover:bg-white/10"
|
|
>
|
|
<X className="h-3.5 w-3.5" />
|
|
</button>
|
|
</div>
|
|
</li>
|
|
);
|
|
}
|
|
|
|
export function ToastViewport() {
|
|
const { toasts, dismissToast } = useToast();
|
|
|
|
if (toasts.length === 0) return null;
|
|
|
|
return (
|
|
<aside
|
|
aria-live="polite"
|
|
aria-atomic="false"
|
|
className="pointer-events-none fixed bottom-3 left-3 z-[120] w-full max-w-sm px-1"
|
|
>
|
|
<ol className="flex w-full flex-col-reverse gap-2">
|
|
{toasts.map((toast) => (
|
|
<AnimatedToast
|
|
key={toast.id}
|
|
toast={toast}
|
|
onDismiss={dismissToast}
|
|
/>
|
|
))}
|
|
</ol>
|
|
</aside>
|
|
);
|
|
}
|