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,14 +130,8 @@ 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 = (
return ( <React.Fragment>
<Stepper classes={{ root: classes.root }} activeStep={page} orientation="vertical">
{steps.map(label => (
<FormStep key={label}>
<StepLabel>{label}</StepLabel>
<StepContent>
{activePage(rest)}
<Hairline /> <Hairline />
<Controls <Controls
disabled={disabled} disabled={disabled}
@ -147,6 +141,16 @@ class GnoStepper extends React.PureComponent<Props, State> {
firstPage={page === 0} firstPage={page === 0}
lastPage={isLastPage} lastPage={isLastPage}
/> />
</React.Fragment>
)
return (
<Stepper classes={{ root: classes.root }} activeStep={page} orientation="vertical">
{steps.map(label => (
<FormStep key={label}>
<StepLabel>{label}</StepLabel>
<StepContent>
{activePage(controls, rest)}
</StepContent> </StepContent>
</FormStep> </FormStep>
))} ))}