Updating UserDetails component when user is connected to provider
This commit is contained in:
parent
53983f006a
commit
244d36e1a1
|
@ -9,9 +9,11 @@ import Bold from '~/components/layout/Bold'
|
||||||
import Hairline from '~/components/layout/Hairline'
|
import Hairline from '~/components/layout/Hairline'
|
||||||
import Img from '~/components/layout/Img'
|
import Img from '~/components/layout/Img'
|
||||||
import Row from '~/components/layout/Row'
|
import Row from '~/components/layout/Row'
|
||||||
|
import Block from '~/components/layout/Block'
|
||||||
import Spacer from '~/components/Spacer'
|
import Spacer from '~/components/Spacer'
|
||||||
import { sm, md, lg, background } from '~/theme/variables'
|
import { xs, sm, md, lg, background } from '~/theme/variables'
|
||||||
import { upperFirst } from '~/utils/css'
|
import { upperFirst } from '~/utils/css'
|
||||||
|
import { shortVersionOf } from '~/logic/wallets/ethAddresses'
|
||||||
|
|
||||||
const metamask = require('../../assets/metamask.svg')
|
const metamask = require('../../assets/metamask.svg')
|
||||||
const connectedLogo = require('../../assets/connected.svg')
|
const connectedLogo = require('../../assets/connected.svg')
|
||||||
|
@ -33,14 +35,17 @@ const openIconStyle = {
|
||||||
const styles = () => ({
|
const styles = () => ({
|
||||||
container: {
|
container: {
|
||||||
padding: `${md} 12px`,
|
padding: `${md} 12px`,
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
},
|
},
|
||||||
identicon: {
|
identicon: {
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
padding: `0 ${md}`,
|
padding: `0 ${md}`,
|
||||||
},
|
},
|
||||||
user: {
|
user: {
|
||||||
alignItems: 'center',
|
borderRadius: '3px',
|
||||||
backgroundColor: background,
|
backgroundColor: background,
|
||||||
|
margin: '0 auto',
|
||||||
padding: sm,
|
padding: sm,
|
||||||
},
|
},
|
||||||
details: {
|
details: {
|
||||||
|
@ -51,12 +56,20 @@ const styles = () => ({
|
||||||
address: {
|
address: {
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
|
letterSpacing: '-0.5px',
|
||||||
|
},
|
||||||
|
open: {
|
||||||
|
paddingLeft: sm,
|
||||||
|
width: 'auto',
|
||||||
},
|
},
|
||||||
disconnect: {
|
disconnect: {
|
||||||
padding: `${md} 32px`,
|
padding: `${md} ${lg}`,
|
||||||
|
},
|
||||||
|
disconnectText: {
|
||||||
|
letterSpacing: '1px',
|
||||||
},
|
},
|
||||||
logo: {
|
logo: {
|
||||||
margin: '0px 2px',
|
margin: `0px ${xs}`,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -64,18 +77,19 @@ const UserDetails = ({
|
||||||
provider, connected, network, userAddress, classes,
|
provider, connected, network, userAddress, classes,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const status = connected ? 'Connected' : 'Not connected'
|
const status = connected ? 'Connected' : 'Not connected'
|
||||||
|
const address = shortVersionOf(userAddress, 6)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<div className={classes.container}>
|
<Block className={classes.container}>
|
||||||
<Row className={classes.identicon} margin="md" align="center">
|
<Row className={classes.identicon} margin="md" align="center">
|
||||||
<Identicon address={userAddress} diameter={60} />
|
<Identicon address={userAddress} diameter={60} />
|
||||||
</Row>
|
</Row>
|
||||||
<Row className={classes.user} grow >
|
<Block align="center" className={classes.user}>
|
||||||
<Paragraph className={classes.address} size="sm" noMargin>{userAddress}</Paragraph>
|
<Paragraph className={classes.address} size="sm" noMargin>{address}</Paragraph>
|
||||||
<OpenInNew style={openIconStyle} />
|
<OpenInNew className={classes.open} style={openIconStyle} />
|
||||||
</Row>
|
</Block>
|
||||||
</div>
|
</Block>
|
||||||
<Hairline margin="xs" />
|
<Hairline margin="xs" />
|
||||||
<Row className={classes.details}>
|
<Row className={classes.details}>
|
||||||
<Paragraph size="sm" noMargin align="right">Status </Paragraph>
|
<Paragraph size="sm" noMargin align="right">Status </Paragraph>
|
||||||
|
@ -115,7 +129,7 @@ const UserDetails = ({
|
||||||
color="primary"
|
color="primary"
|
||||||
fullWidth
|
fullWidth
|
||||||
>
|
>
|
||||||
DISCONNECT
|
<Paragraph className={classes.disconnectText} size="sm" weight="regular" noMargin>DISCONNECT</Paragraph>
|
||||||
</Button>
|
</Button>
|
||||||
</Row>
|
</Row>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import Col from '~/components/layout/Col'
|
||||||
import Img from '~/components/layout/Img'
|
import Img from '~/components/layout/Img'
|
||||||
import { sm } from '~/theme/variables'
|
import { sm } from '~/theme/variables'
|
||||||
import Identicon from '~/components/Identicon'
|
import Identicon from '~/components/Identicon'
|
||||||
|
import { shortVersionOf } from '~/logic/wallets/ethAddresses'
|
||||||
|
|
||||||
const connectedLogo = require('../../assets/connected.svg')
|
const connectedLogo = require('../../assets/connected.svg')
|
||||||
|
|
||||||
|
@ -41,7 +42,7 @@ const ProviderInfo = ({
|
||||||
provider, network, userAddress, connected, classes,
|
provider, network, userAddress, connected, classes,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const providerText = connected ? `${provider} [${network}]` : 'Not connected'
|
const providerText = connected ? `${provider} [${network}]` : 'Not connected'
|
||||||
const cutAddress = connected ? `${userAddress.substring(0, 8)}...${userAddress.substring(36)}` : ''
|
const cutAddress = connected ? shortVersionOf(userAddress, 6) : ''
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
|
Loading…
Reference in New Issue