Skip to content

Commit 7629c70

Browse files
authored
Make better readme (#5)
1 parent 934781b commit 7629c70

File tree

2 files changed

+49
-3
lines changed

2 files changed

+49
-3
lines changed

README.md

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,55 @@
11
# react-wizard-flow
2-
[![CircleCI](https://circleci.com/gh/notwillk/react-wizard-flow.svg?style=shield)](https://circleci.com/gh/notwillk/react-wizard-flow)
32

43
[![npm downloads](https://img.shields.io/npm/dm/react-wizard-flow.svg?style=flat-square)](https://www.npmjs.com/package/react-wizard-flow)
54
[![gzip size](https://img.badgesize.io/https://unpkg.com/react-wizard-flow?compression=gzip&style=flat-square)](https://unpkg.com/react-wizard-flow)
65
[![npm version](https://img.shields.io/npm/v/react-wizard-flows.svg?style=flat-square)](https://www.npmjs.com/package/react-wizard-flow)
76
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
87

8+
## Usage
9+
10+
```typescript
11+
import { createWizardFlow, useWizardFlow } from 'react-wizard-flow';
12+
13+
enum TestSteps {
14+
step1,
15+
step2,
16+
}
17+
18+
const WizardFlow = createWizardFlow(TestSteps);
19+
20+
function Step1() {
21+
const { transition, close } = useWizardFlow(WizardFlow);
22+
return (
23+
<div>
24+
<header>Step 1</header>
25+
<button onClick={() => transition(TestSteps.step1)}>To Step 1</button>
26+
<button onClick={() => transition(TestSteps.step2)}>To Step 2</button>
27+
<button onClick={close}>Close</button>
28+
</div>
29+
);
30+
}
31+
32+
function Step2() {
33+
const { transition, close } = useWizardFlow(WizardFlow);
34+
return (
35+
<div>
36+
<header>Step 1</header>
37+
<button onClick={() => transition(TestSteps.step1)}>To Step 1</button>
38+
<button onClick={() => transition(TestSteps.step2)}>To Step 2</button>
39+
<button onClick={close}>Close</button>
40+
</div>
41+
);
42+
}
43+
44+
const STEPS = {
45+
[TestSteps.step1]: <Step1 />,
46+
[TestSteps.step2]: <Step2 />,
47+
};
48+
49+
export default function() {
50+
const onClose = () => { console.log('Flow closed'); }
51+
return <WizardFlow.Provider initialStep={TestSteps.step1} steps={STEPS} onClose={onClose} />
52+
}
53+
```
54+
955
This README was generated by [anansi](https://github.com/ntucker/anansi/tree/master/packages/generator-js#readme).

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "react-wizard-flow",
3-
"version": "0.0.1",
3+
"version": "1.0.0",
44
"packageManager": "[email protected]",
5-
"description": "react-wizard-flow - An Anansi project",
5+
"description": "react-wizard-flow",
66
"scripts": {
77
"lint": "eslint src --ext .ts,.tsx",
88
"format": "npm run lint --fix",

0 commit comments

Comments
 (0)