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-sure-toast

v1.2.0

Published

Vue Sure Toast is a simple VueJS toast plugin. This plugin contains built in features for theming, position, and more. See below for a full list of features.

Downloads

18

Readme

Vue Sure Toast

Vue Sure Toast is a simple VueJS toast plugin. This plugin contains built in features for theming, position, and more. See below for a full list of features.

Samples

Here are the basic themes built into the plugin.

Alt text

Toast with the progress bar enabled (choppiness is just the gif).

Alt text

Installation

First import the plugin.

import SureToast from 'vue-sure-toast';

Then configure the plugin with Vue.

// The simplest implementation.
Vue.use(SureToast);

// You can set default option values for the plugin here.  See a full list of options below.
Vue.use(SureToast, options);

// Here is a sample that sets the position and theme for all the toasts.
Vue.use(SureToast, {
  position: 'top-left',
  theme: 'warning'
});

Basic Usage

Displaying a toast message from within a component.

// The simplest method for displaying toast.
this.$sureToast.show(message);

this.$sureToast.show(message, icon);

this.$sureToast.show(message, icon, options);

The options parameter can contain an action that will be appended to the toast an a link.

this.$sureToast.show('I am a toast message', 'fa fa-info-circle', {
  interval: 5000,
  enableManualDismiss: true,
  action: { 
    text: 'DISMISS', 
    onClick: (e, toast) => { alert('TOAST CLICKED: ' + toast); } 
  }
});

You can also pass an array of actions when displaying a toast. If you pass both the 'action' and 'actions' property the 'action' property will take precedence over 'actions'. Make sure you pass one to save yourself some trouble.

this.$sureToast.show('I am a toast message', 'fa fa-info-circle', {
  interval: 5000,
  enableManualDismiss: true,
  actions: [
    { 
      text: 'OPEN', 
      onClick: (e, toast) => { alert('OPEN CLICKED: ' + toast); } 
    },
    { 
      text: 'DISMISS', 
      onClick: (e, toast) => { alert('CLOSE CLICKED: ' + toast); } 
    }
  ]
});

Toast Hooks

There are to methods you can hook into that will get fired when a toast is opened or closed.

// If you want a fire onOpened or onClosed for a specific toast you can do it like so.
this.$sureToast.show('I am a toast message', 'fa fa-info-circle', {
  interval: 5000,
  onOpened(e) {
    console.log('toast opened');
  },
  onClosed(e) {
    console.log('toast closed');
  }
});

If you want to fire the onOpened and onClosed for all the toasts you can pass define your functions in the plugin options.

Vue.use(SureToast, {
  onOpened() {
    console.log('toast opened');
  },
  onClosed() {
    console.log('toast closed');
  }
});

Any plugin level options that are passed through the show function will be ignored by the plugin.

Plugin/Toast Options

Below is a full list of the available options for both the defaults and individual toasts.

| Option | Type | Values | Default | Description | | ------------- |:-------------:| -----:| --------:|----------------:| | interval | number | any number (milliseconds) | 5000ms | The duration the toast is visible | | enableManualDismiss | boolean | true, false | false | Allows toasts to be manually dismissed | | position | string | 'top-left', 'top-right', 'bottom-right', 'bottom-left', 'top', 'bottom' | 'top-right' | Screen position of the toast | | theme | string | 'success', 'error', 'info', 'warning', 'default' | 'default' | The color scheme of the toast | | limit | number | any whole number | 3 | How many toasts can be displayed at once | | persist | boolean | true, false | false | Forces toasts to remain on screen (overrides interval) | | reverseToastOrder | boolean | true, false | false | If true displays the latest toasts at the bottom | | showProgressBar | boolean | true, false | false | If true displays the a progress bar across the bottom of toast with displaying the remaining time left for the toast | | onOpened | function | N/A | undefined | Executed after a toast is opened | | onClosed | function | N/A | undefined | Executed after a toast is closed |

Plugin ONLY Options

Below is a full list of the options that can only be set at the plugin level (passed to the Vue.use function).

| Option | Type | Values | Default | Description | | ------------- |:-------------:| -----:| --------:|----------------:| | position | string | 'top-left', 'top-right', 'bottom-right', 'bottom-left', 'top', 'bottom' | 'top-right' | Screen position of the toast | | limit | number | any whole number | 3 | How many toasts can be displayed at once | | reverseToastOrder | boolean | true, false | false | If true displays the latest toasts at the bottom |

Methods

Below is a full list of the methods available through the Vue instance.

| Method | Parameters | Description | | ------------- |:-------------:| -----:| | show | message, icon, options | Display a toast with the default options | | showSuccess | message, icon, options | Displays a success toast (sets theme to 'success') | | showError | message, icon, options | Displays an error toast (sets theme to 'error') | | showWarning | message, icon, options | Displays a warning toast (sets theme to 'warning') | | showInfo | message, icon, options | Display an information toast (sets theme to 'info') | | dismiss | toast | Removes a given toast from the DOM (NOT WORKING) | | dismissAll | N/A | Removes all toasts from the DOM |

Properties

Below is a full list of properties availble through the Vue instance.

| Property | Type | Description | | ------------- |:-------------:| -----:| | pluginDefaultOptions | object | Stores the defaults for the plugin. This is used as a fallback if no plugin or toast level settings are set by the user | | userDefaultOptions | object | Stores the default options configured at the plugin level by the user | | toastsLoaded | number | Stores the current number of toasts visible on the DOM | | toasts | array | Stores an array of DOM elements that represents the toasts current visible on the DOM |

Inspiration/Credit

This plugin was inspired by vue-toasted

Development

Developed by: NSSure