npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-gen-wizard-watson

v0.1.1

Published

Generic react component for creating wizards, and passing data between steps

Downloads

5

Readme

react-gen-wizard

Generic react component for creating wizards, and passing arbitrary data between the wizard's steps.

Prerequisites

  • React 0.14, and above

Installation

npm install react-gen-wizard-watson

How to use

Writing your component

Each step in the wizard is a react component. Your component needs to implement two methods, onPrev() & onNext(). These methods will be called if the previous, or next, button has been clicked while the component was active. These methods are used to add new, change, and/or reset data, for the next or previous step. Two callback props, onPrevEnded(dataObj) & onNextEnded(dataObj), are injected into your component, and should be raised at the end of onPrev, and onNext. The dataObj parameter, will be passed to the next, or previous, component, depending on what the user clicked.

####Example step component:####

import React from 'react';

export default class TestComponent extends React.Component {
  _getData(step) {
    var dataToPass = Object.assign({}, this.props.data);
    dataToPass.step = step;

    return dataToPass;
  }

  onNext() {
    console.log('onNext called');
    this.props.onNextEnded(this._getData(++this.props.data.step));
  }

  onPrev() {
    console.log('onPrev called');    
    this.props.onPrevEnded(this._getData(--this.props.data.step));
  }

  render() {
    return <div>Hello I am just a test component :). I am step {this.props.data.step}</div>;
  }
}

Style

In order to use the default style, import the css/Wizard.css file into your page.

##Using the wizard component##

import Wizard from 'react-gen-wizard';

export default class TestWizard extends React.Component {
  render() {
    return <Wizard components={acquireComponents} onFinish={this.props.onFinish} />;
  }
}
  • onFinish(data) - Required. Will be raised once the last step raises the onNextEnded callback. It receives the data from the last step.
  • components - Required. Configuration of components that will be used as steps. See below.
  • initialData - optional. Initial data to be passed to the first step component. Will be injected into props.data.

###Configuring your steps components### The Wizard component, has a property called components, which is an array of objects, that configure each wizard step. Each component configuration object has the following shape:

{
    name: 'Title',
    component: StepComponentName,
    additionalProps: {},
    showButtons: true,
    breadcrumbNamePath: 'prop.to.show'
  }
  • name - Required. Is used as the steps title, and in case breadcrumbNamePath doesn't exist, will be used in breadcrumbs.
  • component - Required. Your step component.
  • additionalProps - Optional. Props you can inject directly into the current step.
  • showButtons - Optional, default true. Should the next and previous buttons be shown. This is used for cases your step, should automatically move to the next, or previous, step. The automatic move would occur by your component raising the onNextEnded() || onPrevEnded().
  • breadcrumbNamePath - Optional. Path to property in the passed around data object, that will be used as the breadcrumb title. This can be used if you would like to show user data received from a step, in the breadcrumbs.

Example Code

The example folder contains an example jspm project.

cd into the example folder

Install jspm & jspm-server

npm install jspm jspm-server

Install dependencies

jspm install

Run

jspm-server