mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-02-04 15:23:39 +00:00
a4ec6f6139
* hide buttons during send loading state * fix transaction succeeded not clickable; provide error in action * move BroadcastStatusTransaction into 'libs/transaction' * use more succint Array.prototype.find * rename resetState -> resetTransaction * refactor and component componentDidUpdate logic * rename disabled -> generateDisabled; comment componentDidUpdate * add size to Spinner, use in ConfirmationModal; disable instead of hide buttons in Modal * fix flow not understanding that an object wouldn't be null in this case anyway. silly flow * various refactors; send entire balance working
59 lines
1.2 KiB
JavaScript
59 lines
1.2 KiB
JavaScript
// @flow
|
|
import React, { Component } from 'react';
|
|
import type { Element } from 'react';
|
|
|
|
const DEFAULT_BUTTON_TYPE = 'primary';
|
|
const DEFAULT_BUTTON_SIZE = 'lg';
|
|
|
|
import Spinner from './Spinner';
|
|
|
|
type ButtonType =
|
|
| 'default'
|
|
| 'primary'
|
|
| 'success'
|
|
| 'info'
|
|
| 'warning'
|
|
| 'danger';
|
|
type ButtonSize = 'lg' | 'sm' | 'xs';
|
|
|
|
type Props = {
|
|
onClick: () => any,
|
|
text: Element<*> | string,
|
|
loading?: boolean,
|
|
disabled?: boolean,
|
|
loadingText?: string,
|
|
size?: ButtonSize,
|
|
type?: ButtonType
|
|
};
|
|
|
|
export default class SimpleButton extends Component {
|
|
props: Props;
|
|
|
|
computedClass = () => {
|
|
return `btn btn-${this.props.size || DEFAULT_BUTTON_TYPE} btn-${this.props
|
|
.type || DEFAULT_BUTTON_SIZE}`;
|
|
};
|
|
|
|
render() {
|
|
let { loading, disabled, loadingText, text, onClick } = this.props;
|
|
|
|
return (
|
|
<div>
|
|
<button
|
|
onClick={onClick}
|
|
disabled={loading || disabled}
|
|
className={this.computedClass()}
|
|
>
|
|
{loading
|
|
? <div>
|
|
<Spinner /> {loadingText || text}
|
|
</div>
|
|
: <div>
|
|
{text}
|
|
</div>}
|
|
</button>
|
|
</div>
|
|
);
|
|
}
|
|
}
|