Adding hideDot option in CircleDot component

This commit is contained in:
apanizo 2018-11-07 11:22:19 +01:00
parent 6ea91526b2
commit 9c057d0812
3 changed files with 24 additions and 8 deletions

View File

@ -7,7 +7,7 @@ import Img from '~/components/layout/Img'
import { fancy, border, warning } from '~/theme/variables' import { fancy, border, warning } from '~/theme/variables'
const key = require('../assets/key.svg') const key = require('../assets/key.svg')
const triangle = require('../assets/key.svg') const triangle = require('../assets/triangle.svg')
const styles = () => ({ const styles = () => ({
root: { root: {
@ -24,6 +24,10 @@ const styles = () => ({
justifyContent: 'center', justifyContent: 'center',
backgroundColor: border, backgroundColor: border,
}, },
warning: {
position: 'relative',
top: '-2px',
},
}) })
type Mode = 'error' | 'warning' type Mode = 'error' | 'warning'
@ -35,8 +39,9 @@ type Props = {
dotSize: number, dotSize: number,
dotTop: number, dotTop: number,
dotRight: number, dotRight: number,
center?: boolean,
mode: Mode, mode: Mode,
center?: boolean,
hideDot?: boolean,
} }
const buildKeyStyleFrom = (size: number, center: boolean, dotSize: number) => ({ const buildKeyStyleFrom = (size: number, center: boolean, dotSize: number) => ({
@ -56,19 +61,26 @@ const buildDotStyleFrom = (size: number, top: number, right: number, mode: Mode)
}) })
const KeyRing = ({ const KeyRing = ({
classes, circleSize, keySize, dotSize, dotTop, dotRight, mode, center = false, classes, circleSize, keySize, dotSize, dotTop, dotRight, mode, center = false, hideDot = false,
}: Props) => { }: Props) => {
const keyStyle = buildKeyStyleFrom(circleSize, center, dotSize) const keyStyle = buildKeyStyleFrom(circleSize, center, dotSize)
const dotStyle = buildDotStyleFrom(dotSize, dotTop, dotRight, mode) const dotStyle = buildDotStyleFrom(dotSize, dotTop, dotRight, mode)
const img = mode === warning ? triangle : key const isWarning = mode === 'warning'
const img = isWarning ? triangle : key
return ( return (
<React.Fragment> <React.Fragment>
<Block className={classes.root}> <Block className={classes.root}>
<Block className={classes.key} style={keyStyle}> <Block className={classes.key} style={keyStyle}>
<Img src={img} height={keySize} alt="Status disconnected" /> <Img
src={img}
height={keySize}
width={isWarning ? keySize + 2 : keySize}
alt="Status connection"
className={isWarning ? classes.warning : undefined}
/>
</Block> </Block>
<Dot className={classes.dot} style={dotStyle} /> { !hideDot && <Dot className={classes.dot} style={dotStyle} /> }
</Block> </Block>
</React.Fragment> </React.Fragment>
) )

View File

@ -15,6 +15,7 @@ import { xs, sm, md, lg, background, secondary } from '~/theme/variables'
import { upperFirst } from '~/utils/css' import { upperFirst } from '~/utils/css'
import { shortVersionOf } from '~/logic/wallets/ethAddresses' import { shortVersionOf } from '~/logic/wallets/ethAddresses'
import { openAddressInEtherScan } from '~/logic/wallets/getWeb3' import { openAddressInEtherScan } from '~/logic/wallets/getWeb3'
import CircleDot from '~/components/Header/component/CircleDot'
const metamask = require('../../assets/metamask.svg') const metamask = require('../../assets/metamask.svg')
const connectedLogo = require('../../assets/connected.svg') const connectedLogo = require('../../assets/connected.svg')
@ -92,7 +93,10 @@ const UserDetails = ({
<React.Fragment> <React.Fragment>
<Block 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={identiconAddress} diameter={60} /> { connected
? <Identicon address={identiconAddress} diameter={60} />
: <CircleDot keySize={30} circleSize={75} dotSize={25} dotTop={50} dotRight={25} mode="warning" hideDot />
}
</Row> </Row>
<Block align="center" className={classes.user}> <Block align="center" className={classes.user}>
<Paragraph className={classes.address} size="sm" noMargin>{address}</Paragraph> <Paragraph className={classes.address} size="sm" noMargin>{address}</Paragraph>

View File

@ -64,7 +64,7 @@ const ProviderInfo = ({
</React.Fragment> </React.Fragment>
} }
{ !connected && { !connected &&
<CircleDot keySize={17} circleSize={35} dotSize={16} dotTop={24} dotRight={11} mode="warning" /> <CircleDot keySize={14} circleSize={35} dotSize={16} dotTop={24} dotRight={11} mode="warning" />
} }
<Col start="sm" layout="column" className={classes.account}> <Col start="sm" layout="column" className={classes.account}>
<Paragraph size="sm" transform="capitalize" className={classes.network} noMargin weight="bolder">{providerText}</Paragraph> <Paragraph size="sm" transform="capitalize" className={classes.network} noMargin weight="bolder">{providerText}</Paragraph>