react-flow-controller
v0.0.5
Published
The Flow Controller is a component that consists of several steps and dictates the order that the steps can be used, notifies the user of the current progress through the steps, and what steps are remaining.
Downloads
3
Readme
React Flow Controller
The Flow Controller is a component that consists of several steps and dictates the order that the steps can be used, notifies the user of the current progress through the steps, and what steps are remaining.
Purpose
The purpose of this package is the following:
- Provide a clean, simple interface for creating a user interface that directs the user through a sequence of steps.
- This interface will enable a very flexible system for styling the UI.
- The flow controller will be agnostic to the functioning of its child components except insofar as they permit the verification of the individual components, each referred to as a step.
Usage
Installation
Run $ yarn add react-flow-controller
Requirements
- React Flow Controller requires the use of React Router
- Run
yarn add react-router-dom
in your project - If its is not already somewhere in your project, add a
<Router/>
- specifically BrowserRouter. This component is needed in order to use Link and link to the first step of your flow controller.
Props
title
- optional stringcompletionIndicator
- optional react component that itself takes anisCompleted
prop. Any other props for this component will be ignored. By default a component is provided to render a check mark next to the step title in the progress indicator. If not completion indicator is desired, you can passcompletionIndicator={() => null}
to the<FlowControllerRenderer/>
, but what fun is that?steps
- this prop is an array of objects with the shape
{
component: React component
label: string,
link: string,
isCompleted: boolean,
}
Since the component that makes up a step will nearly by necessity take props itself, the way to format these components is like so:
...
component: ReactComponent({prop1: prop1})
...
Integration
React Flow Controller is agnostic to the functioning of the individual step components except that each step component must be able to signal that the work taking place there is complete and the user can advance to the next step. See the
- Add a
<FlowControllerRenderer>
element somewhere within the router. - Use a
<Link>
element somewhere will load the Flow Controller. If the location where the Flow Controller is launched is a nested route, the<Link>
to
property should usematch.pathname
as detailed here so that the Flow Controller will add as another nested set of routes. <FlowControllerRenderer>
takes three props,title
andcompletionIndicator
are optional as detailed above, whilesteps
is more involved.- When the work in each step is completed - thereby changing appropriate member of the
steps
array'sisCompleted
property, the Flow Controller will allow the user to advance to the next step, either by the "Next" button or by using the links in the Progress Indicator. When all the steps haveisCompleted
true, the "Finish" button will be enabled. Upon clicking "Finish" the url will return to where the flow controller began.
Styling
- All the elements of the Flow Controller have CSS class names to enable whatever sort of styling is desired.
- The example included shows how these classes may be used.
- There is a default styles
.css
file included - import it withimport react-flow-controller/dist/DefaultStyles.css
Examples
Both examples share the same components.
- Example where the Flow Controller is nested within other routes
- Example where the Flow Controller is not nested
MVP Features
- Enable adding or removing the controller
- Have a system for moving through steps
- Have a system for determining which steps are verified and which are not.
- Redirect to last verified step if attempting to navigate to an unverified step.
- Include a progress indicator that can also link to previous steps
- Last step will have a button labeled "FINISH"
This project was bootstrapped with Create React App.