Files
fn_registry/frontend/functions/ui/badge.tsx
T
egutierrez 97a3c84625 refactor: migrate frontend from shadcn/Tailwind to Mantine v9
Reescribe todos los componentes UI para usar Mantine v9 en lugar de shadcn/Tailwind.
Elimina cn(), CVA, components.json, theme_provider custom y globals.css con Tailwind.
Añade 25+ componentes nuevos (AppShell, AuthForm, DatePickerInput, Dropzone, etc.)
y MantineProvider como wrapper estándar del sistema de temas.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 23:46:44 +02:00

48 lines
1.4 KiB
TypeScript

import * as React from 'react'
import { Badge as MantineBadge } from '@mantine/core'
type BadgeVariant = 'default' | 'secondary' | 'destructive' | 'outline' | 'ghost' | 'link' | 'success' | 'warning' | 'error' | 'info'
type BadgeSize = 'default' | 'sm'
const variantMap: Record<BadgeVariant, { variant: string; color?: string }> = {
default: { variant: 'filled' },
secondary: { variant: 'light' },
destructive: { variant: 'light', color: 'red' },
outline: { variant: 'outline' },
ghost: { variant: 'subtle' },
link: { variant: 'transparent' },
success: { variant: 'light', color: 'green' },
warning: { variant: 'light', color: 'yellow' },
error: { variant: 'light', color: 'red' },
info: { variant: 'light', color: 'blue' },
}
/** Kept for backwards compatibility */
const badgeVariants = variantMap
interface BadgeProps extends React.HTMLAttributes<HTMLDivElement> {
variant?: BadgeVariant
size?: BadgeSize
}
function Badge({ className, variant = 'default', size = 'default', children, ...props }: BadgeProps) {
const mv = variantMap[variant]
return (
<MantineBadge
data-slot="badge"
variant={mv.variant}
color={mv.color}
size={size === 'sm' ? 'xs' : 'sm'}
radius="xl"
className={className}
{...props}
>
{children}
</MantineBadge>
)
}
export { Badge, badgeVariants }
export type { BadgeProps, BadgeVariant, BadgeSize }