4.0.0 ā€¢ Published 5 years ago

@telus/telus-wizard v4.0.0

Weekly downloads
15
License
MIT
Repository
github
Last release
5 years ago

telus-wizard

version Build Status

A magical React component for builing step flows.

šŸ§™ā€ā™‚ļøšŸ§™ā€ā™€ļø

Install

To include in your application:

npm install @telus/telus-wizard --save

Usage

Import the component:

import Wizard from '@telus/telus-wizard'

Pass it any components you like as direct children - Wizard displays the first one by default.

function MyWizard() {
  return (
    <Wizard>
      <FirstStep />
      <AnotherStep stepId="myCoolStep" />
      <LastStep />
    </Wizard>
  )
}

// Displays `FirstStep` when the wizard mounts.

You can even map over an array to provide children:

function AnotherWiz() {
  return (
    <Wizard>
      {mySteps.map(step => <SomeComponent key={step.someIdProperty}>)}
    </Wizard>
  )
}

// (Rememeber, React requires a unique `key` prop for each child)

Pass any other props you want to your steps:

function YetAnotherWiz({ someProp }) {
  return (
    <Wizard>
      <FirstStep custom={true} />
      <AnotherStep anything="you want!" />
      <LastStep testId="last-step-test" passedDown={someProp} />
    </Wizard>
  )
}

Wizard Props

prop namedescriptiontyperequired
childrenThe components you want to render as steps in the wizard.array of React elements*
transitionPass false to disable CSS transitions (defaults to true)boolean

Step Props

Wizard passes these props to each of its direct children:

prop namedescriptiontype
nextNavigates to the next step, in the order steps were passed to Wizardfunction
previousWizard remembers where you were! Navigates back one step in your history.function
goToNavigates to any step by index (the first step is represented by the number 0), or stepId.function

Local Development

If you want to work locally on this package, run:

npm run setup-local

Github: @telusĀ ā€¢ Twitter: @telusdigital