Skip to content

Commit ab28085

Browse files
author
Walker Leite
committed
feat(component): now components add file and after upload transform into link with x
1 parent 3802f03 commit ab28085

1 file changed

Lines changed: 44 additions & 6 deletions

File tree

src/ic-firebase-uploader/ic-firebase-uploader.vue

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@click="onFileLinkClick(file.ref, $event)">
99
{{file.ref.name}}
1010
</a>
11-
<i class="fa fa-times ic-fb_uploader-delete" @click="onFileDeleteClick(file)"></i>
11+
<i :class="getIconClasses(file)" @click="onFileDeleteClick(file)"></i>
1212
</li>
1313
</ul>
1414
<input
@@ -130,13 +130,17 @@ export default {
130130
},
131131
getUploadFn(fileRef, file) {
132132
return () => {
133+
const sentFile = {
134+
ref: fileRef,
135+
isLoading: true,
136+
}
137+
this.sentFiles.push(sentFile)
138+
133139
fileRef.put(file)
134140
.then(() => fileRef.getDownloadURL())
135141
.then(downloadUrl => {
136-
this.sentFiles.push({
137-
ref: fileRef,
138-
downloadUrl,
139-
})
142+
sentFile.downloadUrl = downloadUrl
143+
sentFile.isLoading = false
140144
141145
/**
142146
* This event is called after each file upload ends.
@@ -150,7 +154,10 @@ export default {
150154
getDownloadURL: fileRef.getDownloadURL
151155
})
152156
})
153-
.catch(err => this.$emit('error', err))
157+
.catch(err => {
158+
this.$emit('error', err)
159+
sentFile.isLoading = false
160+
})
154161
}
155162
},
156163
getDeleteFn(file) {
@@ -173,6 +180,16 @@ export default {
173180
.catch(err => this.$emit('error', err))
174181
}
175182
},
183+
getIconClasses(file) {
184+
const classes = {
185+
'fa': true,
186+
'fa-times': !file.isLoading,
187+
'fa-spinner': file.isLoading,
188+
'ic-fb_uploader-delete': true,
189+
}
190+
191+
return classes;
192+
},
176193
/**
177194
* Open the file browser and ask user for the files
178195
*/
@@ -193,6 +210,27 @@ export default {
193210
color: #ad3636;
194211
}
195212
213+
.ic-fb_uploader .ic-fb_uploader-delete.fa-spinner {
214+
-webkit-animation-name: rotate;
215+
animation-name: rotate;
216+
-webkit-animation-duration: 2s;
217+
animation-duration: 2s;
218+
-webkit-animation-iteration-count: infinite;
219+
animation-iteration-count: infinite;
220+
-webkit-animation-timing-function: ease-in-out;
221+
animation-timing-function: ease-in-out;
222+
}
223+
224+
@-webkit-keyframes rotate {
225+
from {-webkit-transform: rotate(0deg);transform: rotate(0deg);}
226+
to {-webkit-transform: rotate(360deg);transform: rotate(360deg);}
227+
}
228+
229+
@keyframes rotate {
230+
from {-webkit-transform: rotate(0deg);transform: rotate(0deg);}
231+
to {-webkit-transform: rotate(360deg);transform: rotate(360deg);}
232+
}
233+
196234
.ic-fb_uploader .ic-fb_uploader-delete:hover {
197235
opacity: .8;
198236
}

0 commit comments

Comments
 (0)