import { X, Plus } from 'lucide-react'; import { motion } from 'framer-motion'; import type { ButtonHTMLAttributes } from 'react'; import type { LucideIcon } from 'lucide-react'; import { cn } from '~/utils'; interface BadgeProps extends ButtonHTMLAttributes { icon?: LucideIcon; label: string; isActive?: boolean; isEditing?: boolean; isDragging?: boolean; isAvailable: boolean; onBadgeAction?: () => void; onToggle?: () => void; } export default function Badge({ icon: Icon, label, isActive = false, isEditing = false, isDragging = false, isAvailable = true, onBadgeAction, onToggle, className, ...props }: BadgeProps) { const isMoveable = isEditing && isAvailable; const handleClick: React.MouseEventHandler = (e) => { if (!isEditing && onToggle) { if (typeof window !== 'undefined' && window.innerWidth >= 768) { e.preventDefault(); } e.stopPropagation(); onToggle(); } }; return ( {Icon && } {label} {isEditing && !isDragging && ( e.stopPropagation()} onClick={(e) => { e.stopPropagation(); onBadgeAction?.(); }} > {isAvailable ? : } )} ); }