Spaces:
Runtime error
Runtime error
Download client/src/components/ui/Modal.jsx from moustafa7/flwo: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/spaces/moustafa7/flwo/resolve/main/client/src/components/ui/Modal.jsx
- Command line
-
hf download hf://spaces/moustafa7/flwo/client/src/components/ui/Modal.jsx
-
curl -L -o Modal.jsx https://huggingface.co/spaces/moustafa7/flwo/resolve/main/client/src/components/ui/Modal.jsx
1.24 kB
| import { useEffect } from 'react' | |
| import { X } from 'lucide-react' | |
| import { cn } from '../../utils/cn' | |
| export function Modal({ open, isOpen, onClose, children, title, size = 'md' }) { | |
| const isVisible = open ?? isOpen ?? false | |
| useEffect(() => { | |
| if (isVisible) { | |
| document.body.style.overflow = 'hidden' | |
| } else { | |
| document.body.style.overflow = '' | |
| } | |
| return () => { document.body.style.overflow = '' } | |
| }, [isVisible]) | |
| if (!isVisible) return null | |
| const sizes = { sm: 'max-w-sm', md: 'max-w-lg', lg: 'max-w-2xl', xl: 'max-w-4xl' } | |
| return ( | |
| <div className="fixed inset-0 z-50 flex items-center justify-center p-4"> | |
| <div className="fixed inset-0 bg-black/40" onClick={onClose} /> | |
| <div className={cn('relative bg-white rounded-2xl shadow-xl w-full max-h-[90vh] overflow-y-auto', sizes[size])}> | |
| <div className="flex items-center justify-between p-4 border-b"> | |
| <h3 className="text-lg font-bold text-gray-900">{title}</h3> | |
| <button onClick={onClose} className="p-1 hover:bg-gray-100 rounded-lg"> | |
| <X className="w-5 h-5" /> | |
| </button> | |
| </div> | |
| <div className="p-4"> | |
| {children} | |
| </div> | |
| </div> | |
| </div> | |
| ) | |
| } | |