2018-07-31 20:09:18 +02:00
|
|
|
const html = require('choo/html');
|
|
|
|
const assets = require('../../../common/assets');
|
|
|
|
const bytes = require('../../utils').bytes;
|
|
|
|
const fileIcon = require('../fileIcon');
|
|
|
|
|
2018-08-03 21:24:41 +02:00
|
|
|
module.exports = function(file, index, state, emit, hasPassword) {
|
2018-07-31 20:09:18 +02:00
|
|
|
const transfer = state.transfer;
|
|
|
|
const transferState = transfer ? transfer.state : null;
|
|
|
|
const share = state.route.includes('share/');
|
|
|
|
const complete = share ? 'uploadedFile--completed' : '';
|
|
|
|
|
|
|
|
const cancelVisible =
|
2018-08-01 00:19:18 +02:00
|
|
|
state.route === '/' && !state.uploading
|
|
|
|
? 'uploadedFile__cancel--visible'
|
|
|
|
: '';
|
2018-07-31 20:09:18 +02:00
|
|
|
|
|
|
|
const stampClass =
|
|
|
|
share || transferState === 'complete' ? 'uploadedFile__stamp--visible' : '';
|
|
|
|
|
|
|
|
function cancel(event) {
|
|
|
|
event.preventDefault();
|
2018-08-01 00:19:18 +02:00
|
|
|
if (state.route === '/') {
|
2018-08-03 21:24:41 +02:00
|
|
|
emit('removeUpload', { index });
|
2018-07-31 20:09:18 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return html`
|
|
|
|
<li class="uploadedFile ${complete}" id="${file.id}"
|
|
|
|
>
|
|
|
|
|
2018-08-03 21:24:41 +02:00
|
|
|
${fileIcon(file.name, hasPassword)}
|
2018-07-31 20:09:18 +02:00
|
|
|
|
|
|
|
<div class="uploadedFile__cancel ${cancelVisible}"
|
|
|
|
onclick=${cancel}>
|
|
|
|
<img
|
|
|
|
src="${assets.get('close-16.svg')}"
|
|
|
|
alt="cancel"/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="uploadedFile__fileData">
|
|
|
|
<p class="uploadedFile__fileName">${file.name}</p>
|
|
|
|
<p class="uploadedFile__fileInfo">
|
|
|
|
<span>${bytes(file.size)}</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<img src="${assets.get('sent-done.svg')}"
|
|
|
|
class="uploadedFile__stamp ${stampClass}"/>
|
|
|
|
</li>
|
|
|
|
`;
|
|
|
|
};
|