import { useState, useRef, DragEvent, ChangeEvent } from 'react' interface Props { onUpload: (file: File) => void } const ACCEPTED_EXTENSIONS = /\.(mp4|mov|avi|webm|mkv)$/i export default function Upload({ onUpload }: Props) { const [dragging, setDragging] = useState(false) const inputRef = useRef(null) const submit = (file: File) => { if (!ACCEPTED_EXTENSIONS.test(file.name)) return onUpload(file) } const onDrop = (e: DragEvent) => { e.preventDefault() setDragging(false) const file = e.dataTransfer.files[0] if (file) submit(file) } const onChange = (e: ChangeEvent) => { const file = e.target.files?.[0] if (file) submit(file) } return (
inputRef.current?.click()} onDragOver={(e) => { e.preventDefault(); setDragging(true) }} onDragLeave={() => setDragging(false)} onDrop={onDrop} >

Drop your A-roll clip here

or click to browse

MP4 · MOV · AVI · WebM · MKV

) }