formatting update

This commit is contained in:
Danny Coates 2018-11-16 12:39:36 -08:00
parent 91a8c66e0c
commit fbad1ab55a
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
18 changed files with 387 additions and 279 deletions

View File

@ -1,10 +1,12 @@
const html = require('choo/html');
export default function error(_state, _emit) {
return html`<body>
return html`
<body>
<div id="white">
<h1>Error</h1>
<p>Sorry, an error occurred.</p>
</div>
</body>`;
</body>
`;
}

View File

@ -16,21 +16,19 @@ export default function preferences(state, emit) {
emit('pushState', '/');
}
return html`<body>
return html`
<body>
<div id="white">
<div id="preferences">
<a onclick=${clickDone} href="#">
done
</a>
<a onclick="${clickDone}" href="#"> done </a>
<dl>
<dt>
wss url:
</dt>
<dt>wss url:</dt>
<dd>
<input type="text" onchange=${updateWssUrl} value=${wssURL} />
<input type="text" onchange="${updateWssUrl}" value="${wssURL}" />
</dd>
</dl>
</div>
</div>
</body>`;
</body>
`;
}

View File

@ -26,8 +26,12 @@ export default function uploadComplete(state, emit) {
emit('upload', {});
}
const input = html`<input id="url" value=${file.url} readonly="true" />`;
const copyText = html`<span>Copy link</span>`;
const input = html`
<input id="url" value="${file.url}" readonly="true" />
`;
const copyText = html`
<span>Copy link</span>
`;
return html`<body>
<div id="white">
<div class="card">

View File

@ -12,13 +12,15 @@ export default function progressBar(state, emit) {
}
emit('pushState', '/');
}
return html`<body>
return html`
<body>
<div id="white">
<div class="card">
<div>${percent}%</div>
<span class="progress" style="width: ${percent}%">.</span>
<div class="cancel" onclick=${onclick}>CANCEL</div>
<div class="cancel" onclick="${onclick}">CANCEL</div>
</div>
</div>
</body>`;
</body>
`;
}

View File

@ -1,5 +1,7 @@
const html = require('choo/html');
module.exports = function() {
return html`<main class="main container"></main>`;
return html`
<main class="main container"></main>
`;
};

View File

@ -6,18 +6,27 @@ module.exports = function(name, url) {
return html`
<div class="flex flex-col items-center text-center p-4 max-w-sm">
<h1 class="font-bold my-4">${state.translate('notifyUploadDone')}</h1>
<p class="font-normal leading-normal text-grey-darker word-break-all">${state.translate(
'copyUrlFormLabelWithName',
{ filename: name }
)}</p>
<input type="text" id="share-url" class="w-full my-4 border rounded leading-loose h-12 px-2 py-1" value=${url} readonly="true"/>
<button class="rounded bg-blue hover\:bg-blue-dark focus\:bg-blue-darker cursor-pointer text-center text-white py-2 px-6 h-12 w-full flex flex-no-shrink items-center justify-center font-semibold" onclick=${copy}>
<p class="font-normal leading-normal text-grey-darker word-break-all">
${state.translate('copyUrlFormLabelWithName', { filename: name })}
</p>
<input
type="text"
id="share-url"
class="w-full my-4 border rounded leading-loose h-12 px-2 py-1"
value="${url}"
readonly="true"
/>
<button
class="rounded bg-blue hover\:bg-blue-dark focus\:bg-blue-darker cursor-pointer text-center text-white py-2 px-6 h-12 w-full flex flex-no-shrink items-center justify-center font-semibold"
onclick="${copy}"
>
${state.translate('copyUrlFormButton')}
</button>
<a class="text-blue my-4 font-medium cursor-pointer" onclick=${close}>${state.translate(
'okButton'
)}</a>
</div>`;
<a class="text-blue my-4 font-medium cursor-pointer" onclick="${close}"
>${state.translate('okButton')}</a
>
</div>
`;
function copy(event) {
event.stopPropagation();

View File

@ -8,31 +8,39 @@ function password(state, emit) {
const invalid = fileInfo.password === null;
const div = html`
<div class="h-full flex flex-col items-center justify-center border border-grey-light bg-white py-8">
<div
class="h-full flex flex-col items-center justify-center border border-grey-light bg-white py-8"
>
<label
id="password-error"
class="${invalid ? '' : 'invisible'} text-red my-4"
for="password-input">
for="password-input"
>
${state.translate('passwordTryAgain')}
</label>
<form class="w-5/6" onsubmit=${checkPassword} data-no-csrf>
<input id="password-input"
<form class="w-5/6" onsubmit="${checkPassword}" data-no-csrf>
<input
id="password-input"
class="w-full border rounded ${
invalid ? 'border-red' : 'border-grey'
} leading-loose px-2 py-1"
maxlength="32"
autocomplete="off"
placeholder="${state.translate('unlockInputPlaceholder')}"
oninput=${inputChanged}
type="password" />
oninput="${inputChanged}"
type="password"
/>
<input type="submit"
<input
type="submit"
id="password-btn"
class="hidden"
value="${state.translate('unlockInputLabel')}"/>
value="${state.translate('unlockInputLabel')}"
/>
</form>
</div>`;
</div>
`;
if (!(div instanceof String)) {
setTimeout(() => document.getElementById('password-input').focus());
@ -87,16 +95,20 @@ module.exports = function(state, emit) {
break;
case 'complete':
content = html`
<div id="download-complete" class="flex flex-col items-center justify-center h-full bg-white border border-grey-light p-2">
<h1 class="text-center font-bold my-4 text-2xl">${state.translate(
'downloadFinish'
)}</h1>
<div
id="download-complete"
class="flex flex-col items-center justify-center h-full bg-white border border-grey-light p-2"
>
<h1 class="text-center font-bold my-4 text-2xl">
${state.translate('downloadFinish')}
</h1>
<p class="mb-4">
<a href="/" class="text-blue font-medium">${state.translate(
'sendYourFilesLink'
)}</a>
<a href="/" class="text-blue font-medium"
>${state.translate('sendYourFilesLink')}</a
>
</p>
</div>`;
</div>
`;
break;
default:
content = archiveTile.preview(state, emit);
@ -110,5 +122,6 @@ module.exports = function(state, emit) {
<div class="md:mr-6 md:w-1/2">${content}</div>
<div class="md:w-1/2 mt-6 md:mt-0">${intro(state)}</div>
</section>
</main>`;
</main>
`;
};

View File

@ -4,10 +4,12 @@ const assets = require('../../common/assets');
module.exports = function(state) {
return html`
<main class="main container">
<div class="flex flex-col items-center bg-white m-6 px-6 py-8 border border-grey-light md:border-none md:px-12 md:py-16 shadow w-full md:h-full">
<h1 class="text-2xl text-center">${state.translate(
'errorPageHeader'
)}</h1>
<div
class="flex flex-col items-center bg-white m-6 px-6 py-8 border border-grey-light md:border-none md:px-12 md:py-16 shadow w-full md:h-full"
>
<h1 class="text-2xl text-center">
${state.translate('errorPageHeader')}
</h1>
<img class="my-16" src="${assets.get('illustration_error.svg')}" />
<p class="max-w-md leading-normal">
${state.translate('uploadPageExplainer')}
@ -16,5 +18,6 @@ module.exports = function(state) {
${state.translate('sendYourFilesLink')}
</a>
</div>
</main>`;
</main>
`;
};

View File

@ -8,14 +8,17 @@ const signupDialog = require('./signupDialog');
module.exports = function(state, emit) {
const el = html`
<div class="">
${raw(
${
raw(
state.translate('frontPageExpireInfo', {
downloadCount:
'<span class="lg:inline-block md:block sm:inline-block block"></span><select id="dlCount"></select>',
timespan: '<select id="timespan"></select>'
})
)}
</div>`;
)
}
</div>
`;
if (el.__encoded) {
// we're rendering on the server
return el;

View File

@ -4,23 +4,30 @@ const raw = require('choo/html/raw');
module.exports = function(state) {
return html`
<main class="main container">
<div class="flex flex-col items-center bg-white m-6 px-6 py-8 border border-grey-light md:border-none md:px-12 md:py-16 shadow w-full md:h-full">
<div
class="flex flex-col items-center bg-white m-6 px-6 py-8 border border-grey-light md:border-none md:px-12 md:py-16 shadow w-full md:h-full"
>
<h1 class="text-2xl text-center">${state.translate('legalHeader')}</h1>
${raw(
${
raw(
replaceLinks(state.translate('legalNoticeTestPilot'), [
'https://testpilot.firefox.com/terms',
'https://testpilot.firefox.com/privacy',
'https://testpilot.firefox.com/experiments/send'
])
)}
${raw(
)
}
${
raw(
replaceLinks(state.translate('legalNoticeMozilla'), [
'https://www.mozilla.org/privacy/websites/',
'https://www.mozilla.org/about/legal/terms/mozilla/'
])
)}
)
}
</div>
</main>`;
</main>
`;
};
function replaceLinks(str, urls) {

View File

@ -2,13 +2,20 @@ const html = require('choo/html');
module.exports = function(state, emit) {
return html`
<div class="absolute pin flex items-center justify-center overflow-hidden z-40 bg-cloud md:my-8" onclick=${close}>
<div
class="absolute pin flex items-center justify-center overflow-hidden z-40 bg-cloud md:my-8"
onclick="${close}"
>
<div class="h-full max-h-screen absolute pin-t flex items-center">
<div class="shadow-cloud bg-white" onclick=${e => e.stopPropagation()}>
<div
class="shadow-cloud bg-white"
onclick="${e => e.stopPropagation()}"
>
${state.modal(state, emit, close)}
</div>
</div>
</div>`;
</div>
`;
function close(event) {
if (event) {

View File

@ -4,13 +4,17 @@ const assets = require('../../common/assets');
module.exports = function(state) {
return html`
<main class="main container">
<div class="flex flex-col items-center bg-white m-6 px-6 py-8 border border-grey-light md:border-none md:px-12 md:py-16 shadow w-full md:h-full">
<h1 class="text-pink-dark text-2xl text-center">${state.translate(
'expiredPageHeader'
)}</h1>
<img class="my-16" src="${assets.get(
'illustration_expired.svg'
)}" id="expired-img">
<div
class="flex flex-col items-center bg-white m-6 px-6 py-8 border border-grey-light md:border-none md:px-12 md:py-16 shadow w-full md:h-full"
>
<h1 class="text-pink-dark text-2xl text-center">
${state.translate('expiredPageHeader')}
</h1>
<img
class="my-16"
src="${assets.get('illustration_expired.svg')}"
id="expired-img"
/>
<p class="max-w-md leading-normal">
${state.translate('uploadPageExplainer')}
</p>
@ -18,5 +22,6 @@ module.exports = function(state) {
${state.translate('sendYourFilesLink')}
</a>
</div>
</main>`;
</main>
`;
};

View File

@ -5,9 +5,13 @@ module.exports = function(message) {
return html`
<div class="flex flex-col max-w-xs p-4">
<div class="text-center m-8 leading-normal">${message}</div>
<button class="rounded bg-blue hover\:bg-blue-dark focus\:bg-blue-darker cursor-pointer text-center text-white py-2 px-6 h-12 w-full flex flex-no-shrink items-center justify-center font-semibold" onclick=${close}>${state.translate(
'okButton'
)}</button>
</div>`;
<button
class="rounded bg-blue hover\:bg-blue-dark focus\:bg-blue-darker cursor-pointer text-center text-white py-2 px-6 h-12 w-full flex flex-no-shrink items-center justify-center font-semibold"
onclick="${close}"
>
${state.translate('okButton')}
</button>
</div>
`;
};
};

View File

@ -4,14 +4,22 @@ module.exports = function(selected, options, translate, changed) {
let x = selected;
return html`
<select class="appearance-none cursor-pointer border rounded-sm bg-blue-lightest hover:border-blue focus:border-blue px-2 py-1 my-2 h-8" onchange=${choose}>
${options.map(
<select
class="appearance-none cursor-pointer border rounded-sm bg-blue-lightest hover:border-blue focus:border-blue px-2 py-1 my-2 h-8"
onchange="${choose}"
>
${
options.map(
i =>
html`<option value="${i}" ${
i === selected ? 'selected' : ''
}>${translate(i)}</option>`
)}
</select>`;
html`
<option value="${i}" ${i === selected ? 'selected' : ''}
>${translate(i)}</option
>
`
)
}
</select>
`;
function choose(event) {
const target = event.target;

View File

@ -11,41 +11,49 @@ module.exports = function(state) {
strings = unsupportedStrings(state);
why = html`
<a
class="text-blue" href="https://github.com/mozilla/send/blob/master/docs/faq.md#why-is-my-browser-not-supported">
class="text-blue"
href="https://github.com/mozilla/send/blob/master/docs/faq.md#why-is-my-browser-not-supported"
>
${state.translate('notSupportedLink')}
</a>`;
</a>
`;
url =
'https://www.mozilla.org/firefox/new/?utm_campaign=send-acquisition&utm_medium=referral&utm_source=send.firefox.com';
buttonAction = html`
<p class="ml-4 font-bold">
Firefox<br><span class="font-light text-base">${strings.button}</span>
</p>`;
Firefox<br /><span class="font-light text-base">${strings.button}</span>
</p>
`;
} else {
strings = outdatedStrings(state);
url = 'https://support.mozilla.org/kb/update-firefox-latest-version';
buttonAction = html`
<p class="ml-4">
${strings.button}
</p>`;
<p class="ml-4">${strings.button}</p>
`;
}
return html`
<main class="main container">
<div class="flex flex-col items-center bg-white m-6 px-6 py-8 border border-grey-light md:border-none md:px-12 md:py-16 shadow w-full md:h-full">
<div
class="flex flex-col items-center bg-white m-6 px-6 py-8 border border-grey-light md:border-none md:px-12 md:py-16 shadow w-full md:h-full"
>
<h1 class="text-center text-2xl">${strings.header}</h1>
<p class="my-10 max-w-md leading-normal">
${strings.description}
</p>
<p class="my-10 max-w-md leading-normal">${strings.description}</p>
${why}
<a href="${url}" class="border border-green-light rounded bg-green hover\:bg-green-dark focus\:bg-green-darker flex items-center justify-center text-2xl text-white mt-10 py-4 px-6">
<a
href="${url}"
class="border border-green-light rounded bg-green hover\:bg-green-dark focus\:bg-green-darker flex items-center justify-center text-2xl text-white mt-10 py-4 px-6"
>
<img
src="${assets.get('firefox_logo-only.svg')}"
class="w-10"
alt="Firefox"/>
alt="Firefox"
/>
${buttonAction}
</a>
</div>
</main>`;
</main>
`;
};
function outdatedStrings(state) {

View File

@ -7,8 +7,11 @@ module.exports = function(state) {
? html`
<script nonce="${state.cspNonce}">
const downloadMetadata = ${
state.downloadMetadata ? raw(JSON.stringify(state.downloadMetadata)) : '{}'
state.downloadMetadata
? raw(JSON.stringify(state.downloadMetadata))
: '{}'
};
</script>`
</script>
`
: '';
};

View File

@ -5,15 +5,21 @@ const initScript = require('./initScript');
module.exports = function(state, body = '') {
const firaTag = state.fira
? html`<link rel="stylesheet" type="text/css" href="https://code.cdn.mozilla.net/fonts/fira.css" />`
? html`
<link
rel="stylesheet"
type="text/css"
href="https://code.cdn.mozilla.net/fonts/fira.css"
/>
`
: '';
return html`
<!DOCTYPE html>
<html lang="${state.locale}">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta property="og:title" content="${state.title}" />
<meta name="twitter:title" content="${state.title}" />
@ -21,50 +27,72 @@ module.exports = function(state, body = '') {
<meta property="og:description" content="${state.description}" />
<meta name="twitter:description" content="${state.description}" />
<meta name="twitter:card" content="summary" />
<meta property="og:image" content="${state.baseUrl}${assets.get(
'send-fb.jpg'
)}"/>
<meta name="twitter:image" content="${state.baseUrl}${assets.get(
'send-twitter.jpg'
)}"/>
<meta
property="og:image"
content="${state.baseUrl}${assets.get('send-fb.jpg')}"
/>
<meta
name="twitter:image"
content="${state.baseUrl}${assets.get('send-twitter.jpg')}"
/>
<meta property="og:url" content="${state.baseUrl}" />
<title>${state.title}</title>
<link rel="stylesheet" type="text/css" href="${assets.get('app.css')}" />
<link
rel="stylesheet"
type="text/css"
href="${assets.get('app.css')}"
/>
<!-- generic favicons -->
<link rel="icon" href="${assets.get('favicon-32.png')}" sizes="32x32">
<link rel="icon" href="${assets.get('favicon-96.png')}" sizes="96x96">
<link rel="icon" href="${assets.get('favicon-128.png')}" sizes="128x128">
<link rel="icon" href="${assets.get('favicon-228.png')}" sizes="228x228">
<link rel="icon" href="${assets.get('favicon-32.png')}" sizes="32x32" />
<link rel="icon" href="${assets.get('favicon-96.png')}" sizes="96x96" />
<link
rel="icon"
href="${assets.get('favicon-128.png')}"
sizes="128x128"
/>
<link
rel="icon"
href="${assets.get('favicon-228.png')}"
sizes="228x228"
/>
<!-- Android -->
<link rel="shortcut icon" href="${assets.get(
'favicon-196.png'
)}" sizes="196x196">
<link
rel="shortcut icon"
href="${assets.get('favicon-196.png')}"
sizes="196x196"
/>
<!-- iOS -->
<link rel="apple-touch-icon" href="${assets.get(
'favicon-120.png'
)}" sizes="120x120">
<link rel="apple-touch-icon" href="${assets.get(
'favicon-152.png'
)}" sizes="152x152">
<link rel="apple-touch-icon" href="${assets.get(
'favicon-180.png'
)}" sizes="180x180">
<link
rel="apple-touch-icon"
href="${assets.get('favicon-120.png')}"
sizes="120x120"
/>
<link
rel="apple-touch-icon"
href="${assets.get('favicon-152.png')}"
sizes="152x152"
/>
<link
rel="apple-touch-icon"
href="${assets.get('favicon-180.png')}"
sizes="180x180"
/>
<!-- Windows 8 IE 10 -->
<meta name="msapplication-TileColor" content="#FFFFFF">
<meta name="msapplication-TileImage" content="${assets.get(
'favicon-144.png'
)}">
<meta name="msapplication-TileColor" content="#FFFFFF" />
<meta
name="msapplication-TileImage"
content="${assets.get('favicon-144.png')}"
/>
<!-- Windows 8.1 + IE11 and above -->
<meta name="msapplication-config" content="/browserconfig.xml" />
${firaTag}
<script defer src="/jsconfig.js"></script>
<!-- <script defer src="${assets.get('runtime.js')}"></script> -->
@ -77,15 +105,17 @@ module.exports = function(state, body = '') {
<div class="noscript">
<h2>${state.translate('javascriptRequired')}</h2>
<p>
<a class="link" href="https://github.com/mozilla/send/blob/master/docs/faq.md#why-does-firefox-send-require-javascript">
<a
class="link"
href="https://github.com/mozilla/send/blob/master/docs/faq.md#why-does-firefox-send-require-javascript"
>
${state.translate('whyJavascript')}
</a>
</p>
<p>${state.translate('enableJavascript')}</p>
</div>
</noscript>
${body}
${initScript(state)}
${body} ${initScript(state)}
</html>
`;
};

View File

@ -19,15 +19,15 @@ module.exports = function(app) {
<script>
const reporters = mocha.constructor.reporters;
function Combo(runner) {
reporters.HTML.call(this, runner)
reporters.JSON.call(this, runner)
reporters.HTML.call(this, runner);
reporters.JSON.call(this, runner);
}
Object.setPrototypeOf(Combo.prototype, reporters.HTML.prototype)
Object.setPrototypeOf(Combo.prototype, reporters.HTML.prototype);
mocha.setup({
ui: 'bdd',
reporter: Combo,
timeout: 5000
})
});
</script>
<script src="/jsconfig.js"></script>
<script src="${assets.get('cryptofill.js')}"></script>