Replace Mailchimp's 140KB JS

This commit is contained in:
Daniel Vassallo
2019-09-30 16:58:39 -07:00
parent 0f90cdc44b
commit 60f5afd76e
19 changed files with 9475 additions and 1681 deletions

1
src/footer.html Normal file
View File

@@ -0,0 +1 @@
<div class="font-sans tracking-tight my-10 text-xs">Copyright © 2019 Encrypted Development LLC</div>

BIN
src/img/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

141
src/index.html Normal file
View File

@@ -0,0 +1,141 @@
<!doctype html>
<html lang="en">
<head>
<title>Userbase</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
</head>
<body class="pb-10">
<div class="container mx-auto text-center max-w-2xl px-4 text-blackish" style="font-size: 16px">
<div class="my-10">
<div class="flex justify-center">
<img class="w-32 h-32" src="./img/icon.png">
</div>
<h1 class="font-black text-6xl leading-none tracking-tight font-logo">Userbase</h1>
<h2 class="text-2xl leading-tight mt-1 tracking-tight">You won't believe it's not a database!</h2>
</div>
<hr>
<div class="my-10">
<h3 class="font-black text-3xl tracking-tight" id="what-is-userbase">What is Userbase?</h3>
<div class="text-left font-sans tracking-tight">
<p class="mb-4">Userbase is like a database, but purpose-built for web app user data. It's accessible directly
from the browser through a very simple JavaScript SDK.</p>
</div>
</div>
<hr>
<div class="my-10">
<h3 class="font-black text-3xl tracking-tight" id="why-not-a-database">Why isn't it a database?</h3>
<div class="text-left font-sans tracking-tight">
<p class="mb-4">With Userbase you can durably store, update, delete, and query user data. But that's where the
similarities with traditional databases end.</p>
<h4 class="font-bold text-xl tracking-tight" id="zero-management">Zero management</h4>
<p class="mb-4">Unlike a real database, all Userbase queries run in the browser, with the server-side acting as
a dumb data store. There's no database to manage and worry about.
</p>
<h4 class="font-bold text-xl tracking-tight" id="user-management">Built-in user management</h4>
<p class="mb-4">Unlike a real database, Userbase takes care of your user accounts. It comes with built-in APIs
for user signups, logins, and access control.</p>
<h4 class="font-bold text-xl tracking-tight" id="e2ee">End-to-end encrypted</h4>
<p class="mb-4">Unlike a real database, Userbase won't show you what your users store in your web app.</p>
<p class="mb-4"></p>Wait, what!? — Yes, that's a feature — maybe the most important feature. Userbase spares you
from the liability of handling user data by encrypting everything in the browser, using keys that always stay
with the user.</p>
</div>
</div>
<hr>
<div class="my-10">
<h3 class="font-black text-3xl tracking-tight" id="what-would-i-use-it">When would I use it?</h3>
<div class="text-left font-sans tracking-tight">
<p class="mb-4">If you're building a web app, you will likely need a database. Userbase can substitute your
database... </p>
<ul class="list-disc mb-4 ml-8">
<li>If you want to build a web app without writing any backend code.</li>
<li>If you never want to see your users' data.</li>
<li>If you're tired of dealing with databases.</li>
<li>If you want to radically simplify your GDPR compliance.</li>
<li>And if you want to keep things really simple.</li>
</ul>
</div>
</div>
<hr>
<div class="my-10">
<h3 class="font-black text-3xl tracking-tight" id="how-do-i-start">How do I start?</h3>
<div class="text-left font-sans tracking-tight">
<p class="mb-4">Userbase will be available around mid-December 2019.</p>
<h4 class="font-bold text-xl tracking-tight" id="oss">Open source</h4>
<p class="mb-4">Userbase is being developed in the open, and is <a
href="https://github.com/encrypted-dev/userbase" target="_blank" rel="noopener noreferrer">100%
open-source</a>, MIT licensed. You can modify and extend the backend to your liking, and run it yourself in
your AWS account, always under your control.</p>
<h4 class="font-bold text-xl tracking-tight" id="saas">As a service</h4>
<p class="mb-4">Or for just $39/month you can go fully serverless, backendless, databaseless, and AWSless!</p>
<ul class="list-disc mb-4 ml-8">
<li>Unlimited web apps.</li>
<li>Unlimited users.</li>
<li>1 GB storage included.</li>
<li>Unlimited extra storage at $1/month per GB.</li>
<li>All features included.</li>
</ul>
<h4 class="font-bold text-xl tracking-tight" id="mailing-list">Join the waiting list</h4>
<p class="mb-4">Enter your email to receive occasional updates about Userbase. No spam ever.</p>
</div>
<form
action="https://danielvassallo.us20.list-manage.com/subscribe/post?u=e3b0fd293a0e6d7ea0080fafe&amp;id=d0aae9dd3e"
method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate"
target="_blank">
<div class="mc-field-group">
<input type="email" value="" name="EMAIL" id="mce-EMAIL" required autocorrect="off" spellcheck="false"
placeholder="Email address"
class="font-light text-sm h-10 p-2 border border-gray-500 outline-none w-64 rounded font-mono my-4 inline-block">
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe"
class="rounded-lg w-40 h-10 bg-yellowish font-bold cursor-pointer text-gray-900 inline-block relative"
style="top: 1px;">
</div>
<div class="mc-status" class="hidden"></div>
<div style="position: absolute; left: -5000px;" aria-hidden="true">
<input type="text" name="b_e3b0fd293a0e6d7ea0080fafe_d0aae9dd3e" tabindex="-1" value=""></div>
<div class="clear"></div>
</form>
</div>
<hr>
<div class="my-10">
<h3 class="font-black text-3xl tracking-tight" id="about">Who's behind this?</h3>
<div class="text-left font-sans tracking-tight">
<p class="mb-4">This product is the work of <a href="https://twitter.com/dvassallo" target="_blank"
rel="noopener noreferrer">Daniel Vassallo</a> and <a href="https://twitter.com/justinberman95"
target="_blank" rel="noopener noreferrer">Justin Berman</a>. We're a small independent business, structured
to be lean, profitable, and sustainable. We're here for the long haul.
</p>
<p class="mb-4">If you have any questions, or there's anything we can do to help you with your web app, please
<a href="mailto:daniel@encrypted.dev">get in touch</a>. Thank you!</p>
</div>
</div>
<hr>
${require('./footer.html')}
</div>
</body>
</html>

67
src/index.js Normal file
View File

@@ -0,0 +1,67 @@
import './style.css'
var serialize = function (form) {
var serialized = ''
for (var i = 0; i < form.elements.length; i++) {
var field = form.elements[i]
if (!field.name || field.disabled || field.type === 'file' || field.type === 'reset' || field.type === 'submit' || field.type === 'button') continue
if ((field.type !== 'checkbox' && field.type !== 'radio') || field.checked) {
serialized += '&' + encodeURIComponent(field.name) + "=" + encodeURIComponent(field.value)
}
}
return serialized;
}
window.displayMailChimpStatus = function (data) {
if (!data.result || !data.msg) return
var mcStatus = document.querySelector('.mc-status')
if (!mcStatus) return
mcStatus.innerHTML = data.msg
//mcStatus.addAttribute('tabindex', '-1')
mcStatus.focus()
mcStatus.classList.remove('hidden')
if (data.result === 'error') {
mcStatus.classList.remove('mc-success')
mcStatus.classList.add('mc-error')
return;
}
mcStatus.classList.remove('mc-error');
mcStatus.classList.add('mc-success')
}
var submitMailChimpForm = function (form) {
var url = form.getAttribute('action')
url = url.replace('/post?u=', '/post-json?u=')
url += serialize(form) + '&c=displayMailChimpStatus'
var script = window.document.createElement('script')
script.src = url
var ref = window.document.getElementsByTagName('script')[0]
ref.parentNode.insertBefore(script, ref)
script.onload = function () {
this.remove()
}
}
document.addEventListener('submit', function (event) {
if (!event.target.classList.contains('validate')) return
event.preventDefault()
submitMailChimpForm(event.target)
}, false)

25
src/style.css Normal file
View File

@@ -0,0 +1,25 @@
@tailwind base;
@tailwind components;
a {
@apply underline;
}
a:hover {
@apply text-orange-700;
}
.mc-status:focus {
@apply outline-none
}
.mc-success {
@apply text-green-600;
}
.mc-error {
@apply text-red-600;
}
@tailwind utilities;