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

vue-flash-message

v0.7.2

Published

Vue.js flash message component

Downloads

6,199

Readme

vue-flash-message

Demo & Example

Live demo

Install

  npm install --save vue-flash-message

Configuration

import Vue from 'vue';
import VueFlashMessage from 'vue-flash-message';
Vue.use(VueFlashMessage);

You can rename default flash method via options:

Vue.use(VueFlashMessage, { method: 'iPreferQuickSilver' });

Usage

Output flash message pool and configure transitions.

<flash-message class="myCustomClass"></flash-message>

(Optional) Include pre defined basic css.

require('vue-flash-message/dist/vue-flash-message.min.css');

Emit flash messages from any component with a flash (or custom named) method.

this.flash('Data loaded', 'success');
this.flash('Validation failed', 'error');
this.flash('Spawning too much alerts is a bad UX', 'warning');
this.flash('Live long and prosper', 'info');

Shortcut methods

You can also use shortcut methods to output common message types

this.flashSuccess('Data loaded');
this.flashError('Validation failed');
this.flashWwarning('Spawning too much alerts is a bad UX');
this.flashIinfo('Live long and prosper');

You if you don't want to spoil your components with these methods, you can switch them off by using createShortcuts config option.

Vue.use(VueFlashMessage, {
  createShortcuts: false,
});

Usage with options

this.flash('Hello World', 'success', {
  timeout: 3000,
  beforeDestroy() {
    alert('oh no, not again!');
  }
});

Options

| Name | Type | Default | Desciption | | ---: |:---: |:--- |:--- | | timeout | Number | 0 | Number in milliseconds until message self destruct | | important | Boolean | false | Defines if message has a close button. | | autoEmit | Boolean | true | Defines if message should be emitted immediately after calling flash method | | pauseOnInteract | Boolean | false | Defines if message destruct timer should be paused on user interaction | | beforeDestroy | Function | - | Fires bofore message is destroyed | | onStartInteract | Function | - | Fires on user interact with message element | | onCompleteInteract | Function | - | Fires on user complete interaction with message element |

Props

| Name | Type | Default | Desciption | | ---: | :---: | :---: | :--- | | transitionName | String | custom-classes-transition | vue transitions name | | outerClass | String | 'flash__wrapper' | outer class name |

Passing global message options

Vue.use(VueFlashMessage, {
  messageOptions: {
    timeout: 1000,
    important: true,
    autoEmit: false,
    pauseOnInteract: true
  }
});

API

Flash method returns message object giving you full controll over it's contents, options and lifecycle.

const myMessage = this.flash('My message', 'info');

| Method | Desciption | | ---: |:--- | | emit() | Adds message to global storage. Helpfull when message is created with autoEmit: false | | destroy() | Destroys message | | getStorage() | Returns global flash message storage object | | setSelfDestructTimeout(timeout) | Sets message self destruct timer value (in milliseconds) | | startSelfDestructTimer() | Starts self destruct timer | | killSelfDestructTimer() | Stops self destruct timer |

Calling flash method with no arguments will return flash storage object.

const messageStorage = this.flash();

| Method | Desciption | | ---: |:--- | | flash(...) | Same as this.flash method, except it does not return storage instance | | push(id, message) | Adds message object to storage with id key | | destroy(id) | Destroys message by given id | | destroyAll() | Destroys all messages |

Vuex usage

You can access flash message storage object directly from Vue prototype:

Vue.prototype.$flashStorage.flash(...);

License