remove EmailSubscribe

main
Mike Fix 3 years ago
parent 2a7f3148c7
commit 96325691ed
No known key found for this signature in database
GPG Key ID: 1D85E862314CA79F

@ -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('<a')[0] // cut off 'Click to subscribe link'
}
return (
<span>
{message}
<style jsx>{`
span {
position: absolute;
bottom: 2.75rem;
font-size: 12px;
color: ${COLORS.RED};
text-align: left;
}
`}</style>
</span>
)
}
const Form = ({ message, subscribe, error }) => {
const [email, setEmail] = React.useState('')
const [showError, setShowError] = React.useState(true)
const disabled = !validate(email)
return (
<form
className="subscribe-form"
onSubmit={e => {
e.preventDefault()
subscribe({ EMAIL: email })
}}
>
<Input
type="email"
name="email"
placeholder="Email address"
onChange={e => {
setEmail(e.target.value)
setShowError(false)
}}
/>
<Button hoverBackground={COLORS.BLACK} disabled={disabled}>
<span>subscribe</span>
</Button>
{error && showError && <Error message={message} />}
<style jsx>
{`
span {
font-size: 14px;
}
form {
display: flex;
}
:global(button) > span {
color: ${disabled ? 'rgba(255, 255, 255, 0.5)' : '#fff'};
}
form > :global(input) {
text-align: left;
margin-right: 1rem;
font-size: 14px;
}
form > :global(input:-webkit-autofill) {
background-clip: content-box;
-webkit-text-fill-color: #fff;
-webkit-box-shadow: 0 0 0px 1000px ${COLORS.BLACK} inset;
}
form > :global(input:-webkit-autofill::selection) {
-webkit-text-fill-color: #000;
-webkit-box-shadow: 0 0 0px 1000px #fff inset;
}
`}
</style>
</form>
)
}
const EmailSubscribe = () => {
const [open, setOpen] = React.useState(false)
useKeyboardListener('Escape', () => setOpen(false))
if (!process.env.NEXT_PUBLIC_MAILCHIMP_URL) {
return null
}
return (
<div className="container link">
<button
onClick={e => {
e.preventDefault()
setOpen(true)
}}
>
mailing list
</button>
{open && (
<MailchimpSubscribe
url={process.env.NEXT_PUBLIC_MAILCHIMP_URL}
render={({ status, ...props }) => {
const success = status === 'success'
const loading = status === 'sending'
const error = status === 'error'
return (
<div className="subscribe-container">
{loading || success ? (
<span>{loading ? 'loading...' : 'subscribed!'}</span>
) : (
<Form {...props} error={error} />
)}
</div>
)
}}
/>
)}
<style jsx>
{`
button {
padding: 0;
border: none;
color: white;
background: none;
font-size: 100%;
cursor: pointer;
visibility: ${open ? 'hidden' : 'visible'};
}
button:hover {
color: ${COLORS.PRIMARY};
}
span {
font-size: 14px;
}
.container {
display: inline-block;
position: relative;
${open ? 'background: none; margin-top: -2px;' : ''};
margin-right: 1rem;
padding-bottom: 2px;
}
.subscribe-container {
position: absolute;
top: -0.5rem;
justify-content: space-between;
border: 1px solid #fff;
border-radius: 3px;
padding: 0.5rem 1rem;
width: 15rem;
text-align: center;
/* TODO remove these styles after fixing footer */
background: ${COLORS.BLACK};
z-index: 3;
}
`}
</style>
</div>
)
}
export default EmailSubscribe

@ -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 = () => (
<footer role="contentinfo" className="mt3">
<nav className="mt3">
@ -25,7 +20,6 @@ const Footer = () => (
<a className="link" href="/privacy">
privacy
</a>
<EmailSubscribe />
<a className="link" href="/offsets">
offsets
</a>

@ -62,7 +62,6 @@
"react-color": "^2.19.3",
"react-dom": "^17.0.2",
"react-image-crop": "^6.0.16",
"react-mailchimp-subscribe": "^2.1.3",
"tohash": "^1.0.2"
},
"devDependencies": {

@ -3462,7 +3462,7 @@ dayjs@^1.10.4:
resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.10.4.tgz#8e544a9b8683f61783f570980a8a80eaf54ab1e2"
integrity sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw==
debug@2.6.9, debug@^2.1.3, debug@^2.6.9:
debug@2.6.9, debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==
@ -5679,13 +5679,6 @@ jsonfile@^6.0.1:
optionalDependencies:
graceful-fs "^4.1.6"
jsonp@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/jsonp/-/jsonp-0.2.1.tgz#a65b4fa0f10bda719a05441ea7b94c55f3e15bae"
integrity sha1-pltPoPEL2nGaBUQep7lMVfPhW64=
dependencies:
debug "^2.1.3"
jsonpointer@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-5.0.0.tgz#f802669a524ec4805fa7389eadbc9921d5dc8072"
@ -7033,15 +7026,6 @@ react-is@^17.0.2:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==
react-mailchimp-subscribe@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/react-mailchimp-subscribe/-/react-mailchimp-subscribe-2.1.3.tgz#2f195f20b98c9be9608fac95d1f4f5bcb2d81929"
integrity sha512-ZRuPZMnX/9pHQLnAQavsgB5xIF+gNqjNCCq1vvTs23cn+93W2oOp17qjg3LpDBEt1HJi6IHXMwpKXn0taY8FHw==
dependencies:
jsonp "^0.2.1"
prop-types "^15.5.10"
to-querystring "^1.0.4"
react@^17.0.2:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react/-/react-17.0.2.tgz#d0b5cc516d29eb3eee383f75b62864cfb6800037"
@ -8063,11 +8047,6 @@ to-fast-properties@^2.0.0:
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=
to-querystring@^1.0.4:
version "1.1.0"
resolved "https://registry.yarnpkg.com/to-querystring/-/to-querystring-1.1.0.tgz#31efbcebb332bcb2522de36129b4234179399fbd"
integrity sha512-nlYTDlLrE9+JJlEcoqEvOytgReSG4z8+hdHeSO8+WF4VLzF7sY5KFyIGvCEWJc0bROdMJsyhOnbPEb5R2LOI8A==
to-readable-stream@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/to-readable-stream/-/to-readable-stream-1.0.0.tgz#ce0aa0c2f3df6adf852efb404a783e77c0475771"

Loading…
Cancel
Save