Skip to content

Commit

Permalink
fix(Coinify): use NumberBox; fix TextBox gDSFP; do not show spinner o…
Browse files Browse the repository at this point in the history
…n input with type number
  • Loading branch information
Philip Welber committed Jun 11, 2018
1 parent ee072de commit 7f714fe
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
5 changes: 5 additions & 0 deletions packages/blockchain-info-components/src/Form/NumberInput.js
Expand Up @@ -26,6 +26,11 @@ const BaseNumberInput = styled.input.attrs({
color: ${props => props.theme['gray-3']};
opacity: 0.4;
}
&::-webkit-inner-spin-button,
&::-webkit-outer-spin-button {
-webkit-appearance: none;
margin: 0;
}
`

const selectBorderColor = (state) => {
Expand Down
Expand Up @@ -35,8 +35,11 @@ class TextBoxDebounced extends React.Component {
}

static getDerivedStateFromProps (nextProps, prevState) {
if (!equals(nextProps.input.value, prevState)) {
return { value: nextProps.input.value }
if (!equals(prevState.updatedValue, prevState.value)) {
return { updatedValue: prevState.updatedValue, value: prevState.updatedValue }
}
if (!equals(nextProps.input.value, prevState.value)) {
return { updatedValue: nextProps.input.value, value: nextProps.input.value }
}
return null
}
Expand All @@ -48,11 +51,12 @@ class TextBoxDebounced extends React.Component {
handleChange (e) {
e.preventDefault()
const value = e.target.value
this.setState({ value })
if (this.timeout) clearTimeout(this.timeout)
this.setState({ updatedValue: value })

clearTimeout(this.timeout)
this.timeout = setTimeout(() => {
this.props.input.onChange(value)
}, 10)
}, 500)
}

handleBlur () {
Expand Down
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import styled from 'styled-components'
import { FormattedMessage } from 'react-intl'
import { Icon, Text } from 'blockchain-info-components'
import { SelectBoxCoinifyCurrency, TextBoxDebounced } from 'components/Form'
import { SelectBoxCoinifyCurrency, NumberBoxDebounced } from 'components/Form'
import { Field, reduxForm } from 'redux-form'
import { head } from 'ramda'
import { getReasonExplanation } from 'services/CoinifyService'
Expand Down Expand Up @@ -145,12 +145,12 @@ const FiatConvertor = (props) => {
<Wrapper>
<FiatConvertorInput>
<Container>
<Field name='leftVal' component={TextBoxDebounced} disabled={disabled || !canTrade} borderRightNone={1} />
<Field name='leftVal' component={NumberBoxDebounced} disabled={disabled || !canTrade} borderRightNone={1} />
<Field name='currency' component={SelectBoxCoinifyCurrency} defaultDisplay={defaultCurrency} isSell={isSell} />
</Container>
<ArrowRight weight={600} size='22px' name='right-arrow' />
<Container>
<Field name='rightVal' component={TextBoxDebounced} disabled={disabled || !canTrade} />
<Field name='rightVal' component={NumberBoxDebounced} disabled={disabled || !canTrade} />
<Unit>{currency}</Unit>
</Container>
</FiatConvertorInput>
Expand Down

0 comments on commit 7f714fe

Please sign in to comment.