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

vuetify-toaster

v1.0.0

Published

Toaster popups for vuetifyjs by Tom Faust Software

Downloads

18

Readme

Toaster.vue

A Toast and Confirmation Component for VuetifyJs

Toaster allows you to generate small popup (toast) messages that wil appear in any corner, left middle, top center, right middle, bottom center or center of the screen. These messages can be displayed for a configurable amount of time, with or without a countdown and close button. They can also be left open until the user responds to them by clicking the close button.

Toast message exist in different colors for Information (green), Warning (yellow) and Error (red). The colors are configurable. By default, error toasts remain until the user closes them.

All toast messages (or only a configurable subset by type) are stored and can be retrieved by clicking the toast icon in the lower right corner of the screen, which appears if any toasts are available for redisplay.

Toaster also provides screen centered alert and confirmation dialogs with configurable title, message, button text and header color.

Usage

Import Toaster as a component in a global vue template, such as the class that contains your <router-view ... />, like this:

<template>
  <div>
    <transition name="hub-router-transition" mode="out-in">
      <router-view :key="$route.fullPath"/>
    </transition>
    <v-toaster :options="toasterOptions" /> <!-- Add this line -->
  </div>
</template>
import Toaster from 'vuetify-toaster';  // Add this line

@Components({
  component: {
    Toaster // Add this line
  }
})

On the <v-toaster /> line, the ':options' attribute is optional.

Then anywhere you want to display a toast message, import Toaster and use it directly or create simple toast wrapper functions.

Import and Declare Toaster (TypeScript Example)

import Toaster from 'vuetify-toaster'; // do not include in the template or add as a component!

Static toast examples

// green in bottom right corner, times out after 4 seconds
Toaster.info(text);

// yellow in top right corner, times out after 2 seconds
Toaster.warn(text, 2000, Toaster.TopRight);

// red in the center of the screen, does not timeout and shows a Close button
Toaster.error(text, Toaster.WaitForClose, Toaster.Center);

Toaster toast paramers are:

  message: string = '(no message)'
  timeout: number = 4000
  location: number | undefined = undefined

Confirmation Dialog

To display a confirmation dialog, import Toaster and use Toaster.confirm()

Toaster.confirm('Press yes or no',
                () => { do something },
                () => { do something });

Toaster confirm paramaters and default values for all but Function are:

  message: string = 'Do you want to continue'
  yesCallback: Function
  noCallback: Function
  yesPrompt: string = 'Yes'
  noPrompt: string = 'No'
  title: string = 'Please confirm'

Alert Dialog

To display an alert dialog, import Toaster and use Toaster.alert()

Toaster.alert('Press Ok', 'Alert title');

Toaster alert paramaters and default values are:

  message: string = 'Press OK to continue',
  title: string = 'Alert!'
  okPrompt: string = 'OK'

Toaster Options

To set alternate defaults for Toaster, you can use the optional options attribute.

<toaster :options="toasterOptions" />

The example below shows a toasterOptions object returning the default values. Any of these default values can be modified like this as well as overridden at run-time.

private get toasterOptions() {
  return {
    headerColor: 'primary white--text',
    infoColor: 'green',
    warnColor: 'yellow darken-3',
    errorColor: 'red'
    location: Toaster.BottomRight,
    timeout: 4000,
    showCountdown: true,
    showCloseButton: true,
  }
}

An example of toasterOptions that changes, for instance, showCloseButton = false

<toaster :options="myOptions">
private get myOptions {
  return {
    showCloseButton: false
  };
}

This would leave all of the default options values intact except for showCloseButton which would be changed to false.