Spaces:
Build error
Build error
Download components/AlertCard.jsx from ActuallyCookie/anycoder-6a1e4b3a: direct link, hf CLI and curl.
- Browser
- Download file 6.48 kB
-
https://huggingface.co/spaces/ActuallyCookie/anycoder-6a1e4b3a/resolve/main/components/AlertCard.jsx
- Command line
-
hf download hf://spaces/ActuallyCookie/anycoder-6a1e4b3a/components/AlertCard.jsx
-
curl -L -o AlertCard.jsx https://huggingface.co/spaces/ActuallyCookie/anycoder-6a1e4b3a/resolve/main/components/AlertCard.jsx
6.48 kB
| import { CheckCircle2, AlertTriangle, Info, XCircle, X, Bell } from 'lucide-react'; | |
| import { motion } from 'framer-motion'; | |
| const categoryConfig = { | |
| success: { | |
| icon: CheckCircle2, | |
| bg: 'bg-emerald-950/60', | |
| border: 'border-emerald-400/15', | |
| iconBg: 'bg-emerald-400/12', | |
| iconColor: 'text-emerald-400', | |
| title: 'text-emerald-300', | |
| glow: 'shadow-emerald-500/10', | |
| progress: 'bg-emerald-400/40', | |
| }, | |
| error: { | |
| icon: XCircle, | |
| bg: 'bg-red-950/60', | |
| border: 'border-red-400/15', | |
| iconBg: 'bg-red-400/12', | |
| iconColor: 'text-red-400', | |
| title: 'text-red-300', | |
| glow: 'shadow-red-500/10', | |
| progress: 'bg-red-400/40', | |
| }, | |
| warning: { | |
| icon: AlertTriangle, | |
| bg: 'bg-amber-950/60', | |
| border: 'border-amber-400/15', | |
| iconBg: 'bg-amber-400/12', | |
| iconColor: 'text-amber-400', | |
| title: 'text-amber-300', | |
| glow: 'shadow-amber-500/10', | |
| progress: 'bg-amber-400/40', | |
| }, | |
| info: { | |
| icon: Info, | |
| bg: 'bg-blue-950/60', | |
| border: 'border-blue-400/15', | |
| iconBg: 'bg-blue-400/12', | |
| iconColor: 'text-blue-400', | |
| title: 'text-blue-300', | |
| glow: 'shadow-blue-500/10', | |
| progress: 'bg-blue-400/40', | |
| }, | |
| neutral: { | |
| icon: Bell, | |
| bg: 'bg-zinc-900/80', | |
| border: 'border-zinc-400/15', | |
| iconBg: 'bg-zinc-400/12', | |
| iconColor: 'text-zinc-400', | |
| title: 'text-zinc-300', | |
| glow: 'shadow-zinc-500/10', | |
| progress: 'bg-zinc-400/40', | |
| }, | |
| }; | |
| const positionStyles = { | |
| 'top-left': 'items-start justify-start', | |
| 'top-center': 'items-start justify-center', | |
| 'top-right': 'items-start justify-end', | |
| 'bottom-left': 'items-end justify-start', | |
| 'bottom-center': 'items-end justify-center', | |
| 'bottom-right': 'items-end justify-end', | |
| 'center': 'items-center justify-center', | |
| }; | |
| export default function AlertCard({ | |
| id, | |
| category, | |
| title, | |
| message, | |
| position, | |
| dismissible, | |
| autoClose, | |
| duration, | |
| onDismiss, | |
| animationVariant, | |
| }) { | |
| const config = categoryConfig[category] || categoryConfig.neutral; | |
| const Icon = config.icon; | |
| const variants = { | |
| slideIn: { | |
| hidden: { x: 100, opacity: 0, scale: 0.9 }, | |
| visible: { x: 0, opacity: 1, scale: 1, transition: { type: 'spring', stiffness: 350, damping: 25 } }, | |
| exit: { x: 100, opacity: 0, scale: 0.9, transition: { duration: 0.25 } }, | |
| }, | |
| slideInLeft: { | |
| hidden: { x: -100, opacity: 0, scale: 0.9 }, | |
| visible: { x: 0, opacity: 1, scale: 1, transition: { type: 'spring', stiffness: 350, damping: 25 } }, | |
| exit: { x: -100, opacity: 0, scale: 0.9, transition: { duration: 0.25 } }, | |
| }, | |
| slideUp: { | |
| hidden: { y: 60, opacity: 0 }, | |
| visible: { y: 0, opacity: 1, transition: { type: 'spring', stiffness: 350, damping: 25 } }, | |
| exit: { y: 60, opacity: 0, transition: { duration: 0.25 } }, | |
| }, | |
| slideDown: { | |
| hidden: { y: -60, opacity: 0 }, | |
| visible: { y: 0, opacity: 1, transition: { type: 'spring', stiffness: 350, damping: 25 } }, | |
| exit: { y: -60, opacity: 0, transition: { duration: 0.25 } }, | |
| }, | |
| fade: { | |
| hidden: { opacity: 0 }, | |
| visible: { opacity: 1, transition: { duration: 0.35 } }, | |
| exit: { opacity: 0, transition: { duration: 0.2 } }, | |
| }, | |
| scale: { | |
| hidden: { scale: 0.7, opacity: 0 }, | |
| visible: { scale: 1, opacity: 1, transition: { type: 'spring', stiffness: 400, damping: 20 } }, | |
| exit: { scale: 0.7, opacity: 0, transition: { duration: 0.2 } }, | |
| }, | |
| bounce: { | |
| hidden: { scale: 0.5, opacity: 0 }, | |
| visible: { scale: 1, opacity: 1, transition: { type: 'spring', stiffness: 500, damping: 12 } }, | |
| exit: { scale: 0.5, opacity: 0, transition: { duration: 0.2 } }, | |
| }, | |
| elastic: { | |
| hidden: { scale: 0.3, opacity: 0, x: 40 }, | |
| visible: { scale: 1, opacity: 1, x: 0, transition: { type: 'spring', stiffness: 260, damping: 12 } }, | |
| exit: { scale: 0.3, opacity: 0, x: -40, transition: { duration: 0.3 } }, | |
| }, | |
| flip: { | |
| hidden: { rotateX: -90, opacity: 0 }, | |
| visible: { rotateX: 0, opacity: 1, transition: { duration: 0.5, ease: 'easeOut' } }, | |
| exit: { rotateX: 90, opacity: 0, transition: { duration: 0.3 } }, | |
| }, | |
| swing: { | |
| hidden: { rotate: -15, opacity: 0, y: 30 }, | |
| visible: { rotate: 0, opacity: 1, y: 0, transition: { type: 'spring', stiffness: 300, damping: 15 } }, | |
| exit: { rotate: 15, opacity: 0, y: -30, transition: { duration: 0.3 } }, | |
| }, | |
| zoomBounce: { | |
| hidden: { scale: 0.1, opacity: 0 }, | |
| visible: { | |
| scale: 1, | |
| opacity: 1, | |
| transition: { | |
| type: 'spring', | |
| stiffness: 200, | |
| damping: 10, | |
| restDelta: 0.001, | |
| }, | |
| }, | |
| exit: { scale: 0.1, opacity: 0, transition: { duration: 0.25 } }, | |
| }, | |
| }; | |
| const variant = variants[animationVariant] || variants.slideIn; | |
| return ( | |
| <motion.div | |
| layout | |
| initial="hidden" | |
| animate="visible" | |
| exit="exit" | |
| variants={variant} | |
| className={`pointer-events-auto w-full max-w-sm overflow-hidden rounded-xl border ${config.border} ${config.bg} backdrop-blur-sm shadow-lg ${config.glow}`} | |
| > | |
| <div className="relative flex gap-3 p-4"> | |
| <div className={`flex-shrink-0 flex h-10 w-10 items-center justify-center rounded-lg ${config.iconBg}`}> | |
| <Icon className={`h-5 w-5 ${config.iconColor}`} /> | |
| </div> | |
| <div className="flex-1 min-w-0"> | |
| <h4 className={`text-sm font-semibold ${config.title} mb-0.5 truncate`}> | |
| {title} | |
| </h4> | |
| <p className="text-xs text-zinc-400 leading-relaxed"> | |
| {message} | |
| </p> | |
| </div> | |
| {dismissible && ( | |
| <button | |
| onClick={() => onDismiss(id)} | |
| className="flex-shrink-0 h-7 w-7 inline-flex items-center justify-center rounded-lg text-zinc-500 hover:text-white hover:bg-white/10 transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-400/50" | |
| aria-label="Dismiss alert" | |
| > | |
| <X className="h-3.5 w-3.5" /> | |
| </button> | |
| )} | |
| </div> | |
| {autoClose && ( | |
| <div className="h-0.5 w-full bg-white/[0.06]"> | |
| <motion.div | |
| initial={{ width: '100%' }} | |
| animate={{ width: '0%' }} | |
| transition={{ duration: duration / 1000, ease: 'linear' }} | |
| className={`h-full ${config.progress} rounded-full`} | |
| /> | |
| </div> | |
| )} | |
| </motion.div> | |
| ); | |
| } |