Spaces:
Configuration error
Configuration error
Download frontend/src/components/shared/modals/modal-backdrop.tsx from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 879 Bytes
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/components/shared/modals/modal-backdrop.tsx
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/src/components/shared/modals/modal-backdrop.tsx
-
curl -L -o modal-backdrop.tsx https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/components/shared/modals/modal-backdrop.tsx
879 Bytes
| import React from "react"; | |
| interface ModalBackdropProps { | |
| children: React.ReactNode; | |
| onClose?: () => void; | |
| } | |
| export function ModalBackdrop({ children, onClose }: ModalBackdropProps) { | |
| React.useEffect(() => { | |
| const handleEscape = (e: KeyboardEvent) => { | |
| if (e.key === "Escape") onClose?.(); | |
| }; | |
| window.addEventListener("keydown", handleEscape); | |
| return () => window.removeEventListener("keydown", handleEscape); | |
| }, []); | |
| const handleClick = (e: React.MouseEvent<HTMLDivElement>) => { | |
| if (e.target === e.currentTarget) onClose?.(); // only close if the click was on the backdrop | |
| }; | |
| return ( | |
| <div className="fixed inset-0 flex items-center justify-center z-20"> | |
| <div | |
| onClick={handleClick} | |
| className="fixed inset-0 bg-black bg-opacity-80" | |
| /> | |
| <div className="relative">{children}</div> | |
| </div> | |
| ); | |
| } | |