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

state-stepper

v2.0.4

Published

State-Stepper Web-Component

Downloads

606

Readme

State-Stepper

Progress steps visualizer.

NOTE This version (2.x) of state-stepper is not compatible with the previous version (1.x). Version 1.x is for Ionic 3 and 2.x is a standard Web-Component to use everywhere. (Also Ionic 3 and 4).

Visualize your progress steps. This is a Web-Component you can use it everywhere and with everything you want. Every framework like Angular, Vue, React and UIs like Ionic, Material or Vuetify. Or just use it in vanilla JavaScript or TypeScript. Just load and use it.

You can use any element for the icon and text. For example the ion-icon of Ionic.

Demo

Installation

This Web-Component is also available at NPM

npm i state-stepper
import `state-stepper`;

You can also use unpkg. e.g.:

<script type="module" src="https://unpkg.com/state-stepper@latest/dist/state-stepper/state-stepper.esm.js"></script>
<script nomodule="" src="https://unpkg.com/state-stepper@latest/dist/state-stepper/state-stepper.js"></script>

Angular Integration

Example:

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, FormsModule],
  providers: [],
  bootstrap: [AppComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule {}

main.ts

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

import { defineCustomElements } from 'state-stepper/loader';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic()
  .bootstrapModule(AppModule)
  .catch(err => console.error(err));

defineCustomElements(window);

Usage

This example shows the state-stepper element with Ionic icons and pure JavaScript. But you can adept this for each Framework. e.g. ng-for, v-for, etc. for your steps.

HTML

<state-stepper>
  <state-stepper-step state="danger">
    <ion-icon name="options" slot="icon"></ion-icon>
    <span slot="text">Options</span>
  </state-stepper-step>
  <state-stepper-step state="success">
    <ion-icon name="settings" slot="icon"></ion-icon>
    <span slot="text">Work</span>
  </state-stepper-step>
  <state-stepper-step state="warning">
    <ion-icon name="save" slot="icon"></ion-icon>
    <span slot="text">Save</span>
  </state-stepper-step>
  <state-stepper-step state="active">
    <ion-icon name="cloud-upload" slot="icon"></ion-icon>
    <span slot="text">Upload</span>
  </state-stepper-step>
  <state-stepper-step>
    <ion-icon name="checkmark" slot="icon"></ion-icon>
    <span slot="text">Complete</span>
  </state-stepper-step>
</state-stepper>

JS

const stateStepper = document.querySelector('state-stepper');
stateStepper.stepNext('warn');
stateStepper.stepNext('success');
stateStepper.stepNext('success');
stateStepper.stepNext('danger', true);
stateStepper.stepBack();
stateStepper.resetSteps();

Remeber DOMContentLoaded event if you get undefined.

Methods

stepNext(currentState: string, stop = false): Promise<boolean>

Jumps to the next step.

| Argument | Description | | ------------ | -------------------------------------- | | currentState | The state for the current active step. | | stop | (Optional) Stops at current step. |

Returns true if the all steps are completed.


resetSteps(stepIndex = 0): Promise<void>

Resets all steps. You can also use it to start or jump back to a specific step.

| Argument | Description | | --------- | -------------------------------------------- | | stepIndex | (Optional) The index to step back. (0-based) |


stepBack(): Promise<void>

Steps back to the previous step. One step back from the active step.


It's recommended to manage the steps by yourself instead of using the methods. Use the state attribute of a step.

If your steps overflows the view, it automatically scrolls to the active state on initial load and every change of active step.

Roadmap

It is planned to create an Angular wrapper for it in the future. Be free to support this software.

License

MIT Copyright (c) 2019 Dominik Geng

See license