Files
flvx/vite-frontend/src/shadcn-bridge/heroui/chip.tsx
T
sagit 66de566a00 fix(frontend): stabilize multiselect behavior and UI spacing (#154)
* fix(frontend): left-align announcement logo in homepage banner

* fix(frontend): keep multiselect panels floating and preserve summaries

* fix(frontend): rebalance config card header spacing

* fix(frontend): normalize formatting and fix multiselect modal behavior

* fix(frontend): restore config divider spacing on desktop
2026-02-19 20:50:12 +08:00

63 lines
1.3 KiB
TypeScript

import * as React from "react";
import { Badge } from "@/components/ui/badge";
import { cn } from "@/lib/utils";
type ChipColor =
| "default"
| "primary"
| "secondary"
| "success"
| "warning"
| "danger";
type ChipVariant = "solid" | "flat" | "light" | "bordered";
type ChipSize = "sm" | "md" | "lg";
export interface ChipProps extends React.ComponentProps<"span"> {
color?: ChipColor;
size?: ChipSize;
variant?: ChipVariant;
}
function colorVariant(color: ChipColor) {
if (color === "danger") {
return "destructive" as const;
}
if (color === "success") {
return "success" as const;
}
if (color === "warning") {
return "warning" as const;
}
if (color === "secondary") {
return "secondary" as const;
}
return "default" as const;
}
export function Chip({
children,
className,
color = "default",
size = "md",
variant = "solid",
...props
}: ChipProps) {
return (
<Badge
className={cn(
variant === "flat" || variant === "light" ? "bg-opacity-15" : "",
variant === "bordered" ? "border-current bg-transparent" : "",
size === "sm" ? "px-2 py-0 text-[10px]" : "",
size === "lg" ? "px-3 py-1 text-sm" : "",
className,
)}
variant={colorVariant(color)}
{...props}
>
{children}
</Badge>
);
}