'use client'; import { useToast } from '@/hooks/use-toast'; import { Toast, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, } from '@/components/ui/toast'; import { cn } from '@/lib/utils'; import { CheckCircle, AlertCircle, AlertTriangle, Info, X, } from 'lucide-react'; import type { ReactNode } from 'react'; // Toast type definitions type ToastType = 'success' | 'warning' | 'error' | 'info'; interface ToastIconProps { type: ToastType; } // Icon mapping for toast types function ToastIcon({ type }: ToastIconProps) { const iconClass = 'h-4 w-4 shrink-0'; switch (type) { case 'success': return ; case 'warning': return ; case 'error': return ; case 'info': return ; } } // Color mapping for toast types using design system tokens const TOAST_TYPE_STYLES: Record = { success: 'border-[var(--color-success)]/50 bg-[var(--color-success)]/10', warning: 'border-[var(--color-warning)]/50 bg-[var(--color-warning)]/10', error: 'border-[var(--color-danger)]/50 bg-[var(--color-danger)]/10', info: 'border-[var(--color-info)]/50 bg-[var(--color-info)]/10', }; const TOAST_TYPE_TEXT: Record = { success: 'text-[var(--color-success)]', warning: 'text-[var(--color-warning)]', error: 'text-[var(--color-danger)]', info: 'text-[var(--color-info)]', }; export function GameToaster() { const { toasts } = useToast(); return ( {toasts.map((toast) => { // Determine toast type from className or default to info const toastType: ToastType = toast.variant === 'destructive' ? 'error' : (toast as { toastType?: ToastType }).toastType || 'info'; return ( {toast.title && ( {toast.title} )} {toast.description && ( {toast.description} )} ); })} {/* Viewport positioning: - Desktop: bottom-right - Mobile: bottom-center, full-width */} ); } // Custom hook to show typed toasts export function useGameToast() { const { toast } = useToast(); return (type: ToastType, title: ReactNode, description?: ReactNode) => { const toastTypeClass = `toast-type-${type}`; return toast({ title, description, className: toastTypeClass, // Store the type for styling ...{ toastType: type }, } as { title: ReactNode; description?: ReactNode; className?: string; toastType?: ToastType; }); }; } export { type ToastType };