-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from QuickSwap/feature/update-recipient-input
Update inputs and pool card
- Loading branch information
Showing
7 changed files
with
116 additions
and
53 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,79 @@ | ||
import React from 'react'; | ||
import { Box, Typography } from '@material-ui/core'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import useENS from 'hooks/useENS'; | ||
import { useActiveWeb3React } from 'hooks'; | ||
import { getEtherscanLink } from 'utils'; | ||
|
||
const useStyles = makeStyles(({ palette }) => ({ | ||
addressInput: { | ||
border: (props: any) => | ||
`1px solid ${props.error ? palette.error.main : palette.primary.dark}`, | ||
borderRadius: 20, | ||
padding: '12px 24px', | ||
textAlign: 'left', | ||
'& input': { | ||
width: '100%', | ||
fontSize: 20, | ||
fontWeight: 'bold', | ||
color: (props: any) => | ||
props.error ? palette.error.main : palette.text.primary, | ||
background: 'transparent', | ||
border: 'none', | ||
boxShadow: 'none', | ||
outline: 'none', | ||
marginTop: 16, | ||
}, | ||
'& a': { | ||
color: palette.text.primary, | ||
textDecoration: 'none', | ||
}, | ||
}, | ||
})); | ||
|
||
interface AddressInputProps { | ||
value: string; | ||
onChange: (val: string) => void; | ||
placeholder: string; | ||
label: string; | ||
} | ||
|
||
const AddressInput: React.FC<AddressInputProps> = ({ | ||
value, | ||
onChange, | ||
placeholder, | ||
label, | ||
}) => { | ||
const { chainId } = useActiveWeb3React(); | ||
const { address, loading, name } = useENS(value); | ||
const error = Boolean(value.length > 0 && !loading && !address); | ||
const classes = useStyles({ error }); | ||
|
||
return ( | ||
<Box className={classes.addressInput}> | ||
<Box display='flex' justifyContent='space-between' alignItems='center'> | ||
<Typography>{label}</Typography> | ||
{address && chainId && ( | ||
<a | ||
href={getEtherscanLink(chainId, name ?? address, 'address')} | ||
target='_blank' | ||
rel='noreferrer' | ||
> | ||
(View on Block Explorer) | ||
</a> | ||
)} | ||
</Box> | ||
<input | ||
value={value} | ||
placeholder={placeholder} | ||
onChange={(evt) => { | ||
const input = evt.target.value; | ||
const withoutSpaces = input.replace(/\s+/g, ''); | ||
onChange(withoutSpaces); | ||
}} | ||
/> | ||
</Box> | ||
); | ||
}; | ||
|
||
export default AddressInput; |
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 @@ | ||
export { default } from './AddressInput'; |
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
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