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>
This commit is contained in:
@@ -1,45 +1,47 @@
|
||||
import * as React from "react"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { cn } from "../core/cn"
|
||||
import * as React from 'react'
|
||||
import { Badge as MantineBadge } from '@mantine/core'
|
||||
|
||||
const badgeVariants = cva(
|
||||
"group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 [&>svg]:pointer-events-none [&>svg]:size-3!",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
||||
secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
|
||||
destructive: "bg-destructive/10 text-destructive [a]:hover:bg-destructive/20",
|
||||
outline: "border-border text-foreground [a]:hover:bg-muted",
|
||||
ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
success: "bg-green-500/10 text-green-600 dark:bg-green-500/20 dark:text-green-400",
|
||||
warning: "bg-yellow-500/10 text-yellow-600 dark:bg-yellow-500/20 dark:text-yellow-400",
|
||||
error: "bg-red-500/10 text-red-600 dark:bg-red-500/20 dark:text-red-400",
|
||||
info: "bg-blue-500/10 text-blue-600 dark:bg-blue-500/20 dark:text-blue-400",
|
||||
},
|
||||
size: {
|
||||
default: "h-5 px-2 text-xs",
|
||||
sm: "h-4 px-1.5 text-[10px]",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
type BadgeVariant = 'default' | 'secondary' | 'destructive' | 'outline' | 'ghost' | 'link' | 'success' | 'warning' | 'error' | 'info'
|
||||
type BadgeSize = 'default' | 'sm'
|
||||
|
||||
interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement>, VariantProps<typeof badgeVariants> {}
|
||||
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]
|
||||
|
||||
function Badge({ className, variant = "default", size = "default", ...props }: BadgeProps) {
|
||||
return (
|
||||
<span
|
||||
<MantineBadge
|
||||
data-slot="badge"
|
||||
className={cn(badgeVariants({ variant, size }), className)}
|
||||
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 }
|
||||
|
||||
Reference in New Issue
Block a user