import { cn } from "@/lib/ui/variants";

export type StatusTone =
  | "neutral"
  | "accent"
  | "success"
  | "warning"
  | "danger"
  | "info";

const dotTones: Record<StatusTone, string> = {
  neutral: "bg-ink-soft",
  accent: "bg-cinnabar",
  success: "bg-pass",
  warning: "bg-overdue",
  danger: "bg-conflict",
  info: "bg-info",
};

interface StatusDotProps {
  tone?: StatusTone;
  /** 提供 label 时对读屏可见（不单靠颜色传达状态）。 */
  label?: string;
  className?: string;
}

// 状态点：语义色圆点，配合文案使用；有 label 时暴露给读屏。
export function StatusDot({ tone = "neutral", label, className }: StatusDotProps) {
  return (
    <span
      className={cn(
        "inline-block h-2 w-2 shrink-0 rounded-full",
        dotTones[tone],
        className,
      )}
      role={label ? "img" : undefined}
      aria-label={label}
      aria-hidden={label ? undefined : true}
    />
  );
}
