gab-social/app/javascript/gabsocial/components/form.js

37 lines
671 B
JavaScript
Raw Normal View History

import React from 'react'
import PropTypes from 'prop-types'
2020-04-28 06:33:58 +01:00
import Text from './text'
class Form extends React.PureComponent {
2020-04-28 06:33:58 +01:00
render() {
const {
children,
errorMessage,
onSubmit,
} = this.props
return (
<form onSubmit={onSubmit} className={_s.d}>
2020-04-28 06:33:58 +01:00
{
!!errorMessage &&
<Text color='danger' className={_s.my10}>
{errorMessage}
</Text>
}
<div className={_s.d}>
2020-04-28 06:33:58 +01:00
{children}
</div>
</form>
)
}
}
Form.propTypes = {
children: PropTypes.any,
errorMessage: PropTypes.string,
onSubmit: PropTypes.func.isRequired,
}
export default Form