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>
100 lines
4 KiB
TypeScript
100 lines
4 KiB
TypeScript
import { useState } from "react";
|
|
import type { BudgetIncident } from "@paperclipai/shared";
|
|
import { AlertOctagon, ArrowUpRight, PauseCircle } from "lucide-react";
|
|
import { formatCents } from "../lib/utils";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
|
import { Input } from "@/components/ui/input";
|
|
|
|
function centsInputValue(value: number) {
|
|
return (value / 100).toFixed(2);
|
|
}
|
|
|
|
function parseDollarInput(value: string) {
|
|
const parsed = Number(value);
|
|
if (!Number.isFinite(parsed) || parsed < 0) return null;
|
|
return Math.round(parsed * 100);
|
|
}
|
|
|
|
export function BudgetIncidentCard({
|
|
incident,
|
|
onRaiseAndResume,
|
|
onKeepPaused,
|
|
isMutating,
|
|
}: {
|
|
incident: BudgetIncident;
|
|
onRaiseAndResume: (amountCents: number) => void;
|
|
onKeepPaused: () => void;
|
|
isMutating?: boolean;
|
|
}) {
|
|
const [draftAmount, setDraftAmount] = useState(
|
|
centsInputValue(Math.max(incident.amountObserved + 1000, incident.amountLimit)),
|
|
);
|
|
const parsed = parseDollarInput(draftAmount);
|
|
|
|
return (
|
|
<Card className="overflow-hidden border-destructive/20 bg-[linear-gradient(180deg,rgba(255,70,70,0.10),rgba(255,255,255,0.02))]">
|
|
<CardHeader className="px-5 pt-5 pb-3">
|
|
<div className="flex items-start justify-between gap-3">
|
|
<div>
|
|
<div className="text-[11px] uppercase tracking-[0.22em] text-destructive">
|
|
{incident.scopeType} hard stop
|
|
</div>
|
|
<CardTitle className="mt-1 text-base text-destructive">{incident.scopeName}</CardTitle>
|
|
<CardDescription className="mt-1 text-destructive">
|
|
Spending reached {formatCents(incident.amountObserved)} against a limit of {formatCents(incident.amountLimit)}.
|
|
</CardDescription>
|
|
</div>
|
|
<div className="rounded-full border border-destructive/30 bg-destructive/10 p-2 text-destructive">
|
|
<AlertOctagon className="h-4 w-4" />
|
|
</div>
|
|
</div>
|
|
</CardHeader>
|
|
<CardContent className="space-y-4 px-5 pb-5 pt-0">
|
|
<div className="flex items-start gap-2 rounded-xl border border-destructive/20 bg-destructive/10 px-3 py-2 text-sm text-destructive">
|
|
<PauseCircle className="mt-0.5 h-4 w-4 shrink-0" />
|
|
<div>
|
|
{incident.scopeType === "project"
|
|
? "Project execution is paused. New work in this project will not start until you resolve the budget incident."
|
|
: "This scope is paused. New heartbeats will not start until you resolve the budget incident."}
|
|
</div>
|
|
</div>
|
|
|
|
<div className="rounded-xl border border-border/60 bg-background/60 p-3">
|
|
<label className="text-[11px] uppercase tracking-[0.18em] text-muted-foreground">
|
|
New budget (USD)
|
|
</label>
|
|
<div className="mt-2 flex flex-col gap-3 sm:flex-row">
|
|
<Input
|
|
value={draftAmount}
|
|
onChange={(event) => setDraftAmount(event.target.value)}
|
|
inputMode="decimal"
|
|
placeholder="0.00"
|
|
/>
|
|
<Button
|
|
className="gap-2"
|
|
disabled={isMutating || parsed === null || parsed <= incident.amountObserved}
|
|
onClick={() => {
|
|
if (typeof parsed === "number") onRaiseAndResume(parsed);
|
|
}}
|
|
>
|
|
<ArrowUpRight className="h-4 w-4" />
|
|
{isMutating ? "Applying..." : "Raise budget & resume"}
|
|
</Button>
|
|
</div>
|
|
{parsed !== null && parsed <= incident.amountObserved ? (
|
|
<p className="mt-2 text-xs text-destructive">
|
|
The new budget must exceed current observed spend.
|
|
</p>
|
|
) : null}
|
|
</div>
|
|
|
|
<div className="flex justify-end">
|
|
<Button variant="ghost" className="text-muted-foreground" disabled={isMutating} onClick={onKeepPaused}>
|
|
Keep paused
|
|
</Button>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
);
|
|
}
|