🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

file-dropzone-element

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-dropzone-element

Native Web Component for a dropzone to support uploading of binary files

Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
11
37.5%
Maintainers
1
Weekly downloads
 
Created
Source

file-dropzone-element

Native Web Component for a dropzone to support uploading of binary files

This is essentially a refactored version of https://github.com/ryanjdew/ml-uploader to eliminate AngularJS, and allow different kinds of backends. Credit to @ryanjdew for ml-uploader.

Disclaimer: Work in Progress, and not tested in production. Feedback welcome though.

Check https://caniuse.com/ to verify how well Web Components is covered by current browsers. This component uses Custom Elements v1, (optionally) HTML Imports, HTML Templates, Shadow DOM v1 (gracefull decay would be possible).

Installation

Simplest way:

<link rel="import" href="https://cdn.rawgit.com/grtjn/file-dropzone-element/master/file-dropzone.html">

Likely together with this polyfill:

<script src="https://cdn.rawgit.com/webcomponents/webcomponentsjs/master/webcomponents-hi.js" type="text/javascript" defer></script>

Alternatively, 'require'/include it with a tool like Webpack:

<%= require('html-loader!https://cdn.rawgit.com/grtjn/file-dropzone-element/master/file-dropzone.html') %>

Usage

Static example:

<file-dropzone
    button="false"
    multiple="multiple">
  <div slot="intro">
    <p><strong>Drop files here or click to select files.</strong></p>
    <em>(Files will be uploaded automatically)</em>
  </div>
</file-dropzone>

Emits events 'drop', 'drop-all', 'file-double-click'.

Embedding in Vue.js:

  • Import or include the web component in your index.html

  • Add file-dropzone to ignoreElements to stop it from squeaking:

      Vue.config.ignoredElements = ["file-dropzone"];
    
  • Use it in any component:

      <file-dropzone
          button="false"
          multiple="multiple"
          v-on:drop="sendFile"
          v-on:drop-all="sendAllFiles"
          v-on:file-double-click="openFile">
        <div slot="intro">
          <p><strong>Drop files here or click to select files.</strong></p>
          <em>(Files will be uploaded automatically)</em>
        </div>
      </file-dropzone>
    

Test locally

  • Uncomment the local import line in docs/index.html
  • Run something like python -m SimpleHTTPServer 8888 from project root
  • Open http://localhost:8888/docs/

Keywords

web-component

FAQs

Package last updated on 26 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts