You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+67-66Lines changed: 67 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,46 +4,57 @@
4
4
>
5
5
> \-- _Albus Dumbledore_
6
6
7
-
## What is React [Albus](http://u.kanobu.ru/comments/images/3c682662-4e19-49c6-b85b-539db47ff838.gif)?
8
-
React Albus is a React component library for building declarative multi-step flows (also known as Wizards). You are responsible for writing your own steps and configuring their ordering, but React Albus will maintain the flow-related state for you.
7
+
## What is React Albus?
8
+
React Albus is a React component library used to build declarative multi-step journeys (also known as Wizards). You define your step content and ordering and React Albus will manage the journey-related state for you.
9
9
10
-
React Albus also allows you to create routed flows, conditionally skip steps in your flow, and create custom elements to suit your needs.
10
+
React Albus is otherwise unopinionated and allows you to compose funcionality such as routing, animation, and analytics however you see fit.
@@ -54,89 +65,79 @@ Check out the [demo page](http://americanexpress.io/react-albus)!
54
65
## API
55
66
56
67
-[`<Wizard>`](#wizard)
57
-
-[`<Step>`](#step)
58
68
-[`<Steps>`](#steps)
59
-
-[`<Navigation>`](#navigation)
69
+
-[`<Step>`](#step)
60
70
-[`withWizard`](#withwizard)
71
+
-[`wizardShape`](#wizardShape)
61
72
-[`context.wizard`](#contextwizard)
62
73
63
74
---
64
75
65
76
### `<Wizard>`
66
77
67
78
#### Props
68
-
##### `onNext(step, steps, push)`: function *(optional)*
69
-
A function that will be called by Wizard to determine the next step to proceed to.
79
+
##### `onNext(wizard)`: function *(optional)*
80
+
A function that will be called by `<Wizard>` to determine the next step to proceed to.
70
81
71
82
##### Params
72
-
*`step`: An object describing the current step with the structure: `{ path: string, name: string }`.
73
-
*`steps`: An array of `step` objects in the order they were declared in `<Steps>`.
74
-
*`push(path)`: A function that can be called with the `path` of the step that you want to proceed to. Calling this function without arguments will proceed to the next step.
83
+
84
+
*`wizard` (object): The [`context.wizard`](#contextwizard) object.
75
85
76
86
If you do not pass an `onNext` prop, `<Wizard>` will proceed directly to the next step.
77
87
78
-
##### `className`: string *(optional)*
79
-
CSS classes to be added to the `<div>` created by `<Wizard>`.
80
88
##### `render(wizard)`: function *(optional)*
81
89
A function that will be used as the render function of `<Wizard>`.
82
90
83
91
##### Params
84
-
*`wizard`: The [`context.wizard`](#contextwizard) object.
92
+
*`wizard` (object): The [`context.wizard`](#contextwizard) object.
85
93
86
94
---
87
95
88
-
### `<Step>`
89
-
Wraps all the content that will be conditionally shown when the step is active.
96
+
### `<Steps>`
97
+
Wraps all of the `<Step>` components in your journey. The only direct children of `<Steps>` should be `<Step>` components.
90
98
91
99
#### Props
92
-
##### `path`: string
93
-
Unique key for each step.
94
-
##### `className`: string *(optional)*
95
-
CSS classes to be added to the `<div>` created by `<Step>`.
100
+
##### `step`: object ***(optional)***
101
+
An object describing the current step with the structure: `{ id: string }`. Defining a `step` prop will make `<Steps>` a [controlled component](https://facebook.github.io/react/docs/forms.html).
96
102
97
-
In addition to `path` and `className`, any additional props added to `<Step>` will be available on each `step` object. This can be used to add names, descriptions, or other metadata to each step.
103
+
------
98
104
99
-
---
105
+
### `<Step>`
100
106
101
-
### `<Steps>`
102
-
Wraps all of the `<Step>` components for your flow. The only direct children of `<Steps>` should be `<Step>` components.
107
+
Wraps all the content that will be conditionally shown when the step is active.
103
108
104
109
#### Props
105
-
##### `step`: object ***(optional)***
106
-
An object describing the current step with the structure: `{ path: string, name: string }`. Defining this prop will make `<Steps>` a [controlled component](https://facebook.github.io/react/docs/forms.html).
107
110
108
-
---
111
+
##### `id`: string
109
112
110
-
### `<Navigation>`
111
-
Exposes the Wizard navigation functionality for your components to use. Extends its child's props with [`context.wizard`](#contextwizard) and passes [`context.wizard`](#contextwizard) to its render prop.
112
-
#### Props
113
-
##### `render(wizard)`: function *(optional)*
114
-
A function that will be used as the render function of `<Navigation>`.
113
+
Unique key for each step.
115
114
116
-
##### Params
117
-
*`wizard`: The [`context.wizard`](#contextwizard) object.
115
+
In addition to `id`, any additional props added to `<Step>` will be available on each `step` object. This can be used to add names, descriptions, or other metadata to each step.
116
+
117
+
`<WithWizard>` is an alias for `<Step>` that can be used to access [`context.wizard`](#contextwizard) anywhere within the `<Wizard>` tree.
118
118
119
119
---
120
120
121
121
### `withWizard()`
122
-
A higher order component that spreads[`context.wizard`](#contextwizard)across the wrapped component's props.
122
+
A higher order component that adds[`context.wizard`](#contextwizard)as a `wizard ` prop on the wrapped component.
123
123
124
124
---
125
125
126
126
### `context.wizard`
127
-
`<Wizard>`adds this object to context with the following properties:
127
+
`<Wizard>`provides an object on context with the following properties:
128
128
129
-
*`step` (object): Describes the current step with structure: `{ path: string, name: string }`.
129
+
*`step` (object): Describes the current step with structure: `{ id: string }`.
130
130
*`steps` (array): Array of `step` objects in the order they were declared within `<Steps>`.
131
131
*`history` (object): The backing [`history`](https://github.com/ReactTraining/history#properties) object.
132
132
*`next()` (function): Moves to the next step in order.
133
133
*`previous()` (function): Moves to the previous step in order.
134
-
*`go(n)` (function): Moves *n* steps in history.
135
-
*`push(path)` (function): Moves to the step with prop `path`.
134
+
*`go(n)` (function): Moves `n` steps in history.
135
+
*`push(id)` (function): Pushes the step with corresponding `id` onto history.
136
+
*`replace(id)` (function): Replaces the current step in history with the step with corresponding `id`.
136
137
137
138
## Usage with React Router
138
139
139
-
Internally, React Albus uses [history](https://github.com/ReactTraining/history) to maintain the ordering of steps. This makes integrating with React Router (or any other router) as easy as providing Albus with a `history`object and a `basename`where it is living.
140
+
Internally, React Albus uses [history](https://github.com/ReactTraining/history) to maintain the ordering of steps. This makes integrating with React Router (or any other router) as easy as providing `<Wizard>` with `history` and `basename`props.
0 commit comments