danyx23 / elm-dropzone Goto Github PK
View Code? Open in Web Editor NEWEasily allow users to drop files into the browser in Elm
Easily allow users to drop files into the browser in Elm
I'm trying to setup elm-dropzone as described in the README, but pattern matching the action fails with:
-- TYPE MISMATCH -------------------------------------------------- ././Home.elm
Tag `DropZone.Drop` is causing problems in this pattern match.
28โ DnDAction (Drop files) ->
^^^^^^^^^^
This pattern matches things of type:
DropZone.Action
But the values it will actually be trying to match are:
DropZone.Action a
I'm on Elm 0.16 and dropzone 1.0.1.
-- ...
import DropZone exposing (..)
-- ...
type alias Model =
{ dropzone : DropZone.Model, fileUrl : String }
type Action
= DnDAction DropZone.Action
| Load (Maybe String)
| Reset
init : Model
init =
{ dropzone = DropZone.init, fileUrl = "" }
update : Action -> Model -> (Model, Effects Action)
update action model =
case action of
DnDAction (Drop files) ->
let firstFile = List.head files
in ( { model
| dropzone = DropZone.update (Drop files) model.dropzone
}
, case firstFile of
Nothing -> Effects.none
Just file ->
file.blob
|> readAsTextFile
|> Task.toMaybe
|> Task.map Load
|> Effects.task
)
DnDAction act ->
-- These are the other DropZone actions that are not exposed,
-- but you still need to hand it to DropZone.update so
-- the DropZone model stays consistent
( { model | dropzone = DropZone.update act model.dropzone }
, Effects.none
)
Reset ->
({ model | fileUrl = "" }, Effects.none)
This looks like a cool library. I think it would be cool to update this to the latest version of Elm (if possible). Don't feel pressured to do it immediately, I'm just making an issue to track this.
I cannot find find module 'FileReader'.
Module 'Main' is trying to import it.
Potential problems could be:
* Misspelled the module name
* Need to add a source directory or new dependency to elm-package.json
Any chances of getting an update to Elm 0.19.1?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.