|
| 1 | +import { cva, VariantProps } from "class-variance-authority"; |
| 2 | +import React, { HTMLAttributes } from "react"; |
| 3 | +import { cn } from "../../utilities"; |
| 4 | + |
| 5 | +export const badgeVariants = cva("inline-flex items-center", { |
| 6 | + variants: { |
| 7 | + rounded: { |
| 8 | + true: "rounded-rounded", |
| 9 | + false: "rounded-sm" |
| 10 | + }, |
| 11 | + size: { |
| 12 | + xs: "text-text-xs px-0.5", |
| 13 | + sm: "text-text-xs py-0.5 px-2 h-5", |
| 14 | + md: "text-text-sm py-0.5 px-2 h-6" |
| 15 | + }, |
| 16 | + color: { |
| 17 | + green: "bg-success-100 text-success-800", |
| 18 | + yellow: "bg-warning-200 text-warning-900", |
| 19 | + "light-purple": "bg-primary-25 text-primary-500", |
| 20 | + purple: "bg-primary-50 text-primary-500", |
| 21 | + blue: "bg-blue-50 text-blue-600", |
| 22 | + "light-grey": "bg-neutral-100 text-theme-text-secondary", |
| 23 | + grey: "bg-neutral-200 text-theme-text-primary", |
| 24 | + red: "bg-error-100 text-error-700", |
| 25 | + orange: "bg-orange-100 text-orange-700", |
| 26 | + lime: "bg-lime-100 text-lime-800", |
| 27 | + teal: "bg-teal-100 text-teal-700", |
| 28 | + turquoise: "bg-turquoise-100 text-turquoise-700", |
| 29 | + magenta: "bg-magenta-100 text-magenta-700" |
| 30 | + } |
| 31 | + }, |
| 32 | + defaultVariants: { |
| 33 | + color: "purple", |
| 34 | + rounded: true, |
| 35 | + size: "md" |
| 36 | + } |
| 37 | +}); |
| 38 | + |
| 39 | +interface ButtonVariants |
| 40 | + extends Omit<HTMLAttributes<HTMLDivElement>, "color">, |
| 41 | + VariantProps<typeof badgeVariants> {} |
| 42 | + |
| 43 | +export function Badge({ children, className, color, rounded, size, ...rest }: ButtonVariants) { |
| 44 | + return ( |
| 45 | + <div {...rest} className={cn(badgeVariants({ color, rounded, size }), className)}> |
| 46 | + {children} |
| 47 | + </div> |
| 48 | + ); |
| 49 | +} |
0 commit comments