Refactor OpenPaper component. Now it accepts width for container component

This commit is contained in:
apanizo 2018-10-08 12:21:23 +02:00
parent 0ba812f7f5
commit 4cc92e5361
3 changed files with 44 additions and 23 deletions

View File

@ -22,18 +22,27 @@ type Props = {
classes: Object, classes: Object,
children: React$Node, children: React$Node,
controls: React$Node, controls: React$Node,
container?: number,
padding?: boolean, padding?: boolean,
} }
const generateContainerStyleFrom = (container?: number) => ({
maxWidth: container ? `${container}px` : undefined,
})
const OpenPaper = ({ const OpenPaper = ({
classes, children, controls, padding = true, classes, children, controls, container, padding = true,
}: Props) => ( }: Props) => {
<Paper className={classes.root} elevation={1}> const containerStyle = generateContainerStyleFrom(container)
<Block className={`${classes.container} ${padding ? classes.padding : ''}`}>
{children} return (
</Block> <Paper className={classes.root} elevation={1}>
{ controls } <Block style={containerStyle} className={`${classes.container} ${padding ? classes.padding : ''}`}>
</Paper> {children}
) </Block>
{ controls }
</Paper>
)
}
export default withStyles(styles)(OpenPaper) export default withStyles(styles)(OpenPaper)

View File

@ -5,9 +5,11 @@ import Field from '~/components/forms/Field'
import TextField from '~/components/forms/TextField' import TextField from '~/components/forms/TextField'
import { required } from '~/components/forms/validator' import { required } from '~/components/forms/validator'
import Block from '~/components/layout/Block' import Block from '~/components/layout/Block'
import Row from '~/components/layout/Row'
import { FIELD_NAME } from '~/routes/open/components/fields' import { FIELD_NAME } from '~/routes/open/components/fields'
import Paragraph from '~/components/layout/Paragraph' import Paragraph from '~/components/layout/Paragraph'
import OpenPaper from '~/components/Stepper/OpenPaper' import OpenPaper from '~/components/Stepper/OpenPaper'
import { sm } from '~/theme/variables'
type Props = { type Props = {
classes: Object, classes: Object,
@ -16,6 +18,13 @@ type Props = {
const styles = () => ({ const styles = () => ({
root: { root: {
display: 'flex', display: 'flex',
maxWidth: '440px',
},
text: {
flexWrap: 'nowrap',
},
dot: {
marginRight: sm,
}, },
}) })
@ -27,16 +36,22 @@ const SafeName = ({ classes }: Props) => (
By continuing you consent with the terms of use and privacy policy. By continuing you consent with the terms of use and privacy policy.
</Paragraph> </Paragraph>
</Block> </Block>
<Block margin="md"> <Row margin="md" className={classes.text}>
<Paragraph noMargin className={classes.dot} color="secondary">
&#9679;
</Paragraph>
<Paragraph noMargin size="md" color="primary" weight="bolder"> <Paragraph noMargin size="md" color="primary" weight="bolder">
&#9679; I understand that my funds are held securely in my Safe. They cannot be accessed by Gnosis. I understand that my funds are held securely in my Safe. They cannot be accessed by Gnosis.
</Paragraph> </Paragraph>
</Block> </Row>
<Block margin="md"> <Row margin="md">
<Paragraph size="md" color="primary" weight="bolder"> <Paragraph noMargin className={classes.dot} color="secondary">
&#9679; My Safe is a smart contract on the Ethereum blockchain. &#9679;
</Paragraph> </Paragraph>
</Block> <Paragraph noMargin size="md" color="primary" weight="bolder">
My Safe is a smart contract on the Ethereum blockchain.
</Paragraph>
</Row>
<Block margin="lg" className={classes.root}> <Block margin="lg" className={classes.root}>
<Field <Field
name={FIELD_NAME} name={FIELD_NAME}
@ -53,7 +68,7 @@ const SafeName = ({ classes }: Props) => (
const SafeNameForm = withStyles(styles)(SafeName) const SafeNameForm = withStyles(styles)(SafeName)
const SafeNamePage = () => (controls: React$Node) => ( const SafeNamePage = () => (controls: React$Node) => (
<OpenPaper controls={controls}> <OpenPaper controls={controls} container={600}>
<SafeNameForm /> <SafeNameForm />
</OpenPaper> </OpenPaper>
) )

View File

@ -19,9 +19,6 @@ type Props = {
} }
const styles = () => ({ const styles = () => ({
root: {
maxWidth: '450px',
},
owners: { owners: {
paddingLeft: md, paddingLeft: md,
}, },
@ -44,7 +41,7 @@ const SafeThreshold = ({ classes, values }: Props) => {
const numOwners = getNumOwnersFrom(values) const numOwners = getNumOwnersFrom(values)
return ( return (
<Block className={classes.root}> <React.Fragment>
<Block className={classes.title} margin="md"> <Block className={classes.title} margin="md">
<Paragraph size="lg" color="primary" weight="bolder" noMargin> <Paragraph size="lg" color="primary" weight="bolder" noMargin>
Set the required owner confirmations: Set the required owner confirmations:
@ -85,7 +82,7 @@ const SafeThreshold = ({ classes, values }: Props) => {
</Paragraph> </Paragraph>
</Col> </Col>
</Row> </Row>
</Block> </React.Fragment>
) )
} }
@ -93,7 +90,7 @@ const SafeThresholdForm = withStyles(styles)(SafeThreshold)
const SafeOwnersPage = () => (controls: React$Node, { values }: Object) => ( const SafeOwnersPage = () => (controls: React$Node, { values }: Object) => (
<React.Fragment> <React.Fragment>
<OpenPaper controls={controls}> <OpenPaper controls={controls} container={450}>
<SafeThresholdForm values={values} /> <SafeThresholdForm values={values} />
</OpenPaper> </OpenPaper>
</React.Fragment> </React.Fragment>