Created
April 24, 2018 06:30
-
-
Save Jaikant/eeb9f15ffcadfc9024f6c94a97e2e365 to your computer and use it in GitHub Desktop.
Formspree with React/Gatsby Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-undef, react/prop-types */ | |
import React from 'react'; | |
import { css } from 'react-emotion'; | |
import { Box, Flex } from '../../components/Layout'; | |
import colors from '../../utils/colors'; | |
import ButtonPrimary from '../../components/Buttons'; | |
const input = css` | |
display: block; | |
box-sizing: border-box; | |
padding: 10px 16px; | |
width: 100%; | |
outline: 0; | |
border: 1px solid #ccc; | |
border-radius: 0; | |
background: #fff; | |
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); | |
color: #616161; | |
font-size: 18px; | |
line-height: 1.3333333; | |
transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; | |
& :focus { | |
border-color: ${colors.primary}; | |
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), | |
0 0 8px rgba(59, 89, 152, 0.6); | |
} | |
`; | |
const label = css` | |
display: inline-block; | |
text-align: left; | |
margin-bottom: 16px; | |
width: 100%; | |
`; | |
const ContactForm = () => ( | |
<Flex> | |
<form | |
css="max-width: 500px;" | |
action="//formspree.io/jaikant@gmail.com" | |
method="POST" | |
> | |
<label className={label} htmlFor="name"> | |
<input | |
className={input} | |
type="text" | |
placeholder="Your Name" | |
name="name" | |
/> | |
</label> | |
<label className={label} htmlFor="_replyto"> | |
<input | |
className={input} | |
type="email" | |
placeholder="Your email ... example@domain.com" | |
name="_replyto" | |
/> | |
</label> | |
<label className={label} htmlFor="message"> | |
<textarea | |
className={input} | |
name="message" | |
rows="3" | |
placeholder="Your Message" | |
/> | |
</label> | |
<input | |
type="hidden" | |
name="_subject" | |
value="Message via http://domain.com" | |
/> | |
<ButtonPrimary css="margin-bottom: 32px;" type="submit"> | |
Submit | |
</ButtonPrimary> | |
</form> | |
</Flex> | |
); | |
const Contact = () => { | |
return ( | |
<Box bg={colors.primary}> | |
<Box css="margin: 2.5em"> | |
<ContactForm /> | |
</Box> | |
</Box> | |
); | |
}; | |
export default Contact; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how does
<ButtonPrimary />
look like?