import React from 'react' export default class DropZone extends React.Component { constructor() { super() this.state = { focus: false } this.onDragEnter = this.onDragEnter.bind(this) this.onDragLeave = this.onDragLeave.bind(this) this.onDragOver = this.onDragOver.bind(this) this.onDrop = this.onDrop.bind(this) } onDragEnter() { this.setState({ focus: true }) } onDragLeave(e) { if (e.target !== this.refs.overlay.getDOMNode()) return this.setState({ focus: false }) } onDragOver(e) { e.preventDefault() e.dataTransfer.dropEffect = 'copy' } onDrop(e) { e.preventDefault() this.setState({ focus: false }) let file = e.dataTransfer.files[0] if (this.props.onDrop && file) this.props.onDrop(file) } render() { return