fox-send/app/pages/signin/index.js

67 lines
2.0 KiB
JavaScript
Raw Normal View History

/* globals LIMITS */
2018-07-31 18:09:18 +00:00
const html = require('choo/html');
const assets = require('../../../common/assets');
const title = require('../../templates/title');
const bytes = require('../../utils').bytes;
2018-07-31 18:09:18 +00:00
module.exports = function(state, emit) {
return html`
<div class="page signInPage">
2018-08-31 22:15:25 +00:00
<a href="/" class="goBackButton">
<img src="${assets.get('back-arrow.svg')}"/>
2018-07-31 18:09:18 +00:00
</a>
${title(state)}
<div class="signIn__info flexible">
${state.translate('accountBenefitTitle')}
<ul>
<li>${state.translate('accountBenefitLargeFiles', {
size: bytes(LIMITS.MAX_FILE_SIZE)
})}</li>
2018-07-31 18:09:18 +00:00
<li>${state.translate('accountBenefitExpiry')}</li>
<li>${state.translate('accountBenefitSync')}</li>
</ul>
</div>
<div class="signIn__form flexible">
<img class="signIn__firefoxLogo"
src="${assets.get('firefox_logo-only.svg')}"
width=56 height=56
alt="Firefox logo"/>
<div class="signIn__emailLabel">
${state.translate('signInEmailEnter')}
</div>
${state.translate('signInContinueMessage')}
<form
2018-08-03 19:24:41 +00:00
onsubmit=${submitEmail}
2018-07-31 18:09:18 +00:00
data-no-csrf>
<input
id="email-input"
2018-07-31 18:09:18 +00:00
type="text"
class="signIn__emailInput"
placeholder=${state.translate('emailEntryPlaceholder')}/>
<input
class='noDisplay'
id="email-submit"
2018-07-31 18:09:18 +00:00
type="submit"/>
</form>
</div>
<label class="btn" for="email-submit">
2018-07-31 18:09:18 +00:00
${state.translate('signInContinueButton')}
</label>
</div>
`;
2018-08-03 19:24:41 +00:00
function submitEmail(event) {
event.preventDefault();
const el = document.getElementById('email-input');
const email = el.value;
if (email) {
// just check if it's the right shape
const a = email.split('@');
if (a.length === 2 && a.every(s => s.length > 0)) {
return emit('login', email);
}
}
el.value = '';
2018-08-03 19:24:41 +00:00
}
2018-07-31 18:09:18 +00:00
};