import { useCallback, useEffect } from 'react'; import { FormattedMessage } from 'react-intl'; import { animated, config, useSpring } from '@react-spring/web'; import { reduceMotion } from 'mastodon/initial_state'; interface UploadAreaProps { active?: boolean; onClose: () => void; } export const UploadArea: React.FC = ({ active, onClose }) => { const handleKeyUp = useCallback( (e: KeyboardEvent) => { if (active && e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); onClose(); } }, [active, onClose], ); useEffect(() => { window.addEventListener('keyup', handleKeyUp, false); return () => { window.removeEventListener('keyup', handleKeyUp); }; }, [handleKeyUp]); const wrapperAnimStyles = useSpring({ from: { opacity: 0, }, to: { opacity: 1, }, reverse: !active, immediate: reduceMotion, }); const backgroundAnimStyles = useSpring({ from: { transform: 'scale(0.95)', }, to: { transform: 'scale(1)', }, reverse: !active, config: config.wobbly, immediate: reduceMotion, }); return (
); };