Skip to content

Commit 02fd65b

Browse files
committed
Readme updated for custom preview
1 parent 58ac123 commit 02fd65b

21 files changed

+146
-0
lines changed

.babelrc

100644100755
File mode changed.

.gitignore

100644100755
File mode changed.

LICENCE

100644100755
File mode changed.

README.md

100644100755
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ Many of these props are inherited from [dropzone configuration so see their doco
7373
| language | Object | Use dropzone's [dict properties](http://www.dropzonejs.com/#config-dictDefaultMessage) to change texts. |
7474
| useCustomDropzoneOptions | Boolean | If you want to define your own dropzone config set this to true and define a dropzoneOptions.|
7575
| dropzoneOptions | Object | A custom set of rules to define your dropzone object, use anything available in the [dropzone config](http://www.dropzonejs.com/#configuration-options).|
76+
| preview-template | Function | A custom preview template which will be passed as function. See following Note |
77+
78+
## Custom Dropzone preview template
79+
80+
> NOTE : Props like `thumbnailWidth,thumbnailHeight, useFontAwesome` will not work when you override the dropzone preview. No worry you can refer [demo file](demo/custom-dropzone-preview.vue) to achieve same. :) Don't forgot to add your styles in `<style>`
81+
82+
[Custom Dropzone Template Demo File](demo/custom-dropzone-preview.vue)
83+
7684

7785
## Methods
7886
Methods you can call on the component.

build/base.js

100644100755
File mode changed.

build/dev.js

100644100755
File mode changed.

build/prod.js

100644100755
File mode changed.

demo/custom-dropzone-preview.vue

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<template>
2+
<div id="app">
3+
<p>Welcome to your Vue.js app!</p>
4+
5+
<dropzone
6+
id="myVueDropzone"
7+
url="https://httpbin.org/post"
8+
v-on:vdropzone-success="showSuccess"
9+
v-bind:preview-template="template">
10+
<!-- Optional parameters if any! -->
11+
<input type="hidden" name="token" value="xxx">
12+
</dropzone>
13+
14+
</div>
15+
</template>
16+
17+
<script>
18+
import Dropzone from 'vue2-dropzone'
19+
20+
export default {
21+
name: 'MainApp',
22+
components: {
23+
Dropzone
24+
},
25+
methods: {
26+
'showSuccess': function (file) {
27+
console.log('A file was successfully uploaded')
28+
},
29+
'template':function() {
30+
31+
return `
32+
<div class="dz-preview dz-file-preview">
33+
<div class="dz-image" style="width: 200px;height: 200px">
34+
<img data-dz-thumbnail /></div>
35+
<div class="dz-details">
36+
<div class="dz-size"><span data-dz-size></span></div>
37+
<div class="dz-filename"><span data-dz-name></span></div>
38+
</div>
39+
40+
<div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress></span></div>
41+
<div class="dz-error-message"><span data-dz-errormessage></span></div>
42+
<div class="dz-success-mark"><i class="fa fa-check"></i></div>
43+
<div class="dz-error-mark"><i class="fa fa-close"></i></div>
44+
</div>
45+
`;
46+
}
47+
}
48+
}
49+
</script>
50+
51+
<style>
52+
.vue-dropzone {
53+
border: 2px solid #000000;
54+
font-family: 'Arial', sans-serif;
55+
letter-spacing: 0.2px;
56+
color: #777;
57+
transition: background-color .2s linear;
58+
59+
&:hover {
60+
background-color: #F6F6F6;
61+
}
62+
63+
i {
64+
color: #CCC;
65+
}
66+
67+
.dz-preview {
68+
69+
.dz-image {
70+
border-radius: 1;
71+
&:hover {
72+
img {
73+
transform: none;
74+
-webkit-filter: none;
75+
}
76+
}
77+
}
78+
79+
.dz-details {
80+
bottom: 0;
81+
top: 0;
82+
color: white;
83+
background-color: rgba(33, 150, 243, 0.8);
84+
transition: opacity .2s linear;
85+
text-align: left;
86+
.dz-filename span, .dz-size span {
87+
background-color: transparent;
88+
}
89+
.dz-filename:not(:hover) span {
90+
border: none;
91+
}
92+
.dz-filename:hover span {
93+
background-color: transparent;
94+
border: none;
95+
}
96+
}
97+
98+
.dz-progress .dz-upload {
99+
background: #cccccc;
100+
}
101+
102+
.dz-remove {
103+
position: absolute;
104+
z-index: 30;
105+
color: white;
106+
margin-left: 15px;
107+
padding: 10px;
108+
top: inherit;
109+
bottom: 15px;
110+
border: 2px white solid;
111+
text-decoration: none;
112+
text-transform: uppercase;
113+
font-size: 0.8rem;
114+
font-weight: 800;
115+
letter-spacing: 1.1px;
116+
opacity: 0;
117+
}
118+
119+
&:hover {
120+
.dz-remove {
121+
opacity: 1;
122+
}
123+
}
124+
125+
.dz-success-mark, .dz-error-mark {
126+
margin-left: auto !important;
127+
margin-top: auto !important;
128+
width: 100% !important;
129+
top: 35% !important;
130+
left: 0;
131+
i {
132+
color: white !important;
133+
font-size: 5rem !important;
134+
}
135+
}
136+
}
137+
}
138+
</style>

dev/bundle.js

100644100755
File mode changed.

dev/bundle.js.map

100644100755
File mode changed.

0 commit comments

Comments
 (0)