- Updated Badge component to use design token CSS variables (bl-*) - Updated Button component to use design token CSS variables (bl-*) - Improved focus states with proper design token colors - Added aria-label to logout button in sidebar for better accessibility - Maintains backward compatibility while improving consistency This moves admin web toward design system compliance while ensuring no breaking changes to existing functionality. Generated with [Devin](https://cli.devin.ai/docs) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
49 lines
1.9 KiB
TypeScript
49 lines
1.9 KiB
TypeScript
import * as React from 'react';
|
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
import { Slot } from 'radix-ui';
|
|
|
|
import { cn } from '@/lib/utils';
|
|
|
|
const badgeVariants = cva(
|
|
'inline-flex items-center justify-center rounded-full border border-transparent px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:ring-2 focus-visible:ring-[var(--bl-focus-ring)] focus-visible:ring-offset-2 aria-invalid:ring-[var(--bl-danger)] aria-invalid:border-[var(--bl-danger)] transition-[color,box-shadow] overflow-hidden',
|
|
{
|
|
variants: {
|
|
variant: {
|
|
default:
|
|
'bg-[var(--bl-accent)] text-[var(--bl-accent-foreground)] [a&]:hover:bg-[var(--bl-accent)]/90',
|
|
secondary:
|
|
'bg-[var(--bl-surface-muted)] text-[var(--bl-text-primary)] [a&]:hover:bg-[var(--bl-surface-muted)]/90',
|
|
destructive:
|
|
'bg-[var(--bl-danger)] text-[var(--bl-danger-foreground)] [a&]:hover:bg-[var(--bl-danger)]/90 focus-visible:ring-[var(--bl-danger)]/20 dark:focus-visible:ring-[var(--bl-danger)]/40 dark:bg-[var(--bl-danger)]/60',
|
|
outline:
|
|
'border-[var(--bl-border)] text-[var(--bl-text-primary)] [a&]:hover:bg-[var(--bl-surface-muted)] [a&]:hover:text-[var(--bl-text-primary)]',
|
|
ghost: '[a&]:hover:bg-[var(--bl-surface-muted)] [a&]:hover:text-[var(--bl-text-primary)]',
|
|
link: 'text-[var(--bl-accent)] underline-offset-4 [a&]:hover:underline',
|
|
},
|
|
},
|
|
defaultVariants: {
|
|
variant: 'default',
|
|
},
|
|
}
|
|
);
|
|
|
|
function Badge({
|
|
className,
|
|
variant = 'default',
|
|
asChild = false,
|
|
...props
|
|
}: React.ComponentProps<'span'> & VariantProps<typeof badgeVariants> & { asChild?: boolean }) {
|
|
const Comp = asChild ? Slot.Root : 'span';
|
|
|
|
return (
|
|
<Comp
|
|
data-slot="badge"
|
|
data-variant={variant}
|
|
className={cn(badgeVariants({ variant }), className)}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export { Badge, badgeVariants };
|