Files
gruperly/apps/web/src/components/ui/badge.tsx
Jose Selesan 69275c37b4 chore: update comments and documentation for clarity and consistency across various files
- Translated comments from Spanish to English in vite.config.ts, docker-compose.yml, attendance-risk.ts, analytics.ts, attendance.ts, attendees.ts, enums.ts, groups.ts, and onboarding.ts.
- Improved descriptions for better understanding of code functionality and purpose.
- Ensured uniformity in terminology and phrasing throughout the codebase.
2026-10-01 16:06:54 -03:00

39 lines
1.2 KiB
TypeScript

import { forwardRef, type HTMLAttributes } from 'react'
import { cn } from '../../lib/utils'
export type BadgeVariant = 'success' | 'warning' | 'danger' | 'neutral' | 'info'
export type BadgeProps = HTMLAttributes<HTMLSpanElement> & {
variant?: BadgeVariant
}
const variants: Record<BadgeVariant, string> = {
success: 'bg-success-soft text-success',
warning: 'bg-warning-soft text-warning',
danger: 'bg-danger-soft text-danger',
neutral: 'bg-primary-soft text-primary',
/* Informational state, not an alert: waitlist, free spots. Uses the legible
accent ink (`accent-fg` is the light blue in the dark theme, 7.1:1 on the
card) and not the plain `accent`, which in dark scores 2.2:1 and misses the
3:1 minimum for non-text content. */
info: 'bg-accent-soft text-accent-fg',
}
export const Badge = forwardRef<HTMLSpanElement, BadgeProps>(
({ className, variant = 'neutral', ...props }, ref) => {
return (
<span
ref={ref}
className={cn(
'inline-flex shrink-0 items-center whitespace-nowrap rounded-full px-2.5 py-0.5 text-xs font-medium',
variants[variant],
className,
)}
{...props}
/>
)
},
)
Badge.displayName = 'Badge'