Skip to content

Commit eb0b60f

Browse files
fkKyleAMathews
authored andcommitted
[www] Fix email-capture-form cross browser issues (#3553)
* pull shared <input>/<button> styles into constant * add default background color * add placeholder styles * use Futura instead of Spectral for form inputs* help Safari rendering <button> and <input> at equal height (tested in v11.0.2) * add focus styles * add focus styles to CtaButton
1 parent f76fbe0 commit eb0b60f

File tree

2 files changed

+47
-10
lines changed

2 files changed

+47
-10
lines changed

www/src/components/cta-button.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,20 @@ const CtaButton = ({ to, overrideCSS, children }) => (
3333
fontWeight: `normal`,
3434
backgroundColor: `transparent`,
3535
backgroundSize: `30px 30px`,
36-
transiton: `all .15s ease-out`,
37-
":hover": {
36+
transition: `all ${presets.animation.speedDefault} ${
37+
presets.animation.curveDefault
38+
}`,
39+
":hover, &:focus": {
3840
backgroundSize: `30px 30px`,
3941
backgroundColor: presets.brand,
4042
backgroundImage: `linear-gradient(45deg, rgba(0,0,0, 0.1) 25%, transparent 25%, transparent 50%, rgba(0,0,0, 0.1) 50%, rgba(0,0,0, 0.1) 75%, transparent 75%, transparent)`,
4143
color: `#fff`,
4244
animation: `${stripeAnimation} 2.8s linear infinite`,
4345
},
46+
":focus": {
47+
outline: 0,
48+
boxShadow: `0 0 0 0.2rem rgba(${presets.shadowColor}, .25)`,
49+
},
4450
":after": {
4551
content: ``,
4652
display: `block`,

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

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react"
2-
import { rhythm } from "../utils/typography"
2+
import { rhythm, options } from "../utils/typography"
33
import presets from "../utils/presets"
44
import jsonp from "jsonp"
55
import { validate } from "email-validator"
@@ -10,6 +10,23 @@ let stripeAnimation = css.keyframes({
1010
"100%": { backgroundPosition: `30px 60px` },
1111
})
1212

13+
const formInputDefaultStyles = {
14+
backgroundColor: `#fff`,
15+
border: `1px solid ${presets.lightPurple}`,
16+
borderRadius: presets.radius,
17+
color: presets.bodyColor,
18+
fontFamily: options.headerFontFamily.join(`,`),
19+
padding: rhythm(1 / 2),
20+
verticalAlign: `middle`,
21+
transition: `all ${presets.animation.speedDefault} ${
22+
presets.animation.curveDefault
23+
}`,
24+
"::placeholder": {
25+
color: presets.brandLight,
26+
opacity: 1,
27+
},
28+
}
29+
1330
// Mailchimp endpoint
1431
// From: https://us17.admin.mailchimp.com/lists/integration/embeddedcode?id=XXXXXX
1532
// Where `XXXXXX` is the MC list ID
@@ -117,27 +134,41 @@ class EmailCaptureForm extends React.Component {
117134
placeholder="[email protected]"
118135
onChange={this._handleEmailChange}
119136
css={{
120-
padding: rhythm(1 / 2),
137+
...formInputDefaultStyles,
121138
width: `250px`,
122-
color: presets.bodyColor,
139+
":focus": {
140+
color: presets.bodyColor,
141+
borderColor: presets.brand,
142+
outline: 0,
143+
boxShadow: `0 0 0 0.2rem rgba(${
144+
presets.shadowColor
145+
}, .25)`,
146+
},
123147
}}
124148
/>
125149
<button
126150
type="submit"
127151
onClick={this._handleFormSubmit}
128152
css={{
129-
borderRadius: `2px`,
130-
border: `1px solid ${presets.brand}`,
153+
...formInputDefaultStyles,
154+
borderColor: presets.brand,
155+
color: presets.brand,
131156
cursor: `pointer`,
132-
padding: rhythm(1 / 2),
133-
margin: `${rhythm(1 / 2)} 0 0 ${rhythm(1 / 2)}`,
134-
":hover": {
157+
fontWeight: `bold`,
158+
marginLeft: rhythm(1 / 2),
159+
":hover, &:focus": {
135160
backgroundSize: `30px 30px`,
136161
backgroundColor: presets.brand,
137162
backgroundImage: `linear-gradient(45deg, rgba(0,0,0, 0.1) 25%, transparent 25%, transparent 50%, rgba(0,0,0, 0.1) 50%, rgba(0,0,0, 0.1) 75%, transparent 75%, transparent)`,
138163
color: `#fff`,
139164
animation: `${stripeAnimation} 2.8s linear infinite`,
140165
},
166+
":focus": {
167+
outline: 0,
168+
boxShadow: `0 0 0 0.2rem rgba(${
169+
presets.shadowColor
170+
},.25)`,
171+
},
141172
}}
142173
>
143174
Subscribe

0 commit comments

Comments
 (0)