diff --git a/common/components/NonceField.scss b/common/components/NonceField.scss new file mode 100644 index 00000000..4a17f91f --- /dev/null +++ b/common/components/NonceField.scss @@ -0,0 +1,27 @@ +.nonce { + &-input-wrapper { + position: relative; + } + &-refresh { + position: absolute; + right: 0; + top: 0; + border: none; + background: transparent; + padding: 0; + margin: 0 1rem; + height: 2.55rem; + opacity: 0.3; + transition: opacity 300ms; + > img { + height: 1.4rem; + } + &:hover { + opacity: 0.54; + } + &:active { + transition: opacity 120ms; + opacity: 1; + } + } +} diff --git a/common/components/NonceField.tsx b/common/components/NonceField.tsx index ffdd34aa..d8e7286d 100644 --- a/common/components/NonceField.tsx +++ b/common/components/NonceField.tsx @@ -1,38 +1,72 @@ import React from 'react'; import { NonceFieldFactory } from 'components/NonceFieldFactory'; import Help from 'components/ui/Help'; +import RefreshIcon from 'assets/images/refresh.svg'; +import './NonceField.scss'; +import { InlineSpinner } from 'components/ui/InlineSpinner'; +import { connect } from 'react-redux'; +import { getNonceRequested } from 'actions/transaction'; +import { nonceRequestPending } from 'selectors/transaction'; +import { AppState } from 'reducers'; -interface Props { +interface OwnProps { alwaysDisplay: boolean; } -const nonceHelp = ( - -); +interface StateProps { + nonePending: any; +} -export const NonceField: React.SFC = ({ alwaysDisplay }) => ( - { - const content = ( -
- - {nonceHelp} +interface DispatchProps { + requestNonce: any; +} - -
- ); +type Props = OwnProps & DispatchProps & StateProps; - return alwaysDisplay || shouldDisplay ? content : null; - }} - /> -); +class NonceField extends React.Component { + public render() { + const { alwaysDisplay, requestNonce, nonePending } = this.props; + return ( + { + return alwaysDisplay || shouldDisplay ? ( + +
+ + +
+ +
+
+ + +
+ + ) : null; + }} + /> + ); + } +} + +const mapStateToProps = (state: AppState) => { + return { + nonePending: nonceRequestPending(state) + }; +}; + +export default connect(mapStateToProps, { requestNonce: getNonceRequested })(NonceField); diff --git a/common/components/index.ts b/common/components/index.ts index 76c99908..7515dae2 100644 --- a/common/components/index.ts +++ b/common/components/index.ts @@ -1,7 +1,6 @@ export * from './AddressField'; export * from './DataField'; export * from './GasLimitField'; -export * from './NonceField'; export * from './AmountField'; export * from './SendEverything'; export * from './UnitDropDown'; @@ -9,6 +8,7 @@ export * from './CurrentCustomMessage'; export * from './GenerateTransaction'; export * from './SendButton'; export * from './SigningStatus'; +export { default as NonceField } from './NonceField'; export { default as Header } from './Header'; export { default as Footer } from './Footer'; export { default as BalanceSidebar } from './BalanceSidebar';