Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@marcoschulte/vue3-progress
Advanced tools
Readme
A vue3 plugin to show a progress bar while waiting for something.
Find a demo at https://vue3-progress-demo.netlify.app/.
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>
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;
// 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
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.
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);
});
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.
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.
FAQs
A fully customizable vue3 plugin to display a progress bar while waiting for something, e.g. http requests
The npm package @marcoschulte/vue3-progress receives a total of 1,200 weekly downloads. As such, @marcoschulte/vue3-progress popularity was classified as popular.
We found that @marcoschulte/vue3-progress demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.