Editing controls in Stepper component
This commit is contained in:
parent
a3fd30367f
commit
9b6feafb36
|
@ -1,26 +1,39 @@
|
||||||
// @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>
|
||||||
|
<Col xs={12} end="xs">
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
disabled={firstPage || disabled}
|
disabled={firstPage || disabled}
|
||||||
onClick={onPrevious}
|
onClick={onPrevious}
|
||||||
|
size="small"
|
||||||
>
|
>
|
||||||
Back
|
{back}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
size="small"
|
||||||
variant="raised"
|
variant="raised"
|
||||||
color="primary"
|
color="primary"
|
||||||
type="submit"
|
type="submit"
|
||||||
|
@ -28,7 +41,8 @@ const ControlButtons = ({
|
||||||
>
|
>
|
||||||
{next}
|
{next}
|
||||||
</Button>
|
</Button>
|
||||||
</React.Fragment>
|
</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,8 +138,7 @@ 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}
|
||||||
|
@ -149,8 +147,6 @@ class GnoStepper extends React.PureComponent<Props, State> {
|
||||||
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