full page download ui (#1126)

This commit is contained in:
Danny Coates 2019-01-30 07:50:17 -08:00 committed by Donovan Preston
parent 5eb24065b6
commit 9e3bde2cc9
3 changed files with 47 additions and 38 deletions

View File

@ -404,15 +404,17 @@ module.exports.preview = function(state, emit) {
archive.open = true; archive.open = true;
} }
return html` return html`
<send-archive class="flex flex-col max-h-full bg-white border border-grey-light p-4 w-full"> <send-archive class="flex flex-col max-h-full bg-white border border-grey-light p-4 w-full md:w-4/5">
<p class="w-full mb-4"> <p class="w-full mb-4">
<img class="float-left mr-3" src="${assets.get('blue_file.svg')}"/> <img class="float-left mr-3" src="${assets.get('blue_file.svg')}"/>
<h1 class="text-sm font-medium word-break-all">${archive.name}</h1> <h1 class="text-sm font-medium word-break-all">${archive.name}</h1>
<div class="text-xs font-normal opacity-75 pt-1">${bytes( <div class="text-xs font-normal opacity-75 pt-1">${bytes(
archive.size archive.size
)}</div> )}</div>
</p> </p>
${archiveDetails(state.translate, archive)} <div class="h-full md:h-48 overflow-y-auto">
${archiveDetails(state.translate, archive)}
</div>
<button <button
id="download-btn" id="download-btn"
class="btn rounded mt-4 w-full flex-no-shrink" class="btn rounded mt-4 w-full flex-no-shrink"
@ -429,12 +431,12 @@ module.exports.preview = function(state, emit) {
} }
}; };
module.exports.downloading = function(state, emit) { module.exports.downloading = function(state) {
const archive = state.fileInfo; const archive = state.fileInfo;
const progress = state.transfer.progressRatio; const progress = state.transfer.progressRatio;
const progressPercent = percent(progress); const progressPercent = percent(progress);
return html` return html`
<send-archive class="flex flex-col bg-white border border-grey-light p-4 w-full"> <send-archive class="flex flex-col bg-white border border-grey-light p-4 w-full md:w-4/5">
<p class="w-full mb-4"> <p class="w-full mb-4">
<img class="float-left mr-3" src="${assets.get('blue_file.svg')}"/> <img class="float-left mr-3" src="${assets.get('blue_file.svg')}"/>
<h1 class="text-sm font-medium word-break-all">${archive.name}</h1> <h1 class="text-sm font-medium word-break-all">${archive.name}</h1>
@ -444,17 +446,5 @@ module.exports.downloading = function(state, emit) {
</p> </p>
<div class="text-blue text-sm font-medium mt-2">${progressPercent}</div> <div class="text-blue text-sm font-medium mt-2">${progressPercent}</div>
<progress class="my-3" value="${progress}">${progressPercent}</progress> <progress class="my-3" value="${progress}">${progressPercent}</progress>
<button
class="border rounded bg-grey-dark text-white mt-2 text-center py-2 px-6 h-12 w-full flex flex-no-shrink items-center justify-center font-semibold"
title="${state.translate('downloadCancel')}"
onclick=${cancel}>
${state.translate('downloadCancel')}
</button>
</send-archive>`; </send-archive>`;
function cancel(event) {
event.preventDefault();
event.target.disabled = true;
emit('cancel');
}
}; };

View File

@ -1,7 +1,6 @@
/* global downloadMetadata */ /* global downloadMetadata */
const html = require('choo/html'); const html = require('choo/html');
const archiveTile = require('./archiveTile'); const archiveTile = require('./archiveTile');
const intro = require('./intro');
const modal = require('./modal'); const modal = require('./modal');
const notFound = require('./notFound'); const notFound = require('./notFound');
@ -11,20 +10,17 @@ function password(state, emit) {
const div = html` const div = html`
<div <div
class="h-full flex flex-col items-center justify-center border border-grey-light bg-white py-8" class="h-full w-full flex flex-col items-center justify-center bg-white py-8"
> >
<label <h1 class="mb-4">${state.translate('downloadFileTitle')}</h1>
id="password-error" <form
class="${invalid ? '' : 'invisible'} text-red my-4" class="flex flex-row flex-no-wrap w-full md:w-4/5"
for="password-input" onsubmit="${checkPassword}"
data-no-csrf
> >
${state.translate('passwordTryAgain')}
</label>
<form class="w-5/6" onsubmit="${checkPassword}" data-no-csrf>
<input <input
id="password-input" id="password-input"
class="w-full border rounded ${invalid class="w-full border-l border-t border-b rounded-l-sm ${invalid
? 'border-red' ? 'border-red'
: 'border-grey'} leading-loose px-2 py-1" : 'border-grey'} leading-loose px-2 py-1"
maxlength="32" maxlength="32"
@ -33,14 +29,22 @@ function password(state, emit) {
oninput="${inputChanged}" oninput="${inputChanged}"
type="password" type="password"
/> />
<input <input
type="submit" type="submit"
id="password-btn" id="password-btn"
class="hidden" class="btn rounded-r-sm ${invalid
value="${state.translate('unlockInputLabel')}" ? 'bg-red hover:bg-red focus:bg-red'
: ''}"
value="${state.translate('unlockButtonLabel')}"
/> />
</form> </form>
<label
id="password-error"
class="${invalid ? '' : 'invisible'} text-red my-4"
for="password-input"
>
${state.translate('passwordTryAgain')}
</label>
</div> </div>
`; `;
@ -48,14 +52,19 @@ function password(state, emit) {
setTimeout(() => document.getElementById('password-input').focus()); setTimeout(() => document.getElementById('password-input').focus());
} }
function inputChanged() { function inputChanged(event) {
event.stopPropagation();
event.preventDefault();
const label = document.getElementById('password-error'); const label = document.getElementById('password-error');
const input = document.getElementById('password-input'); const input = document.getElementById('password-input');
const btn = document.getElementById('password-btn');
label.classList.add('invisible'); label.classList.add('invisible');
input.classList.remove('border-red'); input.classList.remove('border-red');
btn.classList.remove('bg-red', 'hover:bg-red', 'focus:bg-red');
} }
function checkPassword(event) { function checkPassword(event) {
event.stopPropagation();
event.preventDefault(); event.preventDefault();
const password = document.getElementById('password-input').value; const password = document.getElementById('password-input').value;
if (password.length > 0) { if (password.length > 0) {
@ -96,13 +105,18 @@ module.exports = function(state, emit) {
switch (state.transfer.state) { switch (state.transfer.state) {
case 'downloading': case 'downloading':
case 'decrypting': case 'decrypting':
content = archiveTile.downloading(state, emit); content = html`
<div class="flex flex-col w-full h-full items-center mt-8">
<h1 class="mb-4">${state.translate('downloadingTitle')}</h1>
${archiveTile.downloading(state, emit)}
</div>
`;
break; break;
case 'complete': case 'complete':
content = html` content = html`
<div <div
id="download-complete" id="download-complete"
class="flex flex-col items-center justify-center h-full bg-white border border-grey-light p-2" class="flex flex-col items-center justify-center h-full w-full bg-white border border-grey-light p-2"
> >
<h1 class="text-center font-bold my-4 text-2xl"> <h1 class="text-center font-bold my-4 text-2xl">
${state.translate('downloadFinish')} ${state.translate('downloadFinish')}
@ -118,7 +132,12 @@ module.exports = function(state, emit) {
`; `;
break; break;
default: default:
content = archiveTile.preview(state, emit); content = html`
<div class="flex flex-col w-full h-full items-center mt-8">
<h1 class="mb-4">${state.translate('downloadFileTitle')}</h1>
${archiveTile.preview(state, emit)}
</div>
`;
} }
} else if (state.fileInfo.requiresPassword && !state.fileInfo.password) { } else if (state.fileInfo.requiresPassword && !state.fileInfo.password) {
content = password(state, emit); content = password(state, emit);
@ -127,8 +146,7 @@ module.exports = function(state, emit) {
<main class="main container"> <main class="main container">
${state.modal && modal(state, emit)} ${state.modal && modal(state, emit)}
<section class="relative h-full w-full p-6 md:flex md:flex-row"> <section class="relative h-full w-full p-6 md:flex md:flex-row">
<div class="md:mr-6 md:w-1/2">${content}</div> ${content}
<div class="md:w-1/2 mt-6 md:mt-0">${intro(state)}</div>
</section> </section>
</main> </main>
`; `;

View File

@ -174,4 +174,5 @@ accountBenefitSync = Manage your uploads across devices
manageAccount = Manage Account manageAccount = Manage Account
logOut = Sign Out logOut = Sign Out
okButton = Ok okButton = Ok
myUploads = My Uploads myUploads = My Uploads
downloadingTitle = Downloading