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

@beyonk/svelte-steps

v2.2.0

Published

<a href="https://beyonk.com"> <br /> <br /> <img src="https://user-images.githubusercontent.com/218949/144224348-1b3a20d5-d68e-4a7a-b6ac-6946f19f4a86.png" width="198" /> <br /> <br /> </a>

Downloads

200

Readme

Svelte Steps

js-standard-style Svelte v3 publish

Svelte Steps component

Demo

A hosted demo exists

pnpm i && pnpm dev

About

Demonstrates progress in a multi-step process in your application, such as a payment flow.

  • Current step info is denoted by the step store
  • If the current step is the last step, the steps component shows as fully complete.

Usage

Install the library

npm i --save-dev @beyonk/svelte-steps

Steps Component

See the example directory for an example.

  1. Import the Steps component and the setup function from the library.
  2. Configure the Steps component by passing an array of step names and icons
  3. Configure the theme option by setting an rgb colour value for the complete theme variable
  4. Set the current step by passing it's array index. Usually 0.
  5. Add the <Steps> component to your page, and pass it the theme, and the current attributes.
<Steps {theme} />

<script>
	import { Steps, setup, current } from '@beyonk/svelte-steps'
	import { UserIcon, CreditCardIcon, BriefcaseIcon } from 'svelte-feather-icons'
	
	setup([
		{ name: 'About You', icon: UserIcon },
		{ id: 'payment', name: 'Payment', icon: CreditCardIcon }, // id is optional and will be autogenerated
		{ name: 'Confirmation', icon: BriefcaseIcon }
	])
	
	const theme = [
		{ name: 'complete', value: { r: 6, g: 160, b: 146 } }
	]
</script>

Pages Component

The pages component is a mini steps component for pages where space is of the essence.

API

Change Step

To go to a specific step, call to() passing the id of the desired step

<Steps {theme} />

<script>
	import { to } from '@beyonk/svelte-steps'
	
	to('second-step')
</script>

The $step store gives you the ability to implement next and back buttons trivially:

<Steps {theme} />

<button on:click={() => to($step.next)}>Next Step</button>
<button on:click={() => to($step.previous)}>Previous Step</button>

<script>
	import { to, step } from '@beyonk/svelte-steps'
</script>

Add a Step dynamically

After a specified position

To add a new step, pass it to the addStep method:

after is the id of the step which should sit previous to the new step. id is optional, and is the step id. It will be generated in the absence of passing an id

addStep(step, after, id)

<script>
	import { addStep } from '@beyonk/svelte-steps'
	import { StarIcon } from 'svelte-feather-icons'
	
	addStep({ name: 'Thank You!', icon: StarIcon }, 'payment')
</script>

After the current position

To add a new step at the current position, don't pass the position attribute.

addStep(step)

<script>
	import { addStep } from '@beyonk/svelte-steps'
	import { StarIcon } from 'svelte-feather-icons'
	
	addStep({ name: 'New Step', icon: StarIcon })
</script>

With a custom id

To add a new step with an id, pass it as the third param

addStep(step, after, id)

<script>
	import { addStep } from '@beyonk/svelte-steps'
	import { StarIcon } from 'svelte-feather-icons'
	
	addStep({ name: 'New Step', icon: StarIcon }, 'payment', 'foo123')
</script>

Remove a Step dynamically

At a specified position

To add a new step, use the removeStep function, passing the id of the step to remove

removeStep(id)

<script>
	import { removeStep } from '@beyonk/svelte-steps'
	
	removeStep(2)
</script>

Get Presence of Step

To determine if a step exists, query it by id

Step exists? {hasStep('my-step-id')}

<script>
	import { hasStep } from '@beyonk/svelte-steps'
</script>

Step State

The step state import is called step and contains metadata about the steps:

Total Steps: {$step.total}
Current Index: {$step.index}
Current Step Name: {$step.name}
Current Step Id: {$step.id}
Is Last Step? {$step.isLast}
Is First Step? {$step.isFirst}
Next step id: {$step.next} (false if last step)
Previous step id: {$step.previous} (false if first step)

<script>
	import { step } from '@beyonk/svelte-steps'
</script>

Events

The step icons dispatch a step event when clicked, and the event's details.step contains the id and index of the step which was clicked.