send/app/ui/home.js

34 lines
1,001 B
JavaScript
Raw Normal View History

2018-10-25 02:07:10 +00:00
const html = require('choo/html');
const { list } = require('../utils');
const archiveTile = require('./archiveTile');
2018-10-30 18:37:33 +00:00
const modal = require('./modal');
2018-10-30 02:06:15 +00:00
const intro = require('./intro');
2018-10-25 02:07:10 +00:00
module.exports = function(state, emit) {
const archives = state.storage.files.map(archive =>
archiveTile(state, emit, archive)
);
2018-11-01 19:04:14 +00:00
let left = '';
2018-10-25 02:07:10 +00:00
if (state.uploading) {
2018-11-01 19:04:14 +00:00
left = archiveTile.uploading(state, emit);
2018-10-25 02:07:10 +00:00
} else if (state.archive) {
2018-11-01 19:04:14 +00:00
left = archiveTile.wip(state, emit);
2018-10-25 02:07:10 +00:00
} else {
2018-11-01 19:04:14 +00:00
left = archiveTile.empty(state, emit);
2018-10-25 02:07:10 +00:00
}
archives.reverse();
2018-11-01 19:04:14 +00:00
const right =
archives.length < 1
? intro(state)
: list(archives, 'list-reset h-full overflow-y-scroll', 'pb-4');
2018-10-25 02:07:10 +00:00
return html`
<main class="main container md:relative">
2018-10-30 18:37:33 +00:00
${state.modal && modal(state, emit)}
<section class="h-full w-full px-6 md:flex md:flex-row">
2018-11-01 19:04:14 +00:00
<div class="pt-4 md:pb-4 md:mr-6 md:w-1/2">${left}</div>
<div class="py-4 md:w-1/2">${right}</div>
2018-10-30 18:37:33 +00:00
</section>
</main>`;
2018-10-25 02:07:10 +00:00
};