Adding helper function to calculate penultimate and last page in Stepper
This commit is contained in:
parent
a64278bd51
commit
9d882e7a8b
|
@ -129,13 +129,16 @@ class GnoStepper extends React.PureComponent<Props, State> {
|
||||||
return this.next(values)
|
return this.next(values)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isLastPage = page => page === this.props.steps.length - 1
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
steps, children, classes, disabledWhenValidating = false,
|
steps, children, classes, disabledWhenValidating = false,
|
||||||
} = this.props
|
} = this.props
|
||||||
const { page, values } = this.state
|
const { page, values } = this.state
|
||||||
const activePage = this.getActivePageFrom(children)
|
const activePage = this.getActivePageFrom(children)
|
||||||
const isLastPage = page === steps.length - 1
|
const lastPage = this.isLastPage(page)
|
||||||
|
const penultimate = this.isLastPage(page + 1)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
|
@ -153,7 +156,8 @@ class GnoStepper extends React.PureComponent<Props, State> {
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
onPrevious={this.previous}
|
onPrevious={this.previous}
|
||||||
firstPage={page === 0}
|
firstPage={page === 0}
|
||||||
lastPage={isLastPage}
|
lastPage={lastPage}
|
||||||
|
penultimate={penultimate}
|
||||||
/>
|
/>
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue