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

progress-steps-webcomponent

v1.1.0

Published

A web component for displaying the steps of a process and letting users move between them

Downloads

119

Readme

progress-steps-webcomponent

A web component for displaying the steps of a process and letting users move between them

👉View Example👈

Getting Started

CDN

Use the built files from npm from https://unpkg.com/progress-steps-webcomponent@latest

<!-- For example, use a CDN and replace 'latest' with your intended version -->
<link rel="stylesheet" href="https://unpkg.com/progress-steps-webcomponent@latest/dist/progress-steps.min.css"/>
<script src="https://unpkg.com/progress-steps-webcomponent@latest/dist/progress-steps.min.js"></script>

Manual

To build yourself, clone the repo, and run

npm i
npm run build

And use the dist/progress-steps.min.js and dist/progress-steps.min.css files

Configuration

View the example above for a complete working example. Add the component anywhere in your html:

<progress-steps id="my-steps"></progress-steps>

Then initialize the control

// Find the control
let myStepper = document.querySelector('#my-steps');

// And initialize it
myStepper.init({
	steps: [{ name: 'Step 1' }, { name: 'Step 2' }, { name: 'Step 3' }],
});

Step configuration

You can disable steps by setting disabled to true. You can attach any custom property to a step that you wish. When programmatically fetching the step later, those values can be retrieved and used. For example, you might attach custom IDs/GUIDs to them, so that when a step is changed, you can act upon the ID of that step:

myStepper.init({
	steps: [
		{ name: 'Step 1', myCustomId: 1 },
		{ name: 'Step 2', myCustomId: 2 },
		{ name: 'Step 3', myCustomId: 3 },
		{ name: 'Step 4', myCustomId: 4 },
		{ name: 'Step 5', myCustomId: 5, disabled: true },
		{ name: 'Step 6', myCustomId: 6, disabled: true },
	],
	events: {
		onStepChanged: function (stepNumber, stepObj) {
			console.log(`Step changed to ${stepNumber}!`);
			let newId = stepObj.myCustomId;
			// [Act upon newId here]
		},
	},
});

Events

| Event Name | Parameters | Description | | ------------- | --------------------- | ------------------------------ | | onStepChanged | (stepNumber, stepObj) | Fired when the step is changed |

Methods

| Method Name | Parameters | Description | | ----------- | ---------- | --------------------------------------------------------------- | | init | (options) | Initializes the control. See above examples for options usage | | getStep | | Returns the step object of the current active step | | setStep | (step) | Takes in the step number of the step to change to | | stepUp | | Increments the current active step | | stepDown | | Decrements the current active step | | disableStep | (step) | Takes in the step number of a step and disables it from use | | enableStep | (step) | Takes in the step number of a step and enables it for use |

Styling

Styling defaults can be overridden by overriding CSS variables on your component instance:

/* Ugly but complete style override demonstrating all the style components */
#my-steps{
	/* The color to fill up, left-to-right, as steps are set to active */
	--progress-fill-color: #cf78d9;
	/* The default color of the unfilled section of line and steps after the active step */
	--progress-unfilled-color: purple;

	/* The width of each step icon */
	--step-width: 20px;
	/* The font size of the step number and label */
	--font-size: 12px;
	/* The border radius of the step icon */
	--step-border-radius: 25%;
	/* The thickness of the line/progress bar/borders */
	--line-thickness: 3px;

	/* The animation speed of the progress bar filling up */
	--animation-speed: 500ms;
	/* Display attribute of the step labels. Show: 'inline-block', hide: 'none' */
	--step-label-display: 'inline-block';
	/* The vertical margin of the labels, if shown */
	--step-label-spacing: 5px;
	/* The font weight to use on step labels */
	--step-label-font-weight: normal;

	/* The font color of the step icon that is currently active */
	--current-step-font-color: red;
	/* The font color of the current step label */
	--current-label-font-color: blue;
	/* The font weight of the current step label */
	--current-label-font-weight: bold;

	/* The font color of step labels that are before the current step */
	--previous-label-font-color: red;
	/* The font color of the step icons that are before the current step */
	--previous-step-font-color: pink;

	/* The fill-color for step icons that are after the current active step */
	--future-step-fill-color: orange;
	/* The font color of step labels that are after the current step */
	--future-label-font-color: green;

	/* The font color of step labels that are disabled */
	--disabled-label-font-color: maroon;
	/* The font color of the disabled steps */
	--disabled-step-font-color: red;
	/* The fill-color for disabled step icons */
	--disabled-step-fill-color: blue;
}