Skip to content

Commit f26f438

Browse files
wuweiweiwum-allanson
authored andcommitted
[www] Adding a simple newsletter page (#6359)
* simple newsletter page * enabling email subscription. cleaning up
1 parent 8410691 commit f26f438

File tree

2 files changed

+65
-6
lines changed

2 files changed

+65
-6
lines changed

www/src/components/email-capture-form.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,28 +76,31 @@ class EmailCaptureForm extends React.Component {
7676
{
7777
status: `sending`,
7878
msg: null,
79-
}
79+
},
8080
// setState callback (subscribe email to MC)
81-
// this._postEmailToMailchimp(this.state.email, {
82-
// pathname: document.location.pathname,
83-
// })
81+
this._postEmailToMailchimp(this.state.email, {
82+
pathname: document.location.pathname,
83+
})
8484
)
8585
}
8686

8787
render() {
88+
const { signupMessage, confirmMessage, containerCss } = this.props
89+
8890
return (
8991
<div
9092
css={{
9193
borderTop: `2px solid ${colors.lilac}`,
9294
marginTop: rhythm(3),
9395
paddingTop: `${rhythm(1)}`,
96+
...containerCss,
9497
}}
9598
>
9699
{this.state.status === `success` ? (
97-
<div>Thank you! Youʼll receive your first email shortly.</div>
100+
<div>{confirmMessage}</div>
98101
) : (
99102
<div>
100-
<p>Enjoyed this post? Receive the next one in your inbox!</p>
103+
<p>{signupMessage}</p>
101104
<form
102105
id="email-capture"
103106
method="post"
@@ -160,4 +163,10 @@ class EmailCaptureForm extends React.Component {
160163
}
161164
}
162165

166+
EmailCaptureForm.defaultProps = {
167+
signupMessage: "Enjoyed this post? Receive the next one in your inbox!",
168+
confirmMessage: "Thank you! Youʼll receive your first email shortly.",
169+
containerCss: {},
170+
}
171+
163172
export default EmailCaptureForm

www/src/pages/newsletter.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React, { Component } from "react"
2+
import Helmet from "react-helmet"
3+
import { rhythm } from "../utils/typography"
4+
import { colors } from "../utils/presets"
5+
6+
import Layout from "../components/layout"
7+
import Container from "../components/container"
8+
import EmailCaptureForm from "../components/email-capture-form"
9+
10+
class NewsLetter extends Component {
11+
render() {
12+
const { location, data } = this.props
13+
14+
return (
15+
<Layout location={location}>
16+
<Helmet>
17+
<title>Newsletter</title>
18+
</Helmet>
19+
<Container
20+
hasSideBar={false}
21+
css={{
22+
display: "flex",
23+
flexDirection: "column",
24+
}}
25+
>
26+
<h1 id="introduction" style={{ marginTop: 0 }}>
27+
Newsletter
28+
</h1>
29+
<div>
30+
Sign up for the Gatsby newsletter to keep up with the latest from
31+
the Gatsby community! Hear about new features, tips & tricks, and
32+
what people are building.
33+
</div>
34+
35+
<EmailCaptureForm
36+
signupMessage="Sign up for the Gatsby Newsletter"
37+
confirmMessage="Success! You have been subscribed to the Gatsby newsletter. Expect to see a newsletter in your inbox each Wednesday (or the equivalent of US Wednesday in your time zone)!"
38+
containerCss={{
39+
marginTop: rhythm(1),
40+
paddingTop: rhythm(1 / 2),
41+
borderTop: `2px solid ${colors.lilac}`,
42+
}}
43+
/>
44+
</Container>
45+
</Layout>
46+
)
47+
}
48+
}
49+
50+
export default NewsLetter

0 commit comments

Comments
 (0)