-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathSubscribeForm.js
95 lines (81 loc) · 2.11 KB
/
SubscribeForm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import React from "react";
import styled, { cx, css } from "react-emotion";
import theme from "../styles/theme";
const ACTION_URL =
"https://buttondown.email/api/emails/embed-subscribe/SurviveJS";
const Form = styled.form`
@media (min-width: ${theme.breakpoint.s}) {
display: flex;
flex-direction: row;
align-items: center;
}
`;
const baseStyle = css`
display: block;
width: 100%;
height: ${theme.form.size};
margin-bottom: ${theme.space.s};
padding: 0.6em 1em;
background-color: ${theme.color.background};
border: ${theme.border.width} solid ${theme.color.action};
border-radius: ${theme.form.size};
font-size: ${theme.fontSize.delta};
outline: none;
@media (min-width: ${theme.breakpoint.s}) {
width: auto;
}
`;
const inputStyle = css`
flex-grow: 1;
color: ${theme.color.base};
@media (min-width: ${theme.breakpoint.s}) {
border-right: 0;
border-radius: ${theme.form.size} 0 0 ${theme.form.size};
}
&:focus,
&:focus ~ input {
border-color: ${theme.color.actionDark};
}
`;
const Input = props => (
<input className={cx(baseStyle, inputStyle)} {...props} />
);
const buttonStyle = css`
letter-spacing: 0.05em;
font-weight: ${theme.fontWeight.fat};
color: ${theme.color.actionDark};
transition: background-color ${theme.transition.easing}
${theme.transition.speed},
color ${theme.transition.easing}
${theme.transition.speed};
@media (min-width: ${theme.breakpoint.s}) {
border-radius: 0 ${theme.form.size} ${theme.form.size} 0;
}
&:hover {
color: ${theme.color.actionLight};
background-color: ${theme.color.actionAlpha};
}
`;
const Button = props => (
<input
type="submit"
className={cx(baseStyle, buttonStyle)}
{...props}
/>
);
const SubscribeForm = () => {
return (
<Form action={ACTION_URL} method="post" target="_blank">
<Input
type="email"
placeholder="Email"
name="email"
id="bd-email"
required
/>
<input type="hidden" name="embed" value="1" />
<Button value="Subscribe" name="subscribe" />
</Form>
);
};
export default SubscribeForm;