Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,19 @@ For example:

#### Props Accessible On Each Child (_Step_) Component

| Prop | Data Type | Parameters |
| ------------- | ---------- | ------------------------------------- |
| isActive | `boolean` |
| currentStep | `integer` |
| totalSteps | `integer` |
| firstStep | `function` |
| lastStep | `function` |
| nextStep | `function` |
| previousStep | `function` |
| goToStep | `function` | `integer` : `goToStep(3)` |
| goToStep | `function` | `string` : `goToStep('step3')` |
| goToNamedStep | `function` | `string` : `goToNamedStep('contact')` |
| Prop | Data Type | Parameters |
| --------------- | ---------- | ------------------------------------- |
| isActive | `boolean` |
| currentStep | `integer` |
| currentStepName | `string` |
| totalSteps | `integer` |
| firstStep | `function` |
| lastStep | `function` |
| nextStep | `function` |
| previousStep | `function` |
| goToStep | `function` | `integer` : `goToStep(3)` |
| goToStep | `function` | `string` : `goToStep('step3')` |
| goToNamedStep | `function` | `string` : `goToNamedStep('contact')` |

---

Expand All @@ -111,12 +112,12 @@ The default transitions are using CSS taken from [animate.css](https://daneden.g

```jsx
let custom = {
enterRight: 'your custom css transition classes',
enterLeft : 'your custom css transition classes',
exitRight : 'your custom css transition classes',
exitLeft : 'your custom css transition classes'
}
<StepWizard transitions={custom}>...</StepWizard>
enterRight: "your custom css transition classes",
enterLeft: "your custom css transition classes",
exitRight: "your custom css transition classes",
exitLeft: "your custom css transition classes",
};
<StepWizard transitions={custom}>...</StepWizard>;
```

### Initial Step
Expand Down Expand Up @@ -145,7 +146,7 @@ When isHashEnabled is true, `goToStep` accepts a `hashKey` as an argument

### Use named steps

If we don't need to use hash keys and just simply want to switch steps by their names we can use use `stepName`.
If we don't need to use hash keys and just simply want to switch steps by their names we can use use `stepName`.

```jsx
<StepWizard>
Expand Down
1 change: 1 addition & 0 deletions src/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ exports[`Step Wizard Component nav 1`] = `
>
<div
currentStep={1}
currentStepName="step1"
firstStep={[Function]}
goToNamedStep={[Function]}
goToStep={[Function]}
Expand Down
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ export default class StepWizard extends PureComponent {
return this.getSteps().length;
}

get currentStepName() {
return this.state.namedSteps[this.state.activeStep];
}

getSteps = () => React.Children.toArray(this.props.children);

/** Go to first step */
Expand Down Expand Up @@ -186,6 +190,7 @@ export default class StepWizard extends PureComponent {
const props = {
currentStep: this.currentStep,
totalSteps: this.totalSteps,
currentStepName: this.currentStepName,
/** Functions */
nextStep: this.nextStep,
previousStep: this.previousStep,
Expand Down