Files
dashboard-desaplus-noc/src/components/ui/badge.tsx
2026-02-11 12:38:28 +08:00

54 lines
1.0 KiB
TypeScript

import {
Badge as MantineBadge,
type BadgeProps as MantineBadgeProps,
} from "@mantine/core";
import { cn } from "./utils";
interface BadgeProps extends MantineBadgeProps {
variant?: "default" | "secondary" | "destructive" | "success";
}
const Badge = ({
className,
variant = "default",
children,
...props
}: BadgeProps) => {
let mantineVariant: MantineBadgeProps["variant"];
let mantineColor: MantineBadgeProps["color"];
switch (variant) {
case "secondary":
mantineVariant = "light";
mantineColor = "gray";
break;
case "destructive":
mantineVariant = "filled";
mantineColor = "red";
break;
case "success":
mantineVariant = "filled";
mantineColor = "green";
break;
default:
mantineVariant = "filled";
mantineColor = "blue"; // Placeholder, should align with primary color
break;
}
return (
<MantineBadge
variant={mantineVariant}
color={mantineColor}
className={cn(className)}
{...props}
>
{children}
</MantineBadge>
);
};
export { Badge };