site/components/submit.js
Max Wofford 65e9ad5751 Invites on the slack form create multi-channel guests (#23)
* Invites on the slack form create multi-channel guests

* Use CORS only in production

* Open this boi UP

* Remove cors-anywhere

* Remove JSON parse

* Attempt boolean logic for teens

* Attempt to fix som form

* Attempt to fix form routing error

* Don't include post URL in form html

* Remove method from HTML

* Try persisting event

* Remove fetch imports

* Edit submitted button copy

* Add logging

* Fix teen field

Co-authored-by: Lachlan Campbell <lachlan@hackclub.com>
2020-06-18 08:01:21 -04:00

60 lines
1.1 KiB
JavaScript

import { Button } from 'theme-ui'
import theme from '../lib/theme'
const bg = {
default: {
bg: 'blue',
backgroundImage: theme.util.gradient('cyan', 'blue')
},
submitting: {
bg: 'blue',
backgroundImage: theme.util.gradient('cyan', 'blue')
},
success: {
bg: 'green',
backgroundImage: theme.util.gradient('green', 'cyan')
},
error: {
bg: 'orange',
backgroundImage: theme.util.gradient('orange', 'red'),
boxShadow: `0 0 0 1px ${theme.colors.white}, 0 0 0 4px ${theme.colors.primary}`
}
}
const submitting = {
...bg.default,
opacity: 0.5,
pointerEvents: 'none',
cursor: 'not-allowed'
}
const Submit = ({
status,
labels = {
default: 'Submit',
error: 'Error!',
success: 'Check your email!'
},
width = '100%',
sx,
...props
}) => (
<Button
as="button"
type="submit"
sx={{
py: 2,
px: 3,
mt: 3,
fontSize: 2,
width,
...(status === 'submitting' ? submitting : bg[status]),
...sx
}}
disabled={status === 'submitting'}
children={status === 'submitting' ? 'Submitting…' : labels[status]}
{...props}
/>
)
export default Submit