-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finance, Token Manager: add “Max” button (#1130)
A new component has been added locally: AmountInput. It uses TextInput internally, and can optionally display a “Max” button.
- Loading branch information
1 parent
11415c4
commit 89404d6
Showing
5 changed files
with
139 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { ButtonBase, TextInput, noop, GU, RADIUS } from '@aragon/ui' | ||
|
||
const MAX_BUTTON_WIDTH = 6 * GU | ||
|
||
const AmountInput = React.forwardRef(function AmountInput( | ||
{ showMax, onMaxClick, ...props }, | ||
ref | ||
) { | ||
return ( | ||
<TextInput | ||
ref={ref} | ||
min={0} | ||
step="any" | ||
adornment={ | ||
showMax && ( | ||
<ButtonBase | ||
focusRingRadius={RADIUS} | ||
onClick={onMaxClick} | ||
css={` | ||
width: ${MAX_BUTTON_WIDTH}px; | ||
height: calc(100% - 2px); | ||
text-transform: uppercase; | ||
&:active { | ||
transform: translate(0.5px, 0.5px); | ||
} | ||
`} | ||
> | ||
Max | ||
</ButtonBase> | ||
) | ||
} | ||
adornmentPosition="end" | ||
adornmentSettings={{ width: MAX_BUTTON_WIDTH, padding: 1 }} | ||
{...props} | ||
/> | ||
) | ||
}) | ||
|
||
AmountInput.propTypes = { | ||
showMax: PropTypes.bool, | ||
onMaxClick: PropTypes.func, | ||
} | ||
|
||
AmountInput.defaultProps = { | ||
onMaxClick: noop, | ||
} | ||
|
||
export default AmountInput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import { ButtonBase, TextInput, noop, GU, RADIUS } from '@aragon/ui' | ||
|
||
const MAX_BUTTON_WIDTH = 6 * GU | ||
|
||
const AmountInput = React.forwardRef(function AmountInput( | ||
{ showMax, onMaxClick, ...props }, | ||
ref | ||
) { | ||
return ( | ||
<TextInput | ||
ref={ref} | ||
min={0} | ||
step="any" | ||
adornment={ | ||
showMax && ( | ||
<ButtonBase | ||
focusRingRadius={RADIUS} | ||
onClick={onMaxClick} | ||
css={` | ||
width: ${MAX_BUTTON_WIDTH}px; | ||
height: calc(100% - 2px); | ||
text-transform: uppercase; | ||
&:active { | ||
transform: translate(0.5px, 0.5px); | ||
} | ||
`} | ||
> | ||
Max | ||
</ButtonBase> | ||
) | ||
} | ||
adornmentPosition="end" | ||
adornmentSettings={{ width: MAX_BUTTON_WIDTH, padding: 1 }} | ||
{...props} | ||
/> | ||
) | ||
}) | ||
|
||
AmountInput.propTypes = { | ||
showMax: PropTypes.bool, | ||
onMaxClick: PropTypes.func, | ||
} | ||
|
||
AmountInput.defaultProps = { | ||
onMaxClick: noop, | ||
} | ||
|
||
export default AmountInput |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters