diff --git a/components/EmailSubscribe.js b/components/EmailSubscribe.js deleted file mode 100644 index 8edddea..0000000 --- a/components/EmailSubscribe.js +++ /dev/null @@ -1,173 +0,0 @@ -import React from 'react' -import MailchimpSubscribe from 'react-mailchimp-subscribe' -import { validate } from 'email-validator' -import { useKeyboardListener } from 'actionsack' - -import Input from './Input' -import Button from './Button' -import { COLORS } from '../lib/constants' - -const Error = ({ message = 'something went wrong' }) => { - if ( - message.indexOf && - message.indexOf('The domain portion of the email address is invalid') > -1 - ) { - message = `Oh no, that's not a valid email!` - } - if (message.indexOf && message.indexOf('is already subscribed')) { - message = message.split(' - {message} - - - ) -} - -const Form = ({ message, subscribe, error }) => { - const [email, setEmail] = React.useState('') - const [showError, setShowError] = React.useState(true) - const disabled = !validate(email) - return ( -
{ - e.preventDefault() - subscribe({ EMAIL: email }) - }} - > - { - setEmail(e.target.value) - setShowError(false) - }} - /> - - {error && showError && } - - - ) -} - -const EmailSubscribe = () => { - const [open, setOpen] = React.useState(false) - - useKeyboardListener('Escape', () => setOpen(false)) - - if (!process.env.NEXT_PUBLIC_MAILCHIMP_URL) { - return null - } - - return ( -
- - {open && ( - { - const success = status === 'success' - const loading = status === 'sending' - const error = status === 'error' - return ( -
- {loading || success ? ( - {loading ? 'loading...' : 'subscribed!'} - ) : ( -
- )} -
- ) - }} - /> - )} - -
- ) -} - -export default EmailSubscribe diff --git a/components/Footer.js b/components/Footer.js index 2bb47a6..d30b53d 100644 --- a/components/Footer.js +++ b/components/Footer.js @@ -1,13 +1,8 @@ import React from 'react' import Link from 'next/link' -import dynamic from 'next/dynamic' import { COLORS } from '../lib/constants' -const EmailSubscribe = dynamic(() => import('./EmailSubscribe'), { - loading: () => null, -}) - const Footer = () => (