0.5.0 • Published 1 year ago

file-drops v0.5.0

Weekly downloads
52
License
MIT
Repository
github
Last release
1 year ago

file-drops

A simple in-browser file drop utility.

Usage

import fileDrop from 'file-drops';

const element = document.querySelector('#container');

const dropHandler = fileDrop('Drop a file', function(files) {
  // files = [ { name, contents }, ... ]
});

element.addEventListener('dragover', dropHandler);

Styling

On drop over, the utility will attach the following overlay to the element for which the drop handler got registered:

<div class="drop-overlay">
  <div class="box">
    <div class="label">{label}</div>
  </div>
</div>

Style it as you wish. :heart:

See also

License

MIT