Skip to content

Instantly share code, notes, and snippets.

@yantakus
Created March 2, 2017 17:03
Show Gist options
  • Save yantakus/c22894d27518d8d7ecf5bf055133d794 to your computer and use it in GitHub Desktop.
Save yantakus/c22894d27518d8d7ecf5bf055133d794 to your computer and use it in GitHub Desktop.
// @flow
import React from 'react'
import { Button } from 'react-formal'
import Spinner from 'components/Spinner'
type Props = {
messages: Object,
hint: string | HTMLElement,
text: string | HTMLElement,
isLoading: boolean,
disabled: boolean
}
const AuthButton = ({ messages, hint, text, isLoading, disabled }: Props) => {
const content = <div>{hint && <span className='button__hint'>{hint} </span>}{text}</div>
const hasValidationErrors = messages && !!Object.keys(messages).length
return (
<Button
className='button large expanded'
type='submit'
disabled={disabled || hasValidationErrors}
>{isLoading ? <Spinner /> : content}</Button>
)
}
export default AuthButton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment