add fxA ui elements

This commit is contained in:
Emily 2018-08-03 12:24:41 -07:00
parent 4c64593262
commit 894545a6f0
29 changed files with 612 additions and 370 deletions

View file

@ -1,3 +1,4 @@
/* global MAXFILESIZE */
import { blobStream, concatStream } from './streams';
export default class Archive {
@ -34,4 +35,21 @@ export default class Archive {
get stream() {
return concatStream(this.files.map(file => blobStream(file)));
}
addFiles(files) {
const newSize = files.reduce((total, file) => total + file.size, 0);
if (this.size + newSize > MAXFILESIZE) {
return false;
}
this.files = this.files.concat(files);
return true;
}
checkSize() {
return this.size <= MAXFILESIZE;
}
remove(index) {
this.files.splice(index, 1);
}
}

View file

@ -47,7 +47,7 @@ a {
padding: 0 25px;
box-sizing: border-box;
min-height: 500px;
max-height: 630px;
max-height: 800px;
height: 100px;
}
@ -55,6 +55,7 @@ a {
flex: none;
position: relative;
width: 400px;
margin-top: 32px;
background-color: white;
border-radius: 6px;
box-shadow: 0 0 0 3px rgba(12, 12, 13, 0.2);
@ -147,10 +148,6 @@ a {
border: none;
}
.uploadCancel:hover {
text-decoration: underline;
}
.input {
border: 1px solid var(--lightBorderColor);
font-size: 20px;
@ -161,26 +158,10 @@ a {
padding-right: 10px;
}
.input--noBtn {
border-radius: 6px;
}
.input--error {
border-color: var(--errorColor);
}
.inputBtn.inputError {
background-color: var(--errorColor);
}
.inputBtn.inputError:hover {
background-color: var(--errorColor);
}
.cursor--pointer {
cursor: pointer;
}
.link {
color: var(--linkColor);
text-decoration: none;
@ -206,35 +187,11 @@ a {
text-align: center;
}
.progressSection {
margin: 0 auto;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
text-align: center;
font-size: 15px;
}
.progressSection__text {
color: var(--lightTextColor);
letter-spacing: -0.4px;
margin-top: 24px;
margin-bottom: 74px;
}
.effect--fadeOut {
opacity: 0;
animation: fadeout 200ms linear;
}
.goBackButton {
position: absolute;
top: 0;
left: 0;
margin: 18px;
}
@keyframes fadeout {
0% {
opacity: 1;
@ -260,19 +217,26 @@ a {
}
}
.goBackButton {
position: absolute;
top: 0;
left: 0;
margin: 18px;
}
.error {
color: var(--errorColor);
font-weight: 600;
}
.title {
color: var(--textColor);
font-size: 33px;
color: var(--lightTextColor);
font-size: 18px;
line-height: 40px;
margin: 20px auto;
text-align: center;
max-width: 520px;
font-family: 'SF Pro Text', sans-serif;
font-weight: 700;
word-wrap: break-word;
}
@ -289,7 +253,7 @@ a {
}
.noDisplay {
display: none;
display: none !important;
}
.flexible {
@ -303,7 +267,7 @@ a {
.main {
flex-direction: column;
min-height: 700px;
height: 100%;
}
.spacer {
@ -312,7 +276,8 @@ a {
}
.stripedBox {
max-height: 550px;
margin-top: 72;
min-height: 400px;
flex: 1;
}

View file

@ -1,5 +1,3 @@
import { checkSize } from './utils';
export default function(state, emitter) {
emitter.on('DOMContentLoaded', () => {
document.body.addEventListener('dragover', event => {
@ -16,11 +14,9 @@ export default function(state, emitter) {
.querySelector('.uploadArea')
.classList.remove('uploadArea--dragging');
const target = event.dataTransfer;
const files = Array.from(event.dataTransfer.files);
checkSize(target.files, state.files);
emitter.emit('addFiles', { files: target.files });
emitter.emit('addFiles', { files });
}
});
});

View file

@ -1,14 +1,15 @@
/* global MAXFILESIZE */
import FileSender from './fileSender';
import FileReceiver from './fileReceiver';
import { copyToClipboard, delay, openLinksInNewTab, percent } from './utils';
import * as metrics from './metrics';
import { hasPassword } from './api';
import Archive from './archive';
import { bytes } from './utils';
export default function(state, emitter) {
let lastRender = 0;
let updateTitle = false;
state.files = [];
function render() {
emitter.emit('render');
@ -61,14 +62,9 @@ export default function(state, emitter) {
metrics.changedDownloadLimit(file);
});
emitter.on('removeUpload', async ({ file }) => {
for (let i = 0; i < state.files.length; i++) {
if (state.files[i] === file) {
state.files.splice(i, 1);
render();
return;
}
}
emitter.on('removeUpload', async ({ index }) => {
state.archive.remove(index);
render();
});
emitter.on('delete', async ({ file, location }) => {
@ -93,18 +89,28 @@ export default function(state, emitter) {
});
emitter.on('addFiles', async ({ files }) => {
for (let i = 0; i < files.length; i++) {
state.files.push(files[i]);
if (state.archive) {
if (!state.archive.addFiles(files)) {
// eslint-disable-next-line no-alert
alert(state.translate('fileTooBig', { size: bytes(MAXFILESIZE) }));
return;
}
} else {
const archive = new Archive(files);
if (!archive.checkSize()) {
// eslint-disable-next-line no-alert
alert(state.translate('fileTooBig', { size: bytes(MAXFILESIZE) }));
return;
}
state.archive = archive;
}
render();
});
//TODO: hook up to multi-file upload functionality
emitter.on('upload', async ({ files, type, dlCount, password }) => {
const file = new Archive(files);
const size = file.size;
const sender = new FileSender(file);
emitter.on('upload', async ({ type, dlCount, password }) => {
if (!state.archive) return;
const size = state.archive.size;
const sender = new FileSender(state.archive);
sender.on('progress', updateProgress);
sender.on('encrypting', render);
sender.on('complete', render);

View file

@ -1,9 +1,15 @@
const html = require('choo/html');
const raw = require('choo/html/raw');
const assets = require('../../common/assets');
const title = require('../templates/title');
module.exports = function(state) {
return html`
<div>
<a href="/" class="goBackButton">
<img src="${assets.get('back-arrow.svg')}"/>
</a>
${title(state)}
<div class="title">${state.translate('legalHeader')}</div>
${raw(
replaceLinks(state.translate('legalNoticeTestPilot'), [

View file

@ -4,8 +4,7 @@ const downloadButton = require('../../templates/downloadButton');
const downloadedFiles = require('../../templates/uploadedFileList');
module.exports = function(state, emit) {
const storageFile = state.storage.getFileById(state.params.id);
const multifiles = Array.from(storageFile.manifest.files);
const ownedFile = state.storage.getFileById(state.params.id);
const trySendLink = html`
<a class="link link--action" href="/">
@ -26,7 +25,7 @@ module.exports = function(state, emit) {
<div class="page">
${titleSection(state)}
${downloadedFiles(multifiles, state, emit)}
${downloadedFiles(ownedFile, state, emit)}
<div class="description">${state.translate('downloadMessage2')}</div>
${downloadButton(state, emit)}

View file

@ -4,7 +4,7 @@ const raw = require('choo/html/raw');
const assets = require('../../../common/assets');
const notFound = require('../notFound');
const deletePopup = require('../../templates/popup');
const uploadedFiles = require('../../templates/uploadedFileList');
const uploadedFileList = require('../../templates/uploadedFileList');
const { allowedCopy, delay, fadeOut } = require('../../utils');
module.exports = function(state, emit) {
@ -17,8 +17,6 @@ module.exports = function(state, emit) {
? ''
: 'passwordReminder--hidden';
const multifiles = Array.from(file.manifest.files);
return html`
<div class="page effect--fadeIn" id="shareWrapper">
@ -27,11 +25,10 @@ module.exports = function(state, emit) {
</a>
${expireInfo(file, state.translate)}
${uploadedFiles(multifiles, state, emit)}
${uploadedFileList(file, state, emit)}
<div class="sharePage__copyText">
${state.translate('copyUrlFormLabelWithName', { filename: '' })}
${state.translate('copyUrlLabel')}
<div class="sharePage__passwordReminder ${passwordReminderClass}">(don't forget the password too)</div>
</div>
@ -60,14 +57,14 @@ module.exports = function(state, emit) {
<button
class="btn--cancel btn--delete"
title="${state.translate('deleteFileButton')}"
onclick=${showPopup}>${state.translate('deleteFileButton')}
onclick=${showDeletePopup}>${state.translate('deleteFileButton')}
</button>
</div>
`;
function showPopup() {
function showDeletePopup() {
const popup = document.querySelector('.popup');
popup.classList.add('popup--show');
popup.focus();

View file

@ -37,6 +37,7 @@ module.exports = function(state, emit) {
${state.translate('signInContinueMessage')}
<form
onsubmit=${submitEmail}
data-no-csrf>
<input
type="text"
@ -57,4 +58,9 @@ module.exports = function(state, emit) {
</div>
`;
function submitEmail(event) {
event.preventDefault();
//TODO: hook up fxA onboarding
}
};

View file

@ -6,7 +6,7 @@
.signIn__info {
width: 308px;
margin: 16px auto 0;
margin: 12px auto 0;
text-align: left;
}
@ -26,7 +26,7 @@
height: 40px;
border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 4px;
margin: 0;
margin: 8px 0;
padding: 0 8px;
font-size: 18px;
color: var(--lightTextColor);

View file

@ -1,6 +1,5 @@
const html = require('choo/html');
const assets = require('../../../common/assets');
const { checkSize } = require('../../utils');
const title = require('../../templates/title');
const setPasswordSection = require('../../templates/setPasswordSection');
const uploadBox = require('../../templates/uploadedFileList');
@ -9,14 +8,15 @@ const expireInfo = require('../../templates/expireInfo');
module.exports = function(state, emit) {
// the page flickers if both the server and browser set 'effect--fadeIn'
const fade = state.layout ? '' : 'effect--fadeIn';
const files = state.files ? state.files : [];
const hasAnUpload = state.archive && state.archive.numFiles > 0;
const optionClass = state.uploading ? 'uploadOptions--faded' : '';
const btnUploading = state.uploading ? 'btn--stripes' : '';
const cancelVisible = state.uploading ? '' : 'noDisplay';
const faded = files.length > 0 ? 'uploadArea--faded' : '';
const selectFileClass = files.length > 0 ? 'btn--hidden' : '';
const sendFileClass = files.length > 0 ? '' : 'btn--hidden';
const faded = hasAnUpload ? 'uploadArea--faded' : '';
const selectFileClass = hasAnUpload > 0 ? 'btn--hidden' : '';
const sendFileClass = hasAnUpload > 0 ? '' : 'btn--hidden';
let btnText = '';
@ -37,7 +37,7 @@ module.exports = function(state, emit) {
ondragover=${dragover}
ondragleave=${dragleave}>
${uploadBox(files, state, emit)}
${uploadBox(state.archive, state, emit)}
<div class="uploadedFilesWrapper ${faded}">
<img
@ -118,21 +118,18 @@ module.exports = function(state, emit) {
async function addFiles(event) {
event.preventDefault();
const target = event.target;
checkSize(target.files, state.files);
emit('addFiles', { files: target.files });
const newFiles = Array.from(event.target.files);
emit('addFiles', { files: newFiles });
}
async function upload(event) {
event.preventDefault();
if (files.length > 0) {
emit('upload', {
files,
type: 'click',
dlCount: state.downloadCount,
password: state.password
});
}
emit('upload', {
type: 'click',
dlCount: state.downloadCount,
password: state.password
});
}
};

View file

@ -91,3 +91,7 @@
.uploadCancel {
margin: 6px 0 0;
}
.uploadCancel:hover {
text-decoration: underline;
}

View file

@ -1,6 +1,3 @@
/* global MAXFILESIZE */
import { bytes } from './utils';
export default function(state, emitter) {
window.addEventListener('paste', event => {
if (state.route !== '/' || state.uploading) return;
@ -12,14 +9,7 @@ export default function(state, emitter) {
if (!file) continue; // Sometimes null
if (file.size > MAXFILESIZE) {
// eslint-disable-next-line no-alert
alert(state.translate('fileTooBig', { size: bytes(MAXFILESIZE) }));
continue;
}
emitter.emit('upload', { file, type: 'paste' });
return; // return here since only one file is allowed to be uploaded at a time
emitter.emit('addFiles', { files: [file] });
}
});
}

View file

@ -1,5 +0,0 @@
const welcome = require('../pages/welcome');
module.exports = function(state, emit) {
return welcome(state, emit);
};

View file

@ -2,7 +2,6 @@ const choo = require('choo');
const html = require('choo/html');
const nanotiming = require('nanotiming');
const download = require('./download');
const header = require('../templates/header');
const footer = require('../templates/footer');
const fxPromo = require('../templates/fxPromo');
const signupPromo = require('../templates/signupPromo');
@ -24,7 +23,6 @@ function body(template) {
const b = html`<body class="background ${activeBackground(state)}">
${banner(state, emit)}
${signupPromo(state)}
${header(state)}
<main class="main">
<noscript>
<div class="noscript">
@ -61,7 +59,7 @@ function body(template) {
};
}
app.route('/', body(require('./home')));
app.route('/', body(require('../pages/welcome')));
app.route('/share/:id', body(require('../pages/share')));
app.route('/download/:id', body(download));
app.route('/download/:id/:key', body(download));

View file

@ -15,7 +15,7 @@
.fileList {
position: static;
width: 400px;
max-height: 200px;
max-height: 160px;
margin: 6px 0 0 -3px;
}
}

View file

@ -1,20 +1,18 @@
.footer {
right: 0;
bottom: 0;
left: 0;
font-size: 13px;
font-weight: 600;
display: flex;
align-items: flex-end;
flex-direction: row;
padding: 50px 31px 41px;
width: 100%;
box-sizing: border-box;
justify-content: flex-end;
align-items: flex-end;
}
.legalSection {
max-width: 81vw;
display: flex;
align-items: center;
flex-direction: row;
@ -35,60 +33,116 @@
color: #d7d7db;
}
.legalSection__mozLogo {
.footer__mozLogo {
width: 112px;
height: 32px;
margin-bottom: -5px;
}
.socialSection {
display: flex;
justify-content: space-between;
width: 94px;
}
.socialSection__link {
opacity: 0.9;
}
.socialSection__link:hover {
opacity: 1;
}
.socialSection__icon {
width: 32px;
height: 32px;
margin-bottom: -5px;
margin: 0 0 -5px 4px;
}
.feedback {
background-color: var(--primaryControlBGColor);
background-image: url('../assets/feedback.svg');
background-position: 2px 4px;
background-repeat: no-repeat;
background-size: 18px;
border-radius: 3px;
border: 1px solid var(--primaryControlBGColor);
color: var(--primaryControlFGColor);
cursor: pointer;
display: block;
font-size: 12px;
line-height: 12px;
padding: 5px;
overflow: hidden;
min-width: 12px;
max-width: 12px;
text-indent: 17px;
transition: all 250ms ease-in-out;
white-space: nowrap;
}
.feedback:hover,
.feedback:focus {
min-width: 30px;
max-width: 300px;
text-indent: 2px;
padding: 5px 5px 5px 20px;
background-color: var(--primaryControlHoverColor);
}
.feedback:active {
background-color: var(--primaryControlHoverColor);
}
.dropDownArrow {
display: none;
}
.dropdown__only {
display: none;
}
@media (max-device-width: 750px), (max-width: 750px) {
.footer {
justify-content: flex-start;
align-items: flex-start;
max-width: 630px;
padding: 20px 31px;
margin: auto;
align-items: flex-end;
padding: 20px 25px;
margin: 0;
min-width: 455px;
}
.legalSection__mozLogo {
margin-left: -7px;
.footer_hiddenIcon {
display: none;
}
.dropdown__only {
display: block;
}
.dropDownArrow {
display: initial;
float: right;
}
.legalSection {
flex-direction: column;
margin: auto;
width: 100%;
max-width: 100%;
flex: 0;
background-color: #fff;
display: block;
border-radius: 4px;
border: 1px solid rgba(12, 12, 13, 0.1);
box-sizing: border-box;
text-align: left;
margin-right: auto;
}
.legalSection__link {
flex: none;
display: block;
padding: 10px 0;
align-self: flex-start;
box-sizing: border-box;
height: 24px;
width: 176px;
margin: 0;
padding: 4px 20px 0 8px;
text-shadow: none;
font-weight: 400;
color: var(--lightTextColor);
}
.socialSection {
margin-top: 20px;
align-self: flex-start;
.legalSection__link:visited {
color: var(--lightTextColor);
}
.legalSection__link:hover {
color: var(--primaryControlFGColor);
background-color: var(--primaryControlBGColor);
}
.footer__noDisplay {
display: none;
}
}

View file

@ -1,62 +1,89 @@
const html = require('choo/html');
const version = require('../../../package.json').version;
const assets = require('../../../common/assets');
const { browserName } = require('../../utils');
module.exports = function(state) {
const browser = browserName();
const feedbackUrl = `https://qsurvey.mozilla.com/s3/txp-firefox-send?ver=${version}&browser=${browser}`;
const footer = html`<footer class="footer">
<div class="legalSection">
<a
href="https://www.mozilla.org/about/legal"
class="legalSection__link">
${state.translate('footerLinkLegal')}
</a>
<div class="legalSection"
onmouseover=${showDropDown}
onmouseout=${hideDropDown}>
<div class="legalSection__menu">
<img class="dropDownArrow" src="${assets.get('dropdown-arrow.svg')}"/>
<a class="legalSection__link"
href="https://www.mozilla.org/about/legal">
${state.translate('footerLinkLegal')}
</a>
</div>
<a
href="https://testpilot.firefox.com/about"
class="legalSection__link">
class="legalSection__link footer__dropdown footer__noDisplay">
${state.translate('footerLinkAbout')}
</a>
<a
href="/legal"
class="legalSection__link">${state.translate('footerLinkPrivacy')}</a>
<a
href="/legal"
class="legalSection__link">${state.translate('footerLinkTerms')}</a>
class="legalSection__link footer__dropdown footer__noDisplay">
${state.translate('footerLinkTerms')}
</a>
<a
href="https://www.mozilla.org/privacy/websites/#cookies"
class="legalSection__link">
class="legalSection__link footer__dropdown footer__noDisplay">
${state.translate('footerLinkCookies')}
</a>
<a
href="https://www.mozilla.org/about/legal/report-infringement/"
class="legalSection__link">
class="legalSection__link footer__dropdown footer__noDisplay">
${state.translate('reportIPInfringement')}
</a>
<a
href="https://www.mozilla.org"
class="legalSection__link">
<img
class="legalSection__mozLogo"
src="${assets.get('mozilla-logo.svg')}"
alt="mozilla"/>
</a>
<a
href="https://github.com/mozilla/send"
class="socialSection__link">
<img
class="socialSection__icon"
src="${assets.get('github-icon.svg')}"
alt="github"/>
class="legalSection__link footer__dropdown dropdown__only footer__noDisplay">
Github
</a>
<a
href="https://twitter.com/FxTestPilot"
class="socialSection__link">
<img
class="socialSection__icon"
src="${assets.get('twitter-icon.svg')}"
alt="twitter"/>
class="legalSection__link footer__dropdown dropdown__only footer__noDisplay">
Twitter
</a>
</div>
<a href="${feedbackUrl}"
rel="noreferrer noopener"
class="feedback"
alt="Feedback"
target="_blank">${state.translate('siteFeedback')}
</a>
<a
href="https://github.com/mozilla/send"
class="socialSection__link footer_hiddenIcon">
<img
class="socialSection__icon"
src="${assets.get('github-icon.svg')}"
alt="Github"/>
</a>
<a
href="https://twitter.com/FxTestPilot"
class="socialSection__link footer_hiddenIcon">
<img
class="socialSection__icon"
src="${assets.get('twitter-icon.svg')}"
alt="Twitter"/>
</a>
<a
href="https://www.mozilla.org"
class="socialSection__link">
<img
class="footer__mozLogo"
src="${assets.get('mozilla-logo.svg')}"
alt="mozilla"/>
</a>
</footer>`;
// HACK
// We only want to render this once because we
@ -65,4 +92,18 @@ module.exports = function(state) {
return target && target.nodeName && target.nodeName === 'FOOTER';
};
return footer;
function showDropDown() {
const menus = document.querySelectorAll('.footer__dropdown');
menus.forEach(element => {
element.classList.remove('footer__noDisplay');
});
}
function hideDropDown() {
const menus = document.querySelectorAll('.footer__dropdown');
menus.forEach(element => {
element.classList.add('footer__noDisplay');
});
}
};

View file

@ -3,95 +3,7 @@
box-sizing: border-box;
display: flex;
justify-content: space-between;
padding: 20px;
height: 32px;
padding: 10px;
width: 100%;
}
.logo {
display: flex;
position: relative;
align-items: center;
}
.logo__link {
display: flex;
flex-direction: row;
}
.logo__title {
color: #3e3d40;
font-size: 32px;
font-weight: 500;
margin: 0;
position: relative;
top: -1px;
letter-spacing: 1px;
margin-left: 8px;
transition: color 50ms;
}
.logo__title:hover {
color: var(--primaryControlBGColor);
}
.logo__subtitle {
color: #3e3d40;
font-size: 12px;
margin: 0 8px;
}
.logo__subtitle-link {
font-weight: bold;
color: #3e3d40;
transition: color 50ms;
}
.logo__subtitle-link:hover {
color: var(--primaryControlBGColor);
}
.feedback {
background-color: var(--primaryControlBGColor);
background-image: url('../assets/feedback.svg');
background-position: 2px 4px;
background-repeat: no-repeat;
background-size: 18px;
border-radius: 3px;
border: 1px solid var(--primaryControlBGColor);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
color: var(--primaryControlFGColor);
cursor: pointer;
display: block;
float: left;
font-size: 12px;
line-height: 12px;
opacity: 0.9;
padding: 5px;
overflow: hidden;
min-width: 12px;
max-width: 12px;
text-indent: 17px;
transition: all 250ms ease-in-out;
white-space: nowrap;
}
.feedback:hover,
.feedback:focus {
min-width: 30px;
max-width: 300px;
text-indent: 2px;
padding: 5px 5px 5px 20px;
background-color: var(--primaryControlHoverColor);
}
.feedback:active {
background-color: var(--primaryControlHoverColor);
}
@media (max-device-width: 750px), (max-width: 750px) {
.header {
padding-top: 60px;
flex-direction: column;
justify-content: flex-start;
}
}

View file

@ -1,15 +1,8 @@
const html = require('choo/html');
const version = require('../../../package.json').version;
const browser = browserName();
module.exports = function(state) {
const feedbackUrl = `https://qsurvey.mozilla.com/s3/txp-firefox-send?ver=${version}&browser=${browser}`;
module.exports = function() {
const header = html`
<header class="header">
<a href="${feedbackUrl}"
rel="noreferrer noopener"
class="feedback"
target="_blank">${state.translate('siteFeedback')}</a>
</header>`;
// HACK
// We only want to render this once because we
@ -19,26 +12,3 @@ module.exports = function(state) {
};
return header;
};
function browserName() {
try {
if (/firefox/i.test(navigator.userAgent)) {
return 'firefox';
}
if (/edge/i.test(navigator.userAgent)) {
return 'edge';
}
if (/trident/i.test(navigator.userAgent)) {
return 'ie';
}
if (/chrome/i.test(navigator.userAgent)) {
return 'chrome';
}
if (/safari/i.test(navigator.userAgent)) {
return 'safari';
}
return 'other';
} catch (e) {
return 'unknown';
}
}

View file

@ -3,7 +3,7 @@ const assets = require('../../../common/assets');
const bytes = require('../../utils').bytes;
const fileIcon = require('../fileIcon');
module.exports = function(file, state, emit) {
module.exports = function(file, index, state, emit, hasPassword) {
const transfer = state.transfer;
const transferState = transfer ? transfer.state : null;
const share = state.route.includes('share/');
@ -20,25 +20,15 @@ module.exports = function(file, state, emit) {
function cancel(event) {
event.preventDefault();
if (state.route === '/') {
emit('removeUpload', { file });
emit('removeUpload', { index });
}
}
//const percent = share ? 100 : Math.floor(progressRatio * 100);
/*
style="
background: linear-gradient(to right,
#e8f2fe 0%,
#e8f2fe ${percent}%,
#fff ${percent}%,
#fff 100%);"
*/
return html`
<li class="uploadedFile ${complete}" id="${file.id}"
>
${fileIcon(file.name, file._hasPassword)}
${fileIcon(file.name, hasPassword)}
<div class="uploadedFile__cancel ${cancelVisible}"
onclick=${cancel}>

View file

@ -1,12 +1,15 @@
const html = require('choo/html');
const file = require('../uploadedFile');
module.exports = function(files, state, emit) {
//const progressRatio = state.transfer ? state.transfer.progressRatio : 0;
module.exports = function(archive, state, emit) {
let files = [];
if (archive) {
files = Array.from(archive.manifest.files);
}
return html`
<ul class="uploadedFiles">
${files.map(f => file(f, state, emit))}
${files.map((f, i) => file(f, i, state, emit, archive._hasPassword))}
</ul>
`;
};

View file

@ -3,22 +3,46 @@ const assets = require('../../../common/assets');
// eslint-disable-next-line no-unused-vars
module.exports = function(state) {
const notLoggedInMenu = html`
<ul class="account_dropdown"
tabindex="-1"
>
<li>
<a class=account_dropdown__link>${state.translate(
'accountMenuOption'
)}</a>
</li>
<li>
<a href="/signin"
class=account_dropdown__link>${state.translate(
'signInMenuOption'
)}</a>
</li>
</ul>
`;
return html`
<div class="account">
<img
src="${assets.get('user.svg')}"
onclick=${onclick}
onclick=${avatarClick}
alt="account"/>
<ul class=account_dropdown>
<li class=account_dropdown__item>Placeholder</li>
<li class=account_dropdown__item>Placeholder</li>
</ul>
${notLoggedInMenu}
</div>`;
function onclick(event) {
function avatarClick(event) {
event.preventDefault();
const dropdown = document.querySelector('.account_dropdown');
dropdown.classList.toggle('visible');
dropdown.focus();
}
//the onblur trick makes links unclickable wtf
/*
function hideMenu(event) {
event.stopPropagation();
const dropdown = document.querySelector('.account_dropdown');
dropdown.classList.remove('visible');
}
*/
};

View file

@ -6,28 +6,59 @@
}
.account_dropdown {
z-index: 1;
z-index: 2;
position: absolute;
top: 25px;
left: -10px;
top: 30px;
left: -15px;
width: 150px;
list-style-type: none;
border: 1px solid rgba(0, 0, 0, 0.2);
border: 1px solid #ccc;
border-radius: 4px;
background-color: var(--pageBGColor);
box-shadow: 0 5px 12px 0 rgba(0, 0, 0, 0.2);
padding: 11px 0;
visibility: hidden;
outline: 0;
}
.account_dropdown__item {
.account_dropdown::after,
.account_dropdown::before {
position: absolute;
bottom: 100%;
left: 18px;
height: 0;
width: 0;
border: 1px solid transparent;
content: '';
pointer-events: none;
}
.account_dropdown::after {
border-bottom-color: var(--pageBGColor);
border-width: 12px;
}
.account_dropdown::before {
border-bottom-color: #ccc;
border-width: 13px;
margin-left: -1px;
}
.account_dropdown__link {
display: block;
padding: 0 14px;
color: var(--lightTextColor);
font-size: 13px;
line-height: 24px;
color: var(--lightTextColor);
position: relative;
z-index: 999;
}
.account_dropdown__item:hover {
.account_dropdown__link:visited {
color: var(--lightTextColor);
}
.account_dropdown__link:hover {
background-color: var(--primaryControlBGColor);
color: var(--primaryControlFGColor);
}

View file

@ -1,4 +1,3 @@
/* global MAXFILESIZE */
const b64 = require('base64-js');
function arrayToB64(array) {
@ -129,24 +128,26 @@ function openLinksInNewTab(links, should = true) {
return links;
}
function checkSize(files, oldfiles, translate) {
function size(arr) {
let total = 0;
for (let i = 0; i < arr.length; i++) {
total += arr[i].size;
function browserName() {
try {
if (/firefox/i.test(navigator.userAgent)) {
return 'firefox';
}
return total;
}
const addSize = size(files);
if (addSize === 0) {
return;
}
const totalSize = addSize + size(oldfiles);
if (totalSize > MAXFILESIZE) {
// eslint-disable-next-line no-alert
alert(translate('fileTooBig', { size: bytes(MAXFILESIZE) }));
return;
if (/edge/i.test(navigator.userAgent)) {
return 'edge';
}
if (/trident/i.test(navigator.userAgent)) {
return 'ie';
}
if (/chrome/i.test(navigator.userAgent)) {
return 'chrome';
}
if (/safari/i.test(navigator.userAgent)) {
return 'safari';
}
return 'other';
} catch (e) {
return 'unknown';
}
}
@ -163,5 +164,5 @@ module.exports = {
loadShim,
isFile,
openLinksInNewTab,
checkSize
browserName
};