import classNames from 'clsx'; import * as React from 'react'; import { FormattedMessage } from 'react-intl'; import { spring } from 'react-motion'; import { Icon, Stack, Text } from 'soapbox/components/ui'; import Motion from '../util/optional-motion'; interface IUploadArea { /** Whether the upload area is active. */ active: boolean, /** Callback when the upload area is closed. */ onClose: () => void, } /** Component to display when a file is dragged over the UI. */ const UploadArea: React.FC = ({ active, onClose }) => { const handleKeyUp = (e: KeyboardEvent) => { const keyCode = e.keyCode; if (active) { switch (keyCode) { case 27: e.preventDefault(); e.stopPropagation(); onClose(); break; } } }; React.useEffect(() => { window.addEventListener('keyup', handleKeyUp, false); return () => window.removeEventListener('keyup', handleKeyUp); }, []); return ( {({ backgroundOpacity, backgroundScale }) => (
)} ); }; export default UploadArea;