Editing controls in Stepper component
This commit is contained in:
parent
a3fd30367f
commit
9b6feafb36
|
@ -1,34 +1,48 @@
|
||||||
// @flow
|
// @flow
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import Button from '~/components/layout/Button'
|
import Button from '~/components/layout/Button'
|
||||||
|
import Col from '~/components/layout/Col'
|
||||||
|
import Row from '~/components/layout/Row'
|
||||||
|
|
||||||
type ControlProps = {
|
type ControlProps = {
|
||||||
next: string,
|
next: string,
|
||||||
|
back: string,
|
||||||
onPrevious: () => void,
|
onPrevious: () => void,
|
||||||
firstPage: boolean,
|
firstPage: boolean,
|
||||||
disabled: boolean,
|
disabled: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const controlStyle = {
|
||||||
|
backgroundColor: 'white',
|
||||||
|
padding: '8px',
|
||||||
|
borderBottomRightRadius: '4px',
|
||||||
|
borderBottomLeftRadius: '4px',
|
||||||
|
}
|
||||||
|
|
||||||
const ControlButtons = ({
|
const ControlButtons = ({
|
||||||
next, firstPage, onPrevious, disabled,
|
next, back, firstPage, onPrevious, disabled,
|
||||||
}: ControlProps) => (
|
}: ControlProps) => (
|
||||||
<React.Fragment>
|
<Row style={controlStyle} align="end" margin="lg" grow>
|
||||||
<Button
|
<Col xs={12} end="xs">
|
||||||
type="button"
|
<Button
|
||||||
disabled={firstPage || disabled}
|
type="button"
|
||||||
onClick={onPrevious}
|
disabled={firstPage || disabled}
|
||||||
>
|
onClick={onPrevious}
|
||||||
Back
|
size="small"
|
||||||
</Button>
|
>
|
||||||
<Button
|
{back}
|
||||||
variant="raised"
|
</Button>
|
||||||
color="primary"
|
<Button
|
||||||
type="submit"
|
size="small"
|
||||||
disabled={disabled}
|
variant="raised"
|
||||||
>
|
color="primary"
|
||||||
{next}
|
type="submit"
|
||||||
</Button>
|
disabled={disabled}
|
||||||
</React.Fragment>
|
>
|
||||||
|
{next}
|
||||||
|
</Button>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
)
|
)
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -47,7 +61,9 @@ const Controls = ({
|
||||||
? <React.Fragment>{finishedButton}</React.Fragment>
|
? <React.Fragment>{finishedButton}</React.Fragment>
|
||||||
: <ControlButtons
|
: <ControlButtons
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
next={lastPage ? 'Finish' : 'Next'}
|
back={firstPage ? 'Cancel' : 'Back'}
|
||||||
|
// eslint-disable-next-line
|
||||||
|
next={firstPage ? 'Start' : lastPage ? 'Finish' : 'Next'}
|
||||||
firstPage={firstPage}
|
firstPage={firstPage}
|
||||||
onPrevious={onPrevious}
|
onPrevious={onPrevious}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -6,9 +6,8 @@ import StepContent from '@material-ui/core/StepContent'
|
||||||
import { withStyles } from '@material-ui/core/styles'
|
import { withStyles } from '@material-ui/core/styles'
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import GnoForm from '~/components/forms/GnoForm'
|
import GnoForm from '~/components/forms/GnoForm'
|
||||||
|
import Hairline from '~/components/layout/Hairline'
|
||||||
import Button from '~/components/layout/Button'
|
import Button from '~/components/layout/Button'
|
||||||
import Col from '~/components/layout/Col'
|
|
||||||
import Row from '~/components/layout/Row'
|
|
||||||
import Controls from './Controls'
|
import Controls from './Controls'
|
||||||
|
|
||||||
export { default as Step } from './Step'
|
export { default as Step } from './Step'
|
||||||
|
@ -139,18 +138,15 @@ class GnoStepper extends React.PureComponent<Props, State> {
|
||||||
<StepLabel>{label}</StepLabel>
|
<StepLabel>{label}</StepLabel>
|
||||||
<StepContent>
|
<StepContent>
|
||||||
{activePage(rest)}
|
{activePage(rest)}
|
||||||
<Row align="end" margin="lg" grow>
|
<Hairline />
|
||||||
<Col xs={12} center="xs">
|
<Controls
|
||||||
<Controls
|
disabled={disabled}
|
||||||
disabled={disabled}
|
finishedTx={finishedTransaction}
|
||||||
finishedTx={finishedTransaction}
|
finishedButton={finished}
|
||||||
finishedButton={finished}
|
onPrevious={this.previous}
|
||||||
onPrevious={this.previous}
|
firstPage={page === 0}
|
||||||
firstPage={page === 0}
|
lastPage={isLastPage}
|
||||||
lastPage={isLastPage}
|
/>
|
||||||
/>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</StepContent>
|
</StepContent>
|
||||||
</FormStep>
|
</FormStep>
|
||||||
))}
|
))}
|
||||||
|
|
|
@ -14,7 +14,7 @@ type Props = {
|
||||||
margin?: Size,
|
margin?: Size,
|
||||||
}
|
}
|
||||||
|
|
||||||
const Hairline = ({ margin = 'md' }: Props) => {
|
const Hairline = ({ margin }: Props) => {
|
||||||
const style = calculateStyleFrom(margin)
|
const style = calculateStyleFrom(margin)
|
||||||
|
|
||||||
return <div style={style} />
|
return <div style={style} />
|
||||||
|
|
|
@ -9,6 +9,8 @@ const styles = () => ({
|
||||||
root: {
|
root: {
|
||||||
padding: lg,
|
padding: lg,
|
||||||
maxWidth: '770px',
|
maxWidth: '770px',
|
||||||
|
borderBottomRightRadius: '0px',
|
||||||
|
borderBottomLeftRadius: '0px',
|
||||||
},
|
},
|
||||||
container: {
|
container: {
|
||||||
maxWidth: '600px',
|
maxWidth: '600px',
|
||||||
|
|
|
@ -16,6 +16,6 @@ export const getSize = (size: Size) => {
|
||||||
case 'xl':
|
case 'xl':
|
||||||
return xl
|
return xl
|
||||||
default:
|
default:
|
||||||
return md
|
return '0px'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue