fox-send/app/templates/uploadedFile/index.js

40 lines
1008 B
JavaScript
Raw Normal View History

2018-07-31 18:09:18 +00:00
const html = require('choo/html');
const assets = require('../../../common/assets');
const bytes = require('../../utils').bytes;
const fileIcon = require('../fileIcon');
2018-08-03 19:24:41 +00:00
module.exports = function(file, index, state, emit, hasPassword) {
2018-07-31 18:09:18 +00:00
const cancelVisible =
2018-07-31 22:19:18 +00:00
state.route === '/' && !state.uploading
? 'uploadedFile__cancel--visible'
: '';
2018-07-31 18:09:18 +00:00
function cancel(event) {
event.preventDefault();
2018-07-31 22:19:18 +00:00
if (state.route === '/') {
2018-08-03 19:24:41 +00:00
emit('removeUpload', { index });
2018-07-31 18:09:18 +00:00
}
}
return html`
2018-10-10 01:17:40 +00:00
<li class="uploadedFile" id="${file.id}">
2018-07-31 18:09:18 +00:00
2018-08-03 19:24:41 +00:00
${fileIcon(file.name, hasPassword)}
2018-07-31 18:09:18 +00: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>
</li>
`;
};