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) {
|
|
|
|
const archives = state.storage.files.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);
|
2018-10-25 04:07:10 +02:00
|
|
|
} else if (state.archive) {
|
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 < 1
|
|
|
|
? intro(state)
|
2018-11-02 10:27:59 +01:00
|
|
|
: list(archives, 'list-reset h-full overflow-y-scroll', 'mb-3');
|
2018-11-01 20:04:14 +01:00
|
|
|
|
2018-10-25 04:07:10 +02:00
|
|
|
return html`
|
2018-11-05 09:12:40 +01:00
|
|
|
<main class="main relative">
|
2018-10-30 19:37:33 +01:00
|
|
|
${state.modal && modal(state, emit)}
|
2018-11-02 10:27:59 +01:00
|
|
|
<section class="h-full w-full p-6 md:flex md:flex-row z-10">
|
|
|
|
<div class="md:mr-6 md:w-1/2">${left}</div>
|
2018-11-05 23:19:26 +01:00
|
|
|
<div class="md:w-1/2 mt-6 md:mt-0">${right}</div>
|
2018-10-30 19:37:33 +01:00
|
|
|
</section>
|
|
|
|
</main>`;
|
2018-10-25 04:07:10 +02:00
|
|
|
};
|