- pnpm workspace: apps/{web,server}, packages/{contracts,db,domain,adapters,tasks,agent,testkit}
- server: Hono + zod-openapi, API Key auth with scopes, redacting pino logger, SSE event bus with replay, worker heartbeat
- db: Kysely + pg, file migrator, 0001_init (settings/api_key/audit_event/outbox_event)
- web: React Router 7 SPA console shell with 12 workspace placeholders, uhd_web tokens/ui/guard scripts
- docs: ADR-001 (Node over Deno), dev runbook, design system rules
Co-Authored-By: Claude Fable 5.1 <[email protected]>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import type { ReactNode } from "react";
|
|
import { cn } from "~/lib/utils";
|
|
|
|
export type StatusTone = "success" | "warning" | "destructive" | "neutral";
|
|
|
|
// 状态色只表示状态,不做装饰(docs/design/interface-materials.md)
|
|
const TONE: Record<StatusTone, { box: string; dot: string }> = {
|
|
success: { box: "border-success/30 bg-success/10 text-success", dot: "bg-success" },
|
|
warning: { box: "border-warning/30 bg-warning/10 text-warning", dot: "bg-warning" },
|
|
destructive: { box: "border-destructive/30 bg-destructive/10 text-destructive", dot: "bg-destructive" },
|
|
neutral: { box: "border-border bg-foreground/[0.04] text-muted-foreground", dot: "bg-muted-foreground" },
|
|
};
|
|
|
|
/** 状态徽章:文字必填,不只靠颜色传达状态 */
|
|
export function StatusBadge({
|
|
tone = "neutral",
|
|
children,
|
|
className,
|
|
}: {
|
|
tone?: StatusTone;
|
|
children: ReactNode;
|
|
className?: string;
|
|
}) {
|
|
const t = TONE[tone];
|
|
return (
|
|
<span
|
|
className={cn(
|
|
"inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 text-meta font-medium whitespace-nowrap",
|
|
t.box,
|
|
className,
|
|
)}
|
|
>
|
|
<span aria-hidden className={cn("h-1.5 w-1.5 rounded-full", t.dot)} />
|
|
{children}
|
|
</span>
|
|
);
|
|
}
|