20 lines
825 B
TypeScript
20 lines
825 B
TypeScript
import type { HTMLAttributes } from "react";
|
|
import { cn } from "./cn.js";
|
|
|
|
export type StatusTone = "neutral" | "success" | "warning" | "danger" | "accent";
|
|
|
|
export interface StatusBadgeProps extends HTMLAttributes<HTMLSpanElement> {
|
|
tone?: StatusTone;
|
|
variant?: "badge" | "indicator";
|
|
/** Attention signal on the lamp only; respects reduced-motion preferences. */
|
|
pulse?: boolean;
|
|
}
|
|
|
|
export function StatusBadge({ tone = "neutral", variant = "badge", pulse = false, className, children, ...props }: StatusBadgeProps) {
|
|
return (
|
|
<span className={cn("nodedc-status", className)} data-tone={tone === "neutral" ? undefined : tone} data-variant={variant === "indicator" ? variant : undefined} data-pulse={pulse ? "true" : undefined} {...props}>
|
|
{variant === "indicator" ? null : children}
|
|
</span>
|
|
);
|
|
}
|