Giter Site home page Giter Site logo

svelte-dropzone's Introduction

svelte-dropzone

svelte-dropzone is a simple & ssr ready wrapper around dropzone.JS for svelte and sapper.

cover

Installation

$ npm i svelte-dropzone

Usage

<script>
  import Dropzone from "svelte-dropzone";
  const addedfile = file => console.log(file);
  const drop = event => console.log(event.target);
  const init = () => console.log("dropzone init ! ๐Ÿ˜");
</script>

<Dropzone
  dropzoneClass="dropzoneClass"
  hooveringClass="hooveringClass"
  id="id"
  dropzoneEvents={{ addedfile, drop, init }}
  options={{ clickable: true, acceptedFiles: 'text/javascript', maxFilesize: 256, init }}>
  <p>Drop files here to upload</p>
</Dropzone>

API

prop default type/structure
dropzoneEvents {} object:{{ eventName: func}}
options { previewTemplate: "<div/>", dictDefaultMessage: "" } object:{{ optionName: optionValue}}
dropzoneClass "dropzone" string
hooveringClass "dropzone-hoovering" string
id "dropId" string
autoDiscover false bool
slot <p class="dropzoneDefaultSentence"> Drop files here to upload </p> element
  • All dropzone events can be found here
  • All dropzone options can be found here

svelte-dropzone's People

Contributors

beynar avatar eddiew avatar rallisf1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

svelte-dropzone's Issues

Unexpected token <

I'm getting this error in a svelte/sapper app.
Any ideas?

/Users/phil/websites/image-library/node_modules/svelte-dropzone/index.svelte:1
<script>
^

SyntaxError: Unexpected token <
    at Module._compile (internal/modules/cjs/loader.js:720:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Module.require (internal/modules/cjs/loader.js:683:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (/Users/phil/websites/image-library/__sapper__/dev/server/server.js:10:32)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)

There's a typo (unrelated) in the readme example

<script>
  import Dropzone from "sv-dropzone"

should be

<script>
  import Dropzone from "svelte-dropzone"

dropzone.js:1040 Uncaught Error: Dropzone already attached.

Uncaught Error: Dropzone already attached.
at new Dropzone (dropzone.js:1040)
at dropzone.js:2968
at Function.push../node_modules/dropzone/dist/dropzone.js.Dropzone.discover (dropzone.js:2974)
at push../node_modules/dropzone/dist/dropzone.js.Dropzone._autoDiscoverFunction (dropzone.js:3516)
at HTMLDocument.init (dropzone.js:3484)

Component doesn't work with standard template / please update

Hi Arnoud,

I just tried to make svelte-dropzone run as a sapper/svelte app with the standard template, just replacing index.svelte with your code - with no success. You readme looks great and easy, but then it doesn't work, as other issues are stating.

Your npm package is downloaded 50 times a week, which means that about 200 people spend 10 minutes or even hours with your software every month, trying to make it work.

It would be great if you could

  1. Update the instructions so it runs with the basic sapper template
  2. Fix the code if this is required to make it work
  3. Fix the npm package as some issues state it has errors
  4. Or - at least - write in bold letters, that this is not maintained. I think that's just fair.

Here is my little test:

$ npx degit "sveltejs/sapper-template#rollup" droptest
$ cd droptest
$ npm i
$ npm i svelte-dropzone
### replace index.svelte content with code from readme
$ npm run dev

> [email protected] dev /droptest
> sapper dev

โœ” server (2.3s)
โœ” client (2.9s)
โœ” service worker (27ms)
/droptest/node_modules/svelte-dropzone/index.svelte:1
<script>
^

SyntaxError: Unexpected token '<'
    at wrapSafe (internal/modules/cjs/loader.js:1072:16)
    at Module._compile (internal/modules/cjs/loader.js:1122:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
    at Module.load (internal/modules/cjs/loader.js:1002:32)
    at Function.Module._load (internal/modules/cjs/loader.js:901:14)
    at Module.require (internal/modules/cjs/loader.js:1044:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/droptest/__sapper__/dev/server/server.js:10:32)
    at Module._compile (internal/modules/cjs/loader.js:1158:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
> Server crashed

Anyway, thanks for sharing your code - I was looking for a solution like this.

Rollup error

I tried to use this component as described on README.md.
But, rollup showed me a error below.
[!] Error: UMD and IIFE output formats are not supported for code-splitting builds.
My rollup config is from svelte-template.
https://github.com/sveltejs/template
I cannot figure out this problem, but I can still learn from your code.
Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.