g1t/apps/web/app/components/ui/badge.tsx
| 1 | import type { ComponentProps } from "react"; |
| 2 | |
| 3 | import { cn } from "../../lib/cn"; |
| 4 | |
| 5 | // shadcn/ui's badge, styled with g1t's tokens: a small outlined label whose |
| 6 | // tone says how much it matters. |
| 7 | |
| 8 | export type BadgeTone = "neutral" | "accent" | "info" | "merged" | "warn" | "danger"; |
| 9 | |
| 10 | const TONES: Record<BadgeTone, string> = { |
| 11 | neutral: "border-line text-muted", |
| 12 | accent: "border-accent/40 bg-accent/10 text-accent", |
| 13 | info: "border-info/40 bg-info/10 text-info", |
| 14 | merged: "border-merged/40 bg-merged/10 text-merged", |
| 15 | warn: "border-warn/40 bg-warn/10 text-warn", |
| 16 | danger: "border-danger/40 bg-danger/10 text-danger", |
| 17 | }; |
| 18 | |
| 19 | export function Badge({ tone = "neutral", className, ...props }: ComponentProps<"span"> & { tone?: BadgeTone }) { |
| 20 | return ( |
| 21 | <span |
| 22 | className={cn( |
| 23 | "inline-flex shrink-0 items-center gap-1 rounded-full border px-2 py-px text-[0.6875rem] font-medium whitespace-nowrap", |
| 24 | TONES[tone], |
| 25 | className, |
| 26 | )} |
| 27 | {...props} |
| 28 | /> |
| 29 | ); |
| 30 | } |