Passing Stepper controls down to the Paper step component

This commit is contained in:
Adolfo Panizo 2018-09-16 09:47:22 +02:00
parent b594d3098c
commit 6edbf338bc
2 changed files with 17 additions and 14 deletions

View File

@ -3,6 +3,7 @@ import * as React from 'react'
import Button from '~/components/layout/Button' import Button from '~/components/layout/Button'
import Col from '~/components/layout/Col' import Col from '~/components/layout/Col'
import Row from '~/components/layout/Row' import Row from '~/components/layout/Row'
import { sm } from '~/theme/variables'
type ControlProps = { type ControlProps = {
next: string, next: string,
@ -14,15 +15,13 @@ type ControlProps = {
const controlStyle = { const controlStyle = {
backgroundColor: 'white', backgroundColor: 'white',
padding: '8px', padding: sm,
borderBottomRightRadius: '4px',
borderBottomLeftRadius: '4px',
} }
const ControlButtons = ({ const ControlButtons = ({
next, back, firstPage, onPrevious, disabled, next, back, firstPage, onPrevious, disabled,
}: ControlProps) => ( }: ControlProps) => (
<Row style={controlStyle} align="end" margin="lg" grow> <Row style={controlStyle} align="end" grow>
<Col xs={12} end="xs"> <Col xs={12} end="xs">
<Button <Button
type="button" type="button"

View File

@ -130,6 +130,19 @@ class GnoStepper extends React.PureComponent<Props, State> {
> >
{(submitting: boolean, validating: boolean, ...rest: any) => { {(submitting: boolean, validating: boolean, ...rest: any) => {
const disabled = disabledWhenValidating ? submitting || validating : submitting const disabled = disabledWhenValidating ? submitting || validating : submitting
const controls = (
<React.Fragment>
<Hairline />
<Controls
disabled={disabled}
finishedTx={finishedTransaction}
finishedButton={finished}
onPrevious={this.previous}
firstPage={page === 0}
lastPage={isLastPage}
/>
</React.Fragment>
)
return ( return (
<Stepper classes={{ root: classes.root }} activeStep={page} orientation="vertical"> <Stepper classes={{ root: classes.root }} activeStep={page} orientation="vertical">
@ -137,16 +150,7 @@ class GnoStepper extends React.PureComponent<Props, State> {
<FormStep key={label}> <FormStep key={label}>
<StepLabel>{label}</StepLabel> <StepLabel>{label}</StepLabel>
<StepContent> <StepContent>
{activePage(rest)} {activePage(controls, rest)}
<Hairline />
<Controls
disabled={disabled}
finishedTx={finishedTransaction}
finishedButton={finished}
onPrevious={this.previous}
firstPage={page === 0}
lastPage={isLastPage}
/>
</StepContent> </StepContent>
</FormStep> </FormStep>
))} ))}