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-toaster

v2.0.0

Published

A fully customizable toaster, with sane defaults

Downloads

421

Readme

vue-toaster

A fully customizable toaster.

Demo

  • register your own toast-components with the toaster
  • singleton, same instance shared by all using components

Install

npm install --save-dev vue-toaster
// [email protected]
npm install --save-dev vue-toaster@1

or include build/bundle.js.

Usage

# default is to use it as a mixin
# in your component:
mixins: [
  require("vue-toaster") # adds a method `toast(options)`
  # or with bundle.js
  window.vueComps.toaster
]
methods:
  doToast: ->
    # this will just create a `<div class="toast">{{options.text}}</div>`
    # for each toast:
    toast = @toast({text:"I'm toast"})
    toast.close() # to dismiss
    # the returned object is identical with the options argument:
    toastIn = {text:"I'm toast"}
    toastOut = @toast(toastIn)
    toastOut === toastIn # true

For examples see dev/.

Options

The options object will be used in the toaster and then passed down to the toast. These are used by the toaster:

Name | type | default | description ---:| --- | ---| --- component | String | "toast" | Name of the component to display timeout | Number | 2500 | time in milliseconds, when a toast will be closed automatically. The timeout will be halted on mouseenter and started again on mouseleave class | Vue class | ["toast"] | class of the toast element style | Vue Style | - | style of the toast element cb | Function | - | will be called on close of toast

These are used in the default toast:

Name | type | default | description ---:| --- | ---| --- text | String | - | text to display

Provide your own toast component

You can provide your own toast component with the help of the global Vue instance:

Vue.component('toast2', {template: "<div v-text='options.text'></div>",props:["options"]})

You can then use it in your component:

mixins: [require("vue-toaster")],
methods:{
  doToast: function() {
    @toast({text:"I'm toast",component:"toast2"})
  }
}

Provide your own toast transition

You can provide a default transition like this:

// must be a transition group
// be sure to pass down the context data
Vue.component('toaster-transition', {
  functional: true
  render: function(h,context) {
    context.data.attrs.name = "fade"
    context.data.props = {css: false}
    context.data.on = {
      enter: ...
    }
    return h "transition-group",context.data,context.children)
  }
})

Changelog

  • 2.0.0
    now compatible with vue 2.0.0
    changed way of using own transition

  • 1.1.0
    toast now closes on click, can be prevented by a custom toast with @click.prevent="onClick"
    added vue transition
    renamed classes option to class
    properly remove toaster from dom when last using component is destroyed

  • 1.0.0
    added unit tests

Development

Clone repository

npm install
npm run dev

Browse to http://localhost:8080/.

License

Copyright (c) 2016 Paul Pflugradt Licensed under the MIT license.