mirror of
https://github.com/status-im/MyCrypto.git
synced 2025-01-26 10:59:04 +00:00
9ef1920fe0
* Align footer to bottom * Fix request payment offset padding * Update request payment padding * Add new Input and Dropdown components * Fix offset margins in equiv vals * Update all send tx inputs & dropdowns * Update generate wallet dropdowns * Update inputs & dropdowns for contracts tab * Add inputs & dropdowns for all but swap tab * amend * Fix imports * inputs are invalid when not disabled or readonly * Fix offset refresh button * Add togglable password back to wallet generation * Update swap inputs, textareas, and dropdowns * Update any outstanding inputs * Make UnitDropDown searchable * unitdropdown searchanble if options > 10 * Fix css issues * Reset before setting currentTo
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import React from 'react';
|
|
import { AmountFieldFactory } from './AmountFieldFactory';
|
|
import { UnitDropDown } from 'components';
|
|
import translate, { translateRaw } from 'translations';
|
|
import { Input } from 'components/ui';
|
|
|
|
interface Props {
|
|
hasUnitDropdown?: boolean;
|
|
showAllTokens?: boolean;
|
|
customValidator?(rawAmount: string): boolean;
|
|
}
|
|
|
|
export const AmountField: React.SFC<Props> = ({
|
|
hasUnitDropdown,
|
|
showAllTokens,
|
|
customValidator
|
|
}) => (
|
|
<AmountFieldFactory
|
|
withProps={({ currentValue: { raw }, isValid, onChange, readOnly }) => (
|
|
<div className="input-group-wrapper">
|
|
<label className="input-group input-group-inline-dropdown">
|
|
<div className="input-group-header">{translate('SEND_amount')}</div>
|
|
<Input
|
|
className={`input-group-input ${
|
|
isAmountValid(raw, customValidator, isValid) ? '' : 'invalid'
|
|
}`}
|
|
type="number"
|
|
placeholder={translateRaw('SEND_amount_short')}
|
|
value={raw}
|
|
readOnly={!!readOnly}
|
|
onChange={onChange}
|
|
/>
|
|
{hasUnitDropdown && <UnitDropDown showAllTokens={showAllTokens} />}
|
|
</label>
|
|
</div>
|
|
)}
|
|
/>
|
|
);
|
|
|
|
const isAmountValid = (raw, customValidator, isValid) =>
|
|
customValidator ? customValidator(raw) : isValid;
|