Spaces:
Sleeping
Sleeping
Download frontend/src/components/ErrorToast.tsx from Sid-WC121/visual-notebook: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/spaces/Sid-WC121/visual-notebook/resolve/main/frontend/src/components/ErrorToast.tsx
- Command line
-
hf download hf://spaces/Sid-WC121/visual-notebook/frontend/src/components/ErrorToast.tsx
-
curl -L -o ErrorToast.tsx https://huggingface.co/spaces/Sid-WC121/visual-notebook/resolve/main/frontend/src/components/ErrorToast.tsx
1.37 kB
| import React, { useEffect } from 'react'; | |
| import { useUIStore } from '../store/ui'; | |
| export function ErrorToast() { | |
| const { errors, removeError } = useUIStore(); | |
| useEffect(() => { | |
| if (errors.length > 0) { | |
| const timer = setTimeout(() => removeError(0), 5000); | |
| return () => clearTimeout(timer); | |
| } | |
| }, [errors, removeError]); | |
| if (errors.length === 0) return null; | |
| return ( | |
| <div className="fixed bottom-4 right-4 z-50 flex flex-col gap-2"> | |
| {errors.map((error, i) => ( | |
| <div | |
| key={i} | |
| className="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg shadow-lg flex items-center gap-2 max-w-sm" | |
| > | |
| <svg className="w-4 h-4 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | |
| <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /> | |
| </svg> | |
| <span className="text-sm">{error}</span> | |
| <button onClick={() => removeError(i)} className="text-red-400 hover:text-red-600 ml-auto"> | |
| <svg className="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor"> | |
| <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" /> | |
| </svg> | |
| </button> | |
| </div> | |
| ))} | |
| </div> | |
| ); | |
| } | |