├── .babelrc ├── .editorconfig ├── .eslintignore ├── .flowconfig ├── .gitignore ├── .npmignore ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── example ├── .gitignore ├── README.md ├── package.json ├── public │ ├── favicon.ico │ └── index.html ├── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── index.css │ ├── index.js │ └── store.js └── yarn.lock ├── flow-typed └── npm │ ├── enzyme_v2.3.x.js │ ├── jest_v17.x.x.js │ ├── json-predicate-v0.9.x.js │ ├── react-redux_v4.x.x.js │ └── redux_v3.x.x.js ├── package.json ├── rollup.config.js ├── src ├── Step.js ├── Step.spec.js ├── Wizard.js ├── Wizard.spec.js ├── actionTypes.js ├── actions.js ├── actions.spec.js ├── index.js ├── match.js ├── match.spec.js ├── reducer.js ├── reducer.spec.js └── types.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": ["transform-runtime"], 3 | "presets": [ 4 | "react", 5 | "es2015", 6 | "stage-2" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | trim_trailing_whitespace = true 7 | charset = utf-8 8 | indent_style = space 9 | indent_size = 2 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | src/**/*.spec.js 2 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/node_modules/.* 3 | 4 | [include] 5 | flow-typed/npm/json-predicate.v0.9.x.js 6 | flow-typed/npm/react-redux_v4.x.x.js 7 | flow-typed/npm/redux_v3.x.x.js 8 | flow-typed/npm/enzyme_v2.3.x.js 9 | flow-typed/npm/jest_v17.x.x.js 10 | 11 | [libs] 12 | 13 | [options] 14 | esproposal.class_static_fields=enable 15 | esproposal.class_instance_fields=enable 16 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | src/ 2 | test/ 3 | example/ 4 | .babelrc 5 | .editorconfig 6 | .npmignore 7 | .travis.yml 8 | rollup.config.js 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "6" 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. 4 | 5 | 6 | # [0.2.0](https://github.com/sebinsua/react-redux-wizard/compare/v0.1.1...v0.2.0) (2016-12-12) 7 | 8 | 9 | ### Features 10 | 11 | * **json-predicate:** wrote a json-predicate flowtype definition ([04bb87e](https://github.com/sebinsua/react-redux-wizard/commit/04bb87e)) 12 | * **json-predicate|match:** reducer can switch step based on json-predicates ([4914bae](https://github.com/sebinsua/react-redux-wizard/commit/4914bae)) 13 | 14 | 15 | 16 | 17 | ## [0.1.1](https://github.com/sebinsua/react-redux-wizard/compare/v0.1.0...v0.1.1) (2016-12-12) 18 | 19 | 20 | ### Bug Fixes 21 | 22 | * **previous:** base previous off a stack ([f7212b5](https://github.com/sebinsua/react-redux-wizard/commit/f7212b5)) 23 | 24 | 25 | 26 | 27 | # 0.1.0 (2016-12-12) 28 | 29 | 30 | ### Features 31 | 32 | * **Wizard|Step:** early version of Wizard created ([2bcaa59](https://github.com/sebinsua/react-redux-wizard/commit/2bcaa59)) 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `react-redux-wizard` [![Build Status](https://travis-ci.org/sebinsua/react-redux-wizard.png)](https://travis-ci.org/sebinsua/react-redux-wizard) [![npm version](https://badge.fury.io/js/react-redux-wizard.svg)](https://npmjs.org/package/react-redux-wizard) 2 | > A simple wizard for React. 3 | 4 | This component allows you to represent the flow of a wizard with JSX. 5 | 6 | > **NOTE:** I have not worked on an integration with a React router, so if you require [deep-linking](https://en.wikipedia.org/wiki/Deep_linking) it's not quite ready. It is however completely functional for wizards within modals, and for small sign-up wizards, etc. 7 | 8 | ## Example 9 | 10 | ```js 11 | import React from 'react' 12 | import { Wizard, Step, match } from 'react-redux-wizard' 13 | 14 | const StepOne = ({ name, previous, next }) => 15 |
{name}
16 | const StepTwo = ({ name, previous, next }) => 17 |
0.5 ? 'extra-flow' : null })}>{name}
18 | const StepThree = ({ name, previous, next }) => 19 |
{name}
20 | 21 | function SomeFormWizard () { 22 | return ( 23 | 24 | 25 | 33 | 34 | 35 | 36 | ) 37 | } 38 | 39 | export default SomeFormWizard 40 | ``` 41 | 42 | ## Install 43 | 44 | ```sh 45 | yarn add react-redux-wizard 46 | ``` 47 | 48 | ## API 49 | 50 | ### Reducer 51 | 52 | Your root reducer should use the `reducer` exported by this module against its `wizards` key. 53 | 54 | ### Component 55 | 56 | #### `{...steps}` 57 | 58 | #### `` 59 | 60 | `StepPredicate` is an `Array<{ predicate: JsonPredicate, to: string }>` where `JsonPredicate` [follows the JSON Predicate spec](https://github.com/MalcolmDwyer/json-predicate). `match(string, StepNameToValues)` is just sugar for generating these predicates when given some `Step` names and the associated `values` to check for at a `pathName`. 61 | 62 | We can pass a functions in but we really shouldn't as doing so means that the store can no longer be fully serialized. However, it is possible: 63 | 64 | > `StepFn` has the form `(values: KeyValueObject, wizardState: KeyValueObject) => ?string` 65 | and can be used to pick the next step depending on either the values emitted from a component, 66 | or some of the wizard's internal state. 67 | 68 | #### ` void} next={(values: KeyValueObject) => void} />` 69 | 70 | `` should receive two functions `previous` and `next`. 71 | 72 | `previous` will take zero arguments and go to the previous step, 73 | while `next` expects a `values` key-value object. 74 | 75 | These are different functions from the ones you passed into ``. 76 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | node_modules 5 | 6 | # testing 7 | coverage 8 | 9 | # production 10 | build 11 | 12 | # misc 13 | .DS_Store 14 | .env 15 | npm-debug.log 16 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app). 2 | 3 | Below you will find some information on how to perform common tasks.
4 | You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md). 5 | 6 | ## Table of Contents 7 | 8 | - [Updating to New Releases](#updating-to-new-releases) 9 | - [Sending Feedback](#sending-feedback) 10 | - [Folder Structure](#folder-structure) 11 | - [Available Scripts](#available-scripts) 12 | - [npm start](#npm-start) 13 | - [npm test](#npm-test) 14 | - [npm run build](#npm-run-build) 15 | - [npm run eject](#npm-run-eject) 16 | - [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor) 17 | - [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor) 18 | - [Installing a Dependency](#installing-a-dependency) 19 | - [Importing a Component](#importing-a-component) 20 | - [Adding a Stylesheet](#adding-a-stylesheet) 21 | - [Post-Processing CSS](#post-processing-css) 22 | - [Adding Images and Fonts](#adding-images-and-fonts) 23 | - [Using the `public` Folder](#using-the-public-folder) 24 | - [Using Global Variables](#using-global-variables) 25 | - [Adding Bootstrap](#adding-bootstrap) 26 | - [Adding Flow](#adding-flow) 27 | - [Adding Custom Environment Variables](#adding-custom-environment-variables) 28 | - [Can I Use Decorators?](#can-i-use-decorators) 29 | - [Integrating with a Node Backend](#integrating-with-a-node-backend) 30 | - [Proxying API Requests in Development](#proxying-api-requests-in-development) 31 | - [Using HTTPS in Development](#using-https-in-development) 32 | - [Generating Dynamic `` Tags on the Server](#generating-dynamic-meta-tags-on-the-server) 33 | - [Running Tests](#running-tests) 34 | - [Filename Conventions](#filename-conventions) 35 | - [Command Line Interface](#command-line-interface) 36 | - [Version Control Integration](#version-control-integration) 37 | - [Writing Tests](#writing-tests) 38 | - [Testing Components](#testing-components) 39 | - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries) 40 | - [Initializing Test Environment](#initializing-test-environment) 41 | - [Focusing and Excluding Tests](#focusing-and-excluding-tests) 42 | - [Coverage Reporting](#coverage-reporting) 43 | - [Continuous Integration](#continuous-integration) 44 | - [Disabling jsdom](#disabling-jsdom) 45 | - [Experimental Snapshot Testing](#experimental-snapshot-testing) 46 | - [Editor Integration](#editor-integration) 47 | - [Developing Components in Isolation](#developing-components-in-isolation) 48 | - [Making a Progressive Web App](#making-a-progressive-web-app) 49 | - [Deployment](#deployment) 50 | - [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing) 51 | - [Building for Relative Paths](#building-for-relative-paths) 52 | - [Firebase](#firebase) 53 | - [GitHub Pages](#github-pages) 54 | - [Heroku](#heroku) 55 | - [Modulus](#modulus) 56 | - [Netlify](#netlify) 57 | - [Now](#now) 58 | - [S3 and CloudFront](#s3-and-cloudfront) 59 | - [Surge](#surge) 60 | - [Troubleshooting](#troubleshooting) 61 | - [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra) 62 | - [`npm run build` silently fails](#npm-run-build-silently-fails) 63 | - [Something Missing?](#something-missing) 64 | 65 | ## Updating to New Releases 66 | 67 | Create React App is divided into two packages: 68 | 69 | * `create-react-app` is a global command-line utility that you use to create new projects. 70 | * `react-scripts` is a development dependency in the generated projects (including this one). 71 | 72 | You almost never need to update `create-react-app` itself: it delegates all the setup to `react-scripts`. 73 | 74 | When you run `create-react-app`, it always creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically. 75 | 76 | To update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions. 77 | 78 | In most cases bumping the `react-scripts` version in `package.json` and running `npm install` in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes. 79 | 80 | We commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly. 81 | 82 | ## Sending Feedback 83 | 84 | We are always open to [your feedback](https://github.com/facebookincubator/create-react-app/issues). 85 | 86 | ## Folder Structure 87 | 88 | After creation, your project should look like this: 89 | 90 | ``` 91 | my-app/ 92 | README.md 93 | node_modules/ 94 | package.json 95 | public/ 96 | index.html 97 | favicon.ico 98 | src/ 99 | App.css 100 | App.js 101 | App.test.js 102 | index.css 103 | index.js 104 | logo.svg 105 | ``` 106 | 107 | For the project to build, **these files must exist with exact filenames**: 108 | 109 | * `public/index.html` is the page template; 110 | * `src/index.js` is the JavaScript entry point. 111 | 112 | You can delete or rename the other files. 113 | 114 | You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.
115 | You need to **put any JS and CSS files inside `src`**, or Webpack won’t see them. 116 | 117 | Only files inside `public` can be used from `public/index.html`.
118 | Read instructions below for using assets from JavaScript and HTML. 119 | 120 | You can, however, create more top-level directories.
121 | They will not be included in the production build so you can use them for things like documentation. 122 | 123 | ## Available Scripts 124 | 125 | In the project directory, you can run: 126 | 127 | ### `npm start` 128 | 129 | Runs the app in the development mode.
130 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 131 | 132 | The page will reload if you make edits.
133 | You will also see any lint errors in the console. 134 | 135 | ### `npm test` 136 | 137 | Launches the test runner in the interactive watch mode.
138 | See the section about [running tests](#running-tests) for more information. 139 | 140 | ### `npm run build` 141 | 142 | Builds the app for production to the `build` folder.
143 | It correctly bundles React in production mode and optimizes the build for the best performance. 144 | 145 | The build is minified and the filenames include the hashes.
146 | Your app is ready to be deployed! 147 | 148 | See the section about [deployment](#deployment) for more information. 149 | 150 | ### `npm run eject` 151 | 152 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 153 | 154 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 155 | 156 | Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 157 | 158 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 159 | 160 | ## Syntax Highlighting in the Editor 161 | 162 | To configure the syntax highlighting in your favorite text editor, head to the [Babel's docs](https://babeljs.io/docs/editors) and follow the instructions. Some of the most popular editors are covered. 163 | 164 | ## Displaying Lint Output in the Editor 165 | 166 | >Note: this feature is available with `react-scripts@0.2.0` and higher. 167 | 168 | Some editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint. 169 | 170 | They are not required for linting. You should see the linter output right in your terminal as well as the browser console. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do. 171 | 172 | You would need to install an ESLint plugin for your editor first. 173 | 174 | >**A note for Atom `linter-eslint` users** 175 | 176 | >If you are using the Atom `linter-eslint` plugin, make sure that **Use global ESLint installation** option is checked: 177 | 178 | > 179 | 180 | Then add this block to the `package.json` file of your project: 181 | 182 | ```js 183 | { 184 | // ... 185 | "eslintConfig": { 186 | "extends": "react-app" 187 | } 188 | } 189 | ``` 190 | 191 | Finally, you will need to install some packages *globally*: 192 | 193 | ```sh 194 | npm install -g eslint-config-react-app@0.3.0 eslint@3.8.1 babel-eslint@7.0.0 eslint-plugin-react@6.4.1 eslint-plugin-import@2.0.1 eslint-plugin-jsx-a11y@2.2.3 eslint-plugin-flowtype@2.21.0 195 | ``` 196 | 197 | We recognize that this is suboptimal, but it is currently required due to the way we hide the ESLint dependency. The ESLint team is already [working on a solution to this](https://github.com/eslint/eslint/issues/3458) so this may become unnecessary in a couple of months. 198 | 199 | ## Installing a Dependency 200 | 201 | The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`: 202 | 203 | ``` 204 | npm install --save 205 | ``` 206 | 207 | ## Importing a Component 208 | 209 | This project setup supports ES6 modules thanks to Babel.
210 | While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead. 211 | 212 | For example: 213 | 214 | ### `Button.js` 215 | 216 | ```js 217 | import React, { Component } from 'react'; 218 | 219 | class Button extends Component { 220 | render() { 221 | // ... 222 | } 223 | } 224 | 225 | export default Button; // Don’t forget to use export default! 226 | ``` 227 | 228 | ### `DangerButton.js` 229 | 230 | 231 | ```js 232 | import React, { Component } from 'react'; 233 | import Button from './Button'; // Import a component from another file 234 | 235 | class DangerButton extends Component { 236 | render() { 237 | return