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

jk-stepper

v1.0.0

Published

React stepper component

Downloads

1

Readme

React material stepper

Implementation of Material Stepper for React. React material stepper encapsulates logic of step state maintianing, and provides API for control over the step resolution

Features

  • Simple, declarative configuration
  • Typescript typings
  • Horizontal and vertical layouts
  • Dynamic steps
  • locking
  • Default material themes provided
  • Customizable by SCSS

Examples

Getting started

import Stepper, { Step } from "react-material-stepper";

const StepperExample = () => (
  <Stepper>
    <Step
      stepId={STEP1}
      data="Step 1 initial state"
      title="Step One"
      description="This step is optional"
    >
      <Step1 />
    </Step>
    <Step stepId={STEP2} title="Step Two" description="Login is required">
      <Step2 />
    </Step>
    <Step stepId={STEP3} title="Step Three" >
      <Step3 />
    </Step>
  </Stepper>
);

Example1: Basic stepper configuration, where Step1, Step2 and Step3 is arbitary user defined components

In order to work with stepper API StepperContext could be used:

import {
  StepperAction,
  StepperContent,
  StepperContext
} from "react-material-stepper";

export const STEP1 = "step-one";

const Step1 = ({ vertical = false }) => {
  const { resolve, getData } = React.useContext(StepperContext);

  const data = getData(STEP1);

  const onSubmit = (event: React.FormEvent) => {
    event.preventDefault();
    // resolve will set data for current step and proceed to the next step
    resolve("step1 resolved data");
  };

  return (
    <StepperContent
      onSubmit={onSubmit}
      actions={
        <StepperAction align="right" type="submit">
          Continue
        </StepperAction>
      }
    >
      Step1 resolved:
      <pre>{data}</pre>
    </StepperContent>
  );
};

Example2: StepperContext allows step data resolution. Saved data is accessible by getData method

API

Stepper

| Prop | Type | Description | |-------------|-------------------------------------|----------------------------------------------------------------------| | initialStep | string | number | Stets initital step by StepId | | onResolve | (stepId) => {} | Callback that will be executed on each step resolution | | onReject | (stepId) => {} | Callback that will be executed on each step rejection | | contextRef | MutableRefObject | Stepper controller reference | | className | string | Custom classname will be added to the root stepper container | | vertical | boolean | Indicates either horizontal or vertical steppr layout should be used |

Step

<Step
  stepId="2"
  title="Step Two"
  loading={isLoading(STEP2)}
  description="Login is required"
>
  ...
</Step>

Example3: Step component describes step configuration

| Prop | Type | Description | |-------------|-----------------|--------------------------------------------------| | title* | string | Step title. Required | | stepId* | string | number | Unique step identifier. Required | | children* | ReactNode | React component that will be rendered when step is activated. Required | | description | string | Step description or hint. Optional | | loading | boolean | Indicates whether step content is beign loading. | | disabled | boolean | Indicates whether step is beign disabled | | data | any | Initial state of step | | className | string | Custom classname | | index | number | Step index |

StepperContext

Provides API for control over stepper

| Prop | Type | Description | |----------------|------------------------------|-------------------------------------------------------------------| | updateStep | (stepId, state) => {} | Updates step state by id. | | goAt | stepId => {} | Activates certain step at provided stepId | | resolve | data => {} | Resolves current step with provided data | | reject | (message, description) => {} | Rejects current step with error and description | | isLoading | () => boolean | Indicates whether any of stepper steps is being loading | | getCurrentStep | () => StepState | Returns current step state | | getStep | stepId => StepState | Returns step state by stepId | | getData | (stepId, fallback) | Returns step data, fallback is used when step data is not defined |

StepperContent

StepperContent extends form interface, Could be used in custom steps for convenience and styling. Additionally StepperContent accept actions prop, that will be rendered in the footer of stepper content

StepperAction

StepperAction extends button interface, Could be used in custom steps for convenience and styling. Additionally StepperAction accept align ('left' or 'right') prop.

Customization

As part of material theme

$mdc-theme-primary: #fcb8ab;
$mdc-theme-secondary: #feeae6;
$mdc-theme-on-primary: #442b2d;
$mdc-theme-on-secondary: #442b2d;

@import "react-material-stepper/src/index.scss";
@import "material-components-web/material-components-web";

By SCSS variables

$stepper-color-hover: lightblue;
$stepper-color-index: darkblue;
$stepper-color-success: green;
$stepper-color-error: red;
$stepper-color-connector: cornflowerblue;
$stepper-header-height-horizontal: 64px;

@import "react-material-stepper/src/index.scss";

By CSS override

Stepper components allows passing custom className, and use it for override existing styles by applying css rules

import 'react-material-stepper/dist/react-stepper.css';
<Stepper className="custom-theme">
  <Step
    stepId={STEP1}
    title="Step One"
  >
    <Step1 />
  </Step>
  ...
</Stepper>
.stepper.custom-theme {
  background: red;
}