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

@marcoschulte/vue3-progress

v0.0.7

Published

A fully customizable vue3 plugin to display a progress bar while waiting for something, e.g. http requests

Downloads

6,800

Readme

vue3-progress

A vue3 plugin to show a progress bar while waiting for something.

Demo

Find a demo at https://vue3-progress-demo.netlify.app/.

Setup

npm install @marcoschulte/vue3-progress

Add plugin

// main.ts

import {createApp} from 'vue';
import App from './App.vue';
import {Vue3ProgressPlugin} from '@marcoschulte/vue3-progress';

createApp(App)
    .use(Vue3ProgressPlugin)
    .mount('#app');

Import style

// in an .scss file
@import "~@marcoschulte/vue3-progress/dist/";

// alternatively the pre-compiled css can be imported from @marcoschulte/vue3-progress/dist/index.css

Add progress bar component

<!-- App.vue -->

<template>
  <vue3-progress-bar></vue3-progress-bar>
  
  <!-- snip -->
  
</template>

Usage

There are different ways to use the plugin

import {useProgress} from '@marcoschulte/vue3-progress';

// via useProgress()
const progress = useProgress().start();
progress.finish();

// via global property
const progress = this.$progress.start();
progress.finish();

Alternatively the progress plugin can be attached to a Promise:

const promise: Promise<any> = loadUsers();
const attached = useProgess().attach(promise);
const thisIsTrue = attached === promise;

Multiple simultaneous progresses

// the plugin tracks how many "progresses" are active.
// progress.finish() can safely be called multiple times
const progress1 = useProgress().start(); // progress bar appears
const progress2 = useProgress().start();

progress1.finish();
progress1.finish(); // progress bar is still shown, calling multiple times is safe
progress2.finish(); // progress bar disappears

On the scope of useProgress()

useProgress() can be used from everywhere, not only from vue functional components such as setup. This is possible because a reference to the plugins instance is globally registered. This behavior can be deactivated through installing the plugin as .use(Vue3ProgressPlugin, {disableGlobalInstance: true}). The plugin will now use vue's inject/provide mechanism.

Examples

Usage with axios

import {ProgressFinisher, useProgress} from '@marcoschulte/vue3-progress';

const progresses = [] as ProgressFinisher[];

axios.interceptors.request.use(config => {
  progresses.push(useProgress().start());
  return config;
});

axios.interceptors.response.use(resp => {
  progresses.pop()?.finish();
  return resp;
}, (error) => {
  progresses.pop()?.finish();
  return Promise.reject(error);
});

Customizing

Customizing the style

Some scss variables are exposed which can be customized as follows. Check ProgressBar.vue for all variables.

$vue3-progress-bar-color: #ff0000;
@import "~@marcoschulte/vue3-progress/dist/";

Alternatively the css classes can be overriden in your own style.

Customizing the ProgressBar Component

If customizing the style is not sufficient, you can easily write your own progress bar component instead of using the provided one. The trickling effect can be reused if wanted, it is provided as a composable. Check ProgressBar.vue as a reference to create your own.