2018-09-24 19:01:39 +00:00
|
|
|
/* 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');
|
2018-09-24 19:01:39 +00:00
|
|
|
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>
|
2018-09-24 19:01:39 +00:00
|
|
|
<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
|
2018-09-24 19:01:39 +00:00
|
|
|
id="email-input"
|
2018-07-31 18:09:18 +00:00
|
|
|
type="text"
|
|
|
|
class="signIn__emailInput"
|
|
|
|
placeholder=${state.translate('emailEntryPlaceholder')}/>
|
|
|
|
<input
|
|
|
|
class='noDisplay'
|
2018-09-24 19:01:39 +00:00
|
|
|
id="email-submit"
|
2018-07-31 18:09:18 +00:00
|
|
|
type="submit"/>
|
|
|
|
</form>
|
|
|
|
</div>
|
2018-09-24 19:01:39 +00:00
|
|
|
<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();
|
2018-09-24 19:01:39 +00:00
|
|
|
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
|
|
|
};
|