File size: 950 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import { Button } from '@automattic/components';
import clsx from 'clsx';
import { localize } from 'i18n-calypso';
import { omit } from 'lodash';
import { Component, Children } from 'react';
import './style.scss';
class FormButton extends Component {
static defaultProps = {
isSubmitting: false,
isPrimary: true,
type: 'submit',
};
getDefaultButtonAction = () => {
return this.props.isSubmitting
? this.props.translate( 'Saving…' )
: this.props.translate( 'Save Settings' );
};
render() {
const { children, className, isPrimary, ...props } = this.props;
const buttonClasses = clsx( className, 'form-button' );
return (
<Button
{ ...omit( props, [ 'isSubmitting', 'moment', 'numberFormat', 'translate' ] ) }
primary={ isPrimary }
className={ buttonClasses }
>
{ Children.count( children ) ? children : this.getDefaultButtonAction() }
</Button>
);
}
}
export default localize( FormButton );
|