this lib has not been published and not ready to be used yet.
Vue Filedrop is a UI component that provides a dropzone for files, like this:
-> TODO: enter image here
It also is a renderless component that wraps all of the business logic (drag&drop event handling etc) and provides an easy to consume API via a scoped slot.
This allows developers to build their own UI representation of a Filedrop easily and withut worrying about edge cases and such.
<filedrop-ui @change="handlFiles">
<filedrop v-slot="{
dragEvents,
hovering,
files,
open,
}">
<div
:class="hovering ? 'some-class-for-hover-state'"
v-on:click="open"
v-on="dragEvents"
>
<p v-if="!files.length && !hovering">Drop files here or click to select</p>
<p v-elseif="hovering">You can drop the file(s) here </p>
<ul v-else>
<li v-for="file in files">{{file.name}}</li>
</ul>
</filedrop>
WARNING This package hasnt been published yet, so install instructions don't work.
npm i vue-filedrop
# or
yarn add filedrop
import Vue from 'vue'
import Filedrop from 'vue-filedrop'
Vue.use(Filedrop, {
// Default component names, customizable
// setting one to `false` skips their global registration
filedropName: 'Filedrop',
filedropUiName: 'FiledropUi'
})
Alternatively, you can import components indivudally and register them (globally or locally):
<-- e.g. in a .vue file: -->
<script>
import {
Filedrop,
FiledropUi
} from 'vue-filedrop'
export default {
components: {
Filedrop,
FiledropUi,
}
}
</script>
If you want proper tree-shaking support, we recommend to import froms src (click for more)
import Vue from 'vue'
import Filedrop from 'vue-filedrop/src/index'
Vue.use(Filedrop)
However, in most setups this requires some adjustment of the (webpack) build setup as content of /node_modules
is usually ignored by babel-loader configs.
Vue CLI projects offer the transpileDependencies to do this quick&easy:
// vue.config.js
module.exports = {
transpileDependencies: ['vue-filedrop']
}
Click here to see in-Browser install instructions
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-filedrop"></script>
In the browser, the plugin will automatically register the components globally
- todo
Click here to see information for constributors
yarn install
yarn run serve
yarn run build
yarn run lint
yarn run test
yarn run test:unit
This project is based on Vue CLI, see its Configuration Reference for further info.