Refactor Provider Details. Creating general component #72

This commit is contained in:
apanizo 2018-11-07 10:43:30 +01:00
parent f2e88fca88
commit 4c50494bd5
3 changed files with 77 additions and 58 deletions

View File

@ -3,13 +3,9 @@ import * as React from 'react'
import { withStyles } from '@material-ui/core/styles' import { withStyles } from '@material-ui/core/styles'
import Paragraph from '~/components/layout/Paragraph' import Paragraph from '~/components/layout/Paragraph'
import Button from '~/components/layout/Button' import Button from '~/components/layout/Button'
import Dot from '@material-ui/icons/FiberManualRecord'
import Block from '~/components/layout/Block'
import Img from '~/components/layout/Img'
import Row from '~/components/layout/Row' import Row from '~/components/layout/Row'
import { md, lg, fancy } from '~/theme/variables' import { md, lg } from '~/theme/variables'
import KeyRing from './KeyRing'
const connectedLogo = require('../../assets/key.svg')
type Props = { type Props = {
classes: Object, classes: Object,
@ -37,25 +33,6 @@ const styles = () => ({
img: { img: {
margin: '0px 2px', margin: '0px 2px',
}, },
status: {
height: '25px',
width: '25px',
borderRadius: '20px',
bottom: '93px',
position: 'absolute',
right: '98px',
backgroundColor: '#ffffff',
color: fancy,
},
key: {
width: '75px',
height: '75px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#e4e8f1',
borderRadius: '40px',
},
}) })
const ConnectDetails = ({ classes, onConnect }: Props) => ( const ConnectDetails = ({ classes, onConnect }: Props) => (
@ -66,10 +43,7 @@ const ConnectDetails = ({ classes, onConnect }: Props) => (
</Row> </Row>
</div> </div>
<Row className={classes.logo} margin="lg"> <Row className={classes.logo} margin="lg">
<Block className={classes.key}> <KeyRing keySize={32} circleSize={75} dotSize={25} dotTop={50} dotRight={25} center />
<Img src={connectedLogo} height={32} alt="Status disconnected" />
</Block>
<Dot className={classes.status} />
</Row> </Row>
<Row className={classes.connect}> <Row className={classes.connect}>
<Button <Button

View File

@ -0,0 +1,71 @@
// @flow
import * as React from 'react'
import { withStyles } from '@material-ui/core/styles'
import Block from '~/components/layout/Block'
import Dot from '@material-ui/icons/FiberManualRecord'
import Img from '~/components/layout/Img'
import { fancy, border } from '~/theme/variables'
const key = require('../../assets/key.svg')
const styles = () => ({
root: {
display: 'flex',
},
dot: {
position: 'relative',
backgroundColor: '#ffffff',
color: fancy,
},
key: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: border,
},
})
type Props = {
classes: Object,
keySize: number,
circleSize: number,
dotSize: number,
dotTop: number,
dotRight: number,
center?: boolean,
}
const buildKeyStyleFrom = (size: number, center: boolean, dotSize: number) => ({
width: `${size}px`,
height: `${size}px`,
marginLeft: center ? `${dotSize}px` : 'none',
borderRadius: `${size}px`,
})
const buildDotStyleFrom = (size: number, top: number, right: number) => ({
width: `${size}px`,
height: `${size}px`,
borderRadius: `${size}px`,
top: `${top}px`,
right: `${right}px`,
})
const KeyRing = ({
classes, circleSize, keySize, dotSize, dotTop, dotRight, center = false,
}: Props) => {
const keyStyle = buildKeyStyleFrom(circleSize, center, dotSize)
const dotStyle = buildDotStyleFrom(dotSize, dotTop, dotRight)
return (
<React.Fragment>
<Block className={classes.root}>
<Block className={classes.key} style={keyStyle}>
<Img src={key} height={keySize} alt="Status disconnected" />
</Block>
<Dot className={classes.dot} style={dotStyle} />
</Block>
</React.Fragment>
)
}
export default withStyles(styles)(KeyRing)

View File

@ -1,15 +1,11 @@
// @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 Dot from '@material-ui/icons/FiberManualRecord'
import Paragraph from '~/components/layout/Paragraph' import Paragraph from '~/components/layout/Paragraph'
import Block from '~/components/layout/Block'
import Col from '~/components/layout/Col' import Col from '~/components/layout/Col'
import Img from '~/components/layout/Img'
import { type Open } from '~/components/hoc/OpenHoc' import { type Open } from '~/components/hoc/OpenHoc'
import { sm, fancy } from '~/theme/variables' import { sm } from '~/theme/variables'
import KeyRing from './KeyRing'
const connectWallet = require('../../assets/key.svg')
type Props = Open & { type Props = Open & {
classes: Object, classes: Object,
@ -31,33 +27,11 @@ const styles = () => ({
connect: { connect: {
letterSpacing: '-0.5px', letterSpacing: '-0.5px',
}, },
logo: {
height: '15px',
width: '15px',
top: '12px',
position: 'relative',
right: '10px',
backgroundColor: '#ffffff',
borderRadius: '15px',
color: fancy,
},
key: {
width: '38px',
height: '35px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#e4e8f1',
borderRadius: '20px',
},
}) })
const ProviderDesconnected = ({ classes }: Props) => ( const ProviderDesconnected = ({ classes }: Props) => (
<React.Fragment> <React.Fragment>
<Block className={classes.key}> <KeyRing keySize={17} circleSize={35} dotSize={16} dotTop={24} dotRight={11} />
<Img src={connectWallet} height={18} alt="Status disconnected" />
</Block>
<Dot className={classes.logo} />
<Col end="sm" middle="xs" layout="column" className={classes.account}> <Col end="sm" middle="xs" layout="column" className={classes.account}>
<Paragraph size="sm" transform="capitalize" className={classes.network} noMargin weight="bold">Not Connected</Paragraph> <Paragraph size="sm" transform="capitalize" className={classes.network} noMargin weight="bold">Not Connected</Paragraph>
<Paragraph size="sm" color="fancy" className={classes.connect} noMargin>Connect Wallet</Paragraph> <Paragraph size="sm" color="fancy" className={classes.connect} noMargin>Connect Wallet</Paragraph>