mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-13 03:24:09 +00:00
Wrapping Provider data in one component & Adding Identicon
This commit is contained in:
parent
e75dae5182
commit
70f875ba29
@ -1,24 +1,26 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import { withStyles } from '@material-ui/core/styles'
|
import { withStyles } from '@material-ui/core/styles'
|
||||||
import ExpansionPanel from '@material-ui/core/ExpansionPanel'
|
|
||||||
import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'
|
import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'
|
||||||
import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary'
|
|
||||||
import ExpandMoreIcon from '@material-ui/icons/ArrowDropDown'
|
|
||||||
import OpenInNew from '@material-ui/icons/OpenInNew'
|
import OpenInNew from '@material-ui/icons/OpenInNew'
|
||||||
|
import IconButton from '@material-ui/core/IconButton'
|
||||||
|
import ExpandLess from '@material-ui/icons/ExpandLess'
|
||||||
|
import ExpandMore from '@material-ui/icons/ExpandMore'
|
||||||
|
import Divider from '~/components/layout/Divider'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
|
import openHoc, { type Open } from '~/components/hoc/OpenHoc'
|
||||||
import Col from '~/components/layout/Col'
|
import Col from '~/components/layout/Col'
|
||||||
import Img from '~/components/layout/Img'
|
import Img from '~/components/layout/Img'
|
||||||
import Button from '~/components/layout/Button'
|
import Button from '~/components/layout/Button'
|
||||||
import Row from '~/components/layout/Row'
|
import Row from '~/components/layout/Row'
|
||||||
import Identicon from '~/components/Identicon'
|
import Identicon from '~/components/Identicon'
|
||||||
import Spacer from '~/components/Spacer'
|
import Spacer from '~/components/Spacer'
|
||||||
import { border } from '~/theme/variables'
|
import { border, sm, md } from '~/theme/variables'
|
||||||
import Details from './Details'
|
import Details from './Details'
|
||||||
|
|
||||||
const logo = require('../assets/gnosis-safe-logo.svg')
|
const logo = require('../assets/gnosis-safe-logo.svg')
|
||||||
|
|
||||||
type Props = {
|
type Props = Open & {
|
||||||
provider: string,
|
provider: string,
|
||||||
classes: Object,
|
classes: Object,
|
||||||
network: string,
|
network: string,
|
||||||
@ -27,21 +29,32 @@ type Props = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const styles = theme => ({
|
const styles = theme => ({
|
||||||
root: {
|
|
||||||
width: '100%',
|
|
||||||
},
|
|
||||||
summary: {
|
summary: {
|
||||||
border: `solid 0.5px ${border}`,
|
border: `solid 2px ${border}`,
|
||||||
|
alignItems: 'center',
|
||||||
|
height: '52px',
|
||||||
},
|
},
|
||||||
logo: {
|
logo: {
|
||||||
flexBasis: '125px',
|
padding: `${sm} ${md}`,
|
||||||
|
flexBasis: '95px',
|
||||||
},
|
},
|
||||||
provider: {
|
provider: {
|
||||||
flexBasis: '130px',
|
padding: `${sm} ${md}`,
|
||||||
|
alignItems: 'center',
|
||||||
|
flex: '0 1 auto',
|
||||||
|
display: 'flex',
|
||||||
|
cursor: 'pointer',
|
||||||
|
},
|
||||||
|
account: {
|
||||||
|
padding: `0 ${md} 0 ${sm}`,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
|
expand: {
|
||||||
|
width: '20px',
|
||||||
|
height: '20px',
|
||||||
|
},
|
||||||
user: {
|
user: {
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
border: '1px solid grey',
|
border: '1px solid grey',
|
||||||
@ -92,26 +105,32 @@ const openIconStyle = {
|
|||||||
height: '14px',
|
height: '14px',
|
||||||
}
|
}
|
||||||
|
|
||||||
const Header = ({
|
const Header = openHoc(({
|
||||||
provider, network, connected, classes, userAddress,
|
open, toggle, provider, network, connected, classes, userAddress,
|
||||||
}: 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 ? `${userAddress.substring(0, 8)}...${userAddress.substring(36)}` : ''
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ExpansionPanel className={classes.root} elevation={0}>
|
<React.Fragment>
|
||||||
<ExpansionPanelSummary className={classes.summary} expandIcon={<ExpandMoreIcon />}>
|
<Row onClick={toggle} className={classes.summary}>
|
||||||
<Row grow>
|
|
||||||
<Col start="xs" middle="xs" className={classes.logo}>
|
<Col start="xs" middle="xs" className={classes.logo}>
|
||||||
<Img src={logo} height={54} alt="Gnosis Safe" />
|
<Img src={logo} height={32} alt="Gnosis Team Safe" />
|
||||||
</Col>
|
</Col>
|
||||||
|
<Divider />
|
||||||
<Spacer />
|
<Spacer />
|
||||||
<Col end="sm" middle="xs" layout="column" className={classes.provider}>
|
<Divider />
|
||||||
|
<Col end="sm" middle="xs" className={classes.provider}>
|
||||||
|
{ connected && <Identicon address={userAddress} diameter={25} /> }
|
||||||
|
<Col end="sm" middle="xs" layout="column" className={classes.account}>
|
||||||
<Paragraph size="sm" transform="capitalize" noMargin bold>{providerText}</Paragraph>
|
<Paragraph size="sm" transform="capitalize" noMargin bold>{providerText}</Paragraph>
|
||||||
<Paragraph size="sm" noMargin>{cutAddress}</Paragraph>
|
<Paragraph size="sm" noMargin>{cutAddress}</Paragraph>
|
||||||
</Col>
|
</Col>
|
||||||
|
<IconButton disableRipple className={classes.expand}>
|
||||||
|
{ open ? <ExpandLess /> : <ExpandMore />}
|
||||||
|
</IconButton>
|
||||||
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</ExpansionPanelSummary>
|
|
||||||
{ connected &&
|
{ connected &&
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<ExpansionPanelDetails className={classes.details}>
|
<ExpansionPanelDetails className={classes.details}>
|
||||||
@ -130,8 +149,8 @@ const Header = ({
|
|||||||
</ExpansionPanelDetails>
|
</ExpansionPanelDetails>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
}
|
}
|
||||||
</ExpansionPanel>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
|
|
||||||
export default withStyles(styles)(Header)
|
export default withStyles(styles)(Header)
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
import { createSelector } from 'reselect'
|
import { createSelector } from 'reselect'
|
||||||
import type { Provider } from '~/logic/wallets/store/model/provider'
|
import type { Provider } from '~/logic/wallets/store/model/provider'
|
||||||
import { PROVIDER_REDUCER_ID } from '~/logic/wallets/store/reducer/provider'
|
import { PROVIDER_REDUCER_ID } from '~/logic/wallets/store/reducer/provider'
|
||||||
import { upperFirst } from '~/utils/css'
|
|
||||||
import { ETHEREUM_NETWORK_IDS, ETHEREUM_NETWORK } from '~/logic/wallets/getWeb3'
|
import { ETHEREUM_NETWORK_IDS, ETHEREUM_NETWORK } from '~/logic/wallets/getWeb3'
|
||||||
|
|
||||||
const providerSelector = (state: any): Provider => state[PROVIDER_REDUCER_ID]
|
const providerSelector = (state: any): Provider => state[PROVIDER_REDUCER_ID]
|
||||||
@ -33,7 +32,7 @@ export const networkSelector = createSelector(
|
|||||||
const networkId = provider.get('network')
|
const networkId = provider.get('network')
|
||||||
const network = ETHEREUM_NETWORK_IDS[networkId] || ETHEREUM_NETWORK.UNKNOWN
|
const network = ETHEREUM_NETWORK_IDS[networkId] || ETHEREUM_NETWORK.UNKNOWN
|
||||||
|
|
||||||
return upperFirst(network)
|
return network
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user