npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@polymer-vis/file-drop-zone

v3.0.0-pre.12a

Published

Polymer 2.0 element for dragging and dropping files into a customizable dropzone.

Downloads

13

Readme

file-drop-zone GitHub release Published on webcomponents.org styled with prettier

<style>
file-drop-zone {
  border: 1px dashed transparent;
  color: #aaa;
  background-color: #efefef;
  width: 560px;
  height: 300px;
  transition: all .3s;
}
file-drop-zone.dragover {
  border: 1px dashed #E91E63;
  transition: all .3s;
}
file-drop-zone:hover > [slot='drop-zone'],
file-drop-zone.dragover > [slot='drop-zone'] {
  color: #E91E63;
  transition: all .3s;
}
file-drop-zone.errored {
  background-color: #FFEBEE;
  transition: all .3s;
}
file-drop-zone[has-files] {
  color: #2196F3;
  transition: all .3s;
}
[slot='drop-zone'] {
  text-align: center;
  font-size: 1.1em;
  --iron-icon-height: 64px;
  --iron-icon-width: 64px;
}
[slot='drop-zone'] > .title {
  font-size: 1.2em;
}
[slot='drop-zone'] > .small{
  font-size: 0.6em;
}
</style>
<file-drop-zone
  multiple
  accept=".csv, .tsv"
  files="{{files}}"
  last-error="{{error}}"
  on-error="onError">

  <!-- Custom slot element to style the interior of the drop zone -->
  <div slot="drop-zone" class="layout vertical center center-justified">
    <iron-icon icon="description"></iron-icon>
    <div class="title">Drop CSV or TSV files here</div>
    <!-- error message -->
    <div class="small">[[error.message]]</div>
    <!-- list of file selected -->
    <template is="dom-repeat" items="[[files]]">
      <div class="small">[[item.name]]</div>
    </template>
  </div>

</file-drop-zone>

file-drop-zone is a Polymer 3.0.0-pre.12 element for dragging and dropping files into a customizable dropzone. The Polymer 2.0 version can be found in the master branch.

API documentations and examples can be found at file-drop-zone webcomponents page.

Installation

npm install --save @polymer-vis/file-drop-zone

Disclaimers

PolymerVis is a personal project and is NOT in any way affliated with Polymer or Google.

Quick Start

file-drop-zone is a wrapper around an invisible file input. The most basic use case is to style the file-drop-zone directly, and set the appropriate attributes (required, accept, multiple, name) for the file input.

file-drop-zone {
  width: 200px;
  height: 200px;
  background-color: #fafafa;
}
<file-drop-zone multiple accept="image/*" files="{{files}}"></file-drop-zone>

You can also customize the interior of the file-drop-zone via slot named drop-zone.

<file-drop-zone multiple accept="image/*" files="{{files}}">
  <div slot="drop-zone">
    <iron-icon icon="description"></iron-icon>
    <h3>Drop your file here</h3>
  </div>
</file-drop-zone>

Events

change or selected

Fired when one or more files are selected or dropped into the zone. Return a FileList of selected files. Deprecation warning: selected event will be deprecated and removed at 2.1.0. Use change event instead.

error

Fired when an error is encountered.

Styling

You can style file-drop-zone normally, but there are 3 additional states available for styling.

.dragover
You can style file-drop-zone when a file is dragged over the drop-zone with the dragover class.

file-drop-zone.dragover {
  border: 1px dashed grey;
}

.errored
You can style file-drop-zone when there is any error with the errored class.

file-drop-zone.errored {
  border: 1px dashed red;
}

[has-files]
You can style file-drop-zone when there are at least 1 selected file with the has-files attribute.

file-drop-zone[has-files] {
  border: 1px solid grey;
}