Safes list
This commit is contained in:
parent
617863fb54
commit
3a04b077b2
|
@ -1,34 +1,60 @@
|
||||||
import MuiList from '@material-ui/core/List'
|
import MuiList from '@material-ui/core/List'
|
||||||
import ListItem from '@material-ui/core/ListItem'
|
import ListItem from '@material-ui/core/ListItem'
|
||||||
import ListItemIcon from '@material-ui/core/ListItemIcon'
|
|
||||||
import ListItemText from '@material-ui/core/ListItemText'
|
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
|
import { AddressInfo, Icon, Text, ButtonLink } from '@gnosis.pm/safe-react-components'
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
|
import styled from 'styled-components'
|
||||||
|
|
||||||
import DefaultBadge from './DefaultBadge'
|
import DefaultBadge from './DefaultBadge'
|
||||||
|
|
||||||
import check from 'src/assets/icons/check.svg'
|
|
||||||
import Identicon from 'src/components/Identicon'
|
|
||||||
import ButtonLink from 'src/components/layout/ButtonLink'
|
|
||||||
import Hairline from 'src/components/layout/Hairline'
|
import Hairline from 'src/components/layout/Hairline'
|
||||||
import Img from 'src/components/layout/Img'
|
|
||||||
import Link from 'src/components/layout/Link'
|
import Link from 'src/components/layout/Link'
|
||||||
import Paragraph from 'src/components/layout/Paragraph'
|
|
||||||
import { formatAmount } from 'src/logic/tokens/utils/formatAmount'
|
import { formatAmount } from 'src/logic/tokens/utils/formatAmount'
|
||||||
import { sameAddress, shortVersionOf } from 'src/logic/wallets/ethAddresses'
|
import { sameAddress } from 'src/logic/wallets/ethAddresses'
|
||||||
import { SAFELIST_ADDRESS } from 'src/routes/routes'
|
import { SAFELIST_ADDRESS } from 'src/routes/routes'
|
||||||
|
|
||||||
import { disabled, md, mediumFontSize, primary, sm } from 'src/theme/variables'
|
|
||||||
|
|
||||||
export const SIDEBAR_SAFELIST_ROW_TESTID = 'SIDEBAR_SAFELIST_ROW_TESTID'
|
export const SIDEBAR_SAFELIST_ROW_TESTID = 'SIDEBAR_SAFELIST_ROW_TESTID'
|
||||||
|
|
||||||
|
const StyledIcon = styled(Icon)`
|
||||||
|
margin-right: 4px;
|
||||||
|
`
|
||||||
|
const AddressWrapper = styled.div`
|
||||||
|
display: flex;
|
||||||
|
padding: 5px 0;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
> nth-child(2) {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
|
const StyledButtonLink = styled(ButtonLink)`
|
||||||
|
visibility: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
`
|
||||||
|
|
||||||
|
const AddressDetails = styled.div`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
width: 150px;
|
||||||
|
|
||||||
|
div {
|
||||||
|
margin-left: 0px;
|
||||||
|
padding: 5px 20px;
|
||||||
|
|
||||||
|
img {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin-top: 3px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
icon: {
|
|
||||||
marginRight: sm,
|
|
||||||
},
|
|
||||||
checkIcon: {
|
|
||||||
marginRight: '10px',
|
|
||||||
},
|
|
||||||
list: {
|
list: {
|
||||||
height: '100%',
|
height: '100%',
|
||||||
overflowX: 'hidden',
|
overflowX: 'hidden',
|
||||||
|
@ -38,26 +64,13 @@ const useStyles = makeStyles({
|
||||||
listItemRoot: {
|
listItemRoot: {
|
||||||
paddingTop: 0,
|
paddingTop: 0,
|
||||||
paddingBottom: 0,
|
paddingBottom: 0,
|
||||||
'&:hover $makeDefaultBtn': {
|
'&:hover .safeListMakeDefaultButton': {
|
||||||
visibility: 'initial',
|
visibility: 'initial',
|
||||||
},
|
},
|
||||||
'&:focus $makeDefaultBtn': {
|
'&:focus .safeListMakeDefaultButton': {
|
||||||
visibility: 'initial',
|
visibility: 'initial',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
safeName: {
|
|
||||||
color: primary,
|
|
||||||
overflowWrap: 'break-word',
|
|
||||||
},
|
|
||||||
safeAddress: {
|
|
||||||
color: disabled,
|
|
||||||
fontSize: mediumFontSize,
|
|
||||||
},
|
|
||||||
makeDefaultBtn: {
|
|
||||||
padding: 0,
|
|
||||||
marginLeft: md,
|
|
||||||
visibility: 'hidden',
|
|
||||||
},
|
|
||||||
noIcon: {
|
noIcon: {
|
||||||
visibility: 'hidden',
|
visibility: 'hidden',
|
||||||
width: '28px',
|
width: '28px',
|
||||||
|
@ -78,42 +91,32 @@ const SafeList = ({ currentSafe, defaultSafe, onSafeClick, safes, setDefaultSafe
|
||||||
>
|
>
|
||||||
<ListItem classes={{ root: classes.listItemRoot }}>
|
<ListItem classes={{ root: classes.listItemRoot }}>
|
||||||
{sameAddress(currentSafe, safe.address) ? (
|
{sameAddress(currentSafe, safe.address) ? (
|
||||||
<ListItemIcon>
|
<StyledIcon type="check" size="md" color="primary" />
|
||||||
<Img alt="check" className={classes.checkIcon} src={check} />
|
|
||||||
</ListItemIcon>
|
|
||||||
) : (
|
) : (
|
||||||
<div className={classes.noIcon}>placeholder</div>
|
<div className={classes.noIcon}>placeholder</div>
|
||||||
)}
|
)}
|
||||||
<ListItemIcon>
|
|
||||||
<Identicon address={safe.address} className={classes.icon} diameter={32} />
|
|
||||||
</ListItemIcon>
|
|
||||||
<ListItemText
|
|
||||||
classes={{
|
|
||||||
primary: classes.safeName,
|
|
||||||
secondary: classes.safeAddress,
|
|
||||||
}}
|
|
||||||
primary={safe.name}
|
|
||||||
secondary={shortVersionOf(safe.address, 4)}
|
|
||||||
/>
|
|
||||||
<Paragraph color="primary" size="lg">
|
|
||||||
{`${formatAmount(safe.ethBalance)} ETH`}
|
|
||||||
</Paragraph>
|
|
||||||
{sameAddress(defaultSafe, safe.address) ? (
|
|
||||||
<DefaultBadge />
|
|
||||||
) : (
|
|
||||||
<ButtonLink
|
|
||||||
className={classes.makeDefaultBtn}
|
|
||||||
onClick={(e) => {
|
|
||||||
e.preventDefault()
|
|
||||||
e.stopPropagation()
|
|
||||||
|
|
||||||
setDefaultSafe(safe.address)
|
<AddressWrapper>
|
||||||
}}
|
<AddressInfo address={safe.address} name={safe.name} showIdenticon shortenAddress={4} />
|
||||||
size="sm"
|
|
||||||
>
|
<AddressDetails>
|
||||||
Make default
|
<Text size="xl">{`${formatAmount(safe.ethBalance)} ETH`}</Text>
|
||||||
</ButtonLink>
|
{sameAddress(defaultSafe, safe.address) ? (
|
||||||
)}
|
<DefaultBadge />
|
||||||
|
) : (
|
||||||
|
<StyledButtonLink
|
||||||
|
className="safeListMakeDefaultButton"
|
||||||
|
textSize="sm"
|
||||||
|
onClick={() => {
|
||||||
|
setDefaultSafe(safe.address)
|
||||||
|
}}
|
||||||
|
color="primary"
|
||||||
|
>
|
||||||
|
Make default
|
||||||
|
</StyledButtonLink>
|
||||||
|
)}
|
||||||
|
</AddressDetails>
|
||||||
|
</AddressWrapper>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</Link>
|
</Link>
|
||||||
<Hairline />
|
<Hairline />
|
||||||
|
|
Loading…
Reference in New Issue