2018-10-25 04:07:10 +02:00
|
|
|
const html = require('choo/html');
|
2019-03-01 21:56:10 +01:00
|
|
|
const assets = require('../../common/assets');
|
2020-07-25 07:04:42 +02:00
|
|
|
const { bytes } = require('../utils');
|
2019-02-12 20:50:06 +01:00
|
|
|
const { canceledSignup, submittedSignup } = require('../metrics');
|
2018-10-25 04:07:10 +02:00
|
|
|
|
2019-02-12 20:50:06 +01:00
|
|
|
module.exports = function(trigger) {
|
2018-10-25 04:07:10 +02:00
|
|
|
return function(state, emit, close) {
|
2019-02-26 19:39:50 +01:00
|
|
|
const DAYS = Math.floor(state.LIMITS.MAX_EXPIRE_SECONDS / 86400);
|
2019-02-08 18:44:21 +01:00
|
|
|
let submitting = false;
|
2018-10-25 04:07:10 +02:00
|
|
|
return html`
|
2019-03-01 21:56:10 +01:00
|
|
|
<send-signup-dialog
|
2020-07-25 07:04:42 +02:00
|
|
|
class="flex flex-col lg:flex-row justify-center my-16 md:my-0 px-8 md:px-24 w-full h-full"
|
2019-03-01 21:56:10 +01:00
|
|
|
>
|
2019-05-30 04:22:03 +02:00
|
|
|
<img src="${assets.get('master-logo.svg')}" class="h-16 mt-1 mb-4" />
|
2019-03-02 01:19:55 +01:00
|
|
|
<section
|
2019-06-14 20:30:43 +02:00
|
|
|
class="flex flex-col flex-shrink-0 self-center lg:mx-6 lg:max-w-xs"
|
2019-03-02 01:19:55 +01:00
|
|
|
>
|
2019-06-14 20:30:43 +02:00
|
|
|
<h1 class="text-3xl font-bold text-center lg:text-left">
|
2019-03-02 01:19:55 +01:00
|
|
|
${state.translate('accountBenefitTitle')}
|
|
|
|
</h1>
|
|
|
|
<ul
|
2019-09-09 19:34:55 +02:00
|
|
|
class="leading-normal list-disc text-grey-80 my-2 mt-4 pl-4 md:self-center dark:text-grey-40"
|
2019-03-02 01:19:55 +01:00
|
|
|
>
|
2019-03-01 21:56:10 +01:00
|
|
|
<li>
|
|
|
|
${state.translate('accountBenefitLargeFiles', {
|
|
|
|
size: bytes(state.LIMITS.MAX_FILE_SIZE)
|
|
|
|
})}
|
|
|
|
</li>
|
2019-03-04 23:13:18 +01:00
|
|
|
<li>${state.translate('accountBenefitDownloadCount')}</li>
|
2019-03-01 21:56:10 +01:00
|
|
|
<li>
|
2019-03-04 23:13:18 +01:00
|
|
|
${state.translate('accountBenefitTimeLimit', { count: DAYS })}
|
2019-03-01 21:56:10 +01:00
|
|
|
</li>
|
|
|
|
<li>${state.translate('accountBenefitSync')}</li>
|
|
|
|
</ul>
|
|
|
|
</section>
|
2019-03-02 01:19:55 +01:00
|
|
|
<section
|
|
|
|
class="flex flex-col flex-grow m-4 md:self-center md:w-128 lg:max-w-xs"
|
|
|
|
>
|
2019-03-01 21:56:10 +01:00
|
|
|
<form onsubmit=${submitEmail} data-no-csrf>
|
|
|
|
<input
|
|
|
|
id="email-input"
|
2019-03-03 02:05:58 +01:00
|
|
|
type="email"
|
2020-07-25 07:04:42 +02:00
|
|
|
class="hidden lg:block border rounded-lg w-full px-2 py-1 h-12 mb-3 text-lg text-grey-70 leading-loose dark:bg-grey-80 dark:text-white"
|
2019-03-04 23:13:18 +01:00
|
|
|
placeholder=${state.translate('emailPlaceholder')}
|
2019-03-01 21:56:10 +01:00
|
|
|
/>
|
|
|
|
<input
|
2019-06-14 20:30:43 +02:00
|
|
|
class="btn rounded-lg w-full flex flex-shrink-0 items-center justify-center"
|
2019-05-01 18:39:29 +02:00
|
|
|
value="${state.translate('signInOnlyButton')}"
|
|
|
|
title="${state.translate('signInOnlyButton')}"
|
2019-03-01 21:56:10 +01:00
|
|
|
id="email-submit"
|
|
|
|
type="submit"
|
|
|
|
/>
|
|
|
|
</form>
|
2020-07-25 03:11:50 +02:00
|
|
|
${state.user.loginRequired
|
|
|
|
? ''
|
|
|
|
: html`
|
|
|
|
<button
|
|
|
|
class="my-3 link-blue font-medium"
|
|
|
|
title="${state.translate('deletePopupCancel')}"
|
|
|
|
onclick=${cancel}
|
|
|
|
>
|
|
|
|
${state.translate('deletePopupCancel')}
|
|
|
|
</button>
|
|
|
|
`}
|
2019-03-01 21:56:10 +01:00
|
|
|
</section>
|
|
|
|
</send-signup-dialog>
|
|
|
|
`;
|
2018-10-25 04:07:10 +02:00
|
|
|
|
2018-12-21 20:40:52 +01:00
|
|
|
function emailish(str) {
|
|
|
|
if (!str) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// just check if it's the right shape
|
|
|
|
const a = str.split('@');
|
|
|
|
return a.length === 2 && a.every(s => s.length > 0);
|
|
|
|
}
|
|
|
|
|
2019-02-12 20:50:06 +01:00
|
|
|
function cancel(event) {
|
|
|
|
canceledSignup({ trigger });
|
|
|
|
close(event);
|
|
|
|
}
|
|
|
|
|
2018-10-25 04:07:10 +02:00
|
|
|
function submitEmail(event) {
|
|
|
|
event.preventDefault();
|
2019-02-08 18:44:21 +01:00
|
|
|
if (submitting) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
submitting = true;
|
|
|
|
|
2018-10-25 04:07:10 +02:00
|
|
|
const el = document.getElementById('email-input');
|
|
|
|
const email = el.value;
|
2019-02-12 20:50:06 +01:00
|
|
|
submittedSignup({ trigger });
|
2018-12-21 20:40:52 +01:00
|
|
|
emit('login', emailish(email) ? email : null);
|
2018-10-25 04:07:10 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|