drop.chapril.org-firefoxsend/app/ui/home.js

40 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-10-25 04:07:10 +02:00
const html = require('choo/html');
const { list } = require('../utils');
const archiveTile = require('./archiveTile');
2018-10-30 19:37:33 +01:00
const modal = require('./modal');
2018-10-30 03:06:15 +01:00
const intro = require('./intro');
2018-10-25 04:07:10 +02:00
module.exports = function(state, emit) {
2020-07-24 19:06:27 +02:00
if (state.user.loginRequired && !state.user.loggedIn) {
emit('signup-cta', 'required');
}
2018-11-16 21:30:15 +01:00
const archives = state.storage.files
.filter(archive => !archive.expired)
.map(archive => archiveTile(state, emit, archive));
2018-11-01 20:04:14 +01:00
let left = '';
2018-10-25 04:07:10 +02:00
if (state.uploading) {
2018-11-01 20:04:14 +01:00
left = archiveTile.uploading(state, emit);
} else if (state.archive.numFiles > 0) {
2018-11-01 20:04:14 +01:00
left = archiveTile.wip(state, emit);
2018-10-25 04:07:10 +02:00
} else {
2018-11-01 20:04:14 +01:00
left = archiveTile.empty(state, emit);
2018-10-25 04:07:10 +02:00
}
archives.reverse();
2018-11-01 20:04:14 +01:00
const right =
archives.length === 0
2018-11-01 20:04:14 +01:00
? intro(state)
2019-06-14 20:30:43 +02:00
: list(archives, 'p-2 h-full overflow-y-auto w-full', 'mb-4 w-full');
2018-11-01 20:04:14 +01:00
2018-10-25 04:07:10 +02:00
return html`
2019-02-22 22:31:54 +01:00
<main class="main">
2018-11-16 21:30:15 +01:00
${state.modal && modal(state, emit)}
2019-02-11 22:48:06 +01:00
<section
2019-05-03 18:26:10 +02:00
class="h-full w-full p-6 md:p-8 overflow-hidden md:flex md:flex-row md:rounded-xl md:shadow-big"
2019-02-11 22:48:06 +01:00
>
2019-05-03 18:26:10 +02:00
<div class="px-2 w-full md:px-0 md:mr-8 md:w-1/2">${left}</div>
2019-02-11 22:48:06 +01:00
<div class="mt-6 w-full md:w-1/2 md:-m-2">${right}</div>
2018-11-16 21:30:15 +01:00
</section>
</main>
`;
2018-10-25 04:07:10 +02:00
};