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

vuex-toast

v0.1.3

Published

Simple toast notification using Vuex

Downloads

3,808

Readme

Vuex Toast

Simple toast notification using Vuex

Requirements

  • Vue >= 2.0
  • Vuex >= 2.0

Demo

http://codepen.io/ktsn/pen/Bzxkjd

Example

First, you should register a toast module to your Vuex store. You can use a default style at dist/vuex-toast.css.

import Vue from 'vue'
import Vuex from 'vuex'
import { createModule } from 'vuex-toast'

// If you want to use the default style (with webpack css-loader)
import 'vuex-toast/dist/vuex-toast.css'

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    // ...
    toast: createModule({
      dismissInterval: 8000
    })
    // ...
  }
})

Put Toast component anywhere in your application.

<template>
  <div>
    <article><!-- Your contents --></article>
    <toast position="ne"></toast>
  </div>
</template>

<script>
import { Toast } from 'vuex-toast'

export default {
  // ...
  components: {
    Toast
  }
  // ...
}
</script>

You can send notifications to the toast component with toast type.

import { mapActions } from 'vuex'
import { ADD_TOAST_MESSAGE } from 'vuex-toast'

export default {
  methods: {
    ...mapActions({
      addToast: ADD_TOAST_MESSAGE
    }),

    sendNotification(text) {
      this.addToast({
        text,
        type: 'success',
        dismissAfter: 10000
      })
    }
  }
}

API

Toast

A Vue component that shows toast messages.

  • props
    • position
    • html
    • namespace
      • Vuex module's namespace if you install toast module into some namespaced module.

createModule(options): VuexModule

Create Vuex module for managing toast messages.

  • options
    • dismissInterval

createComponent(options): VueComponent

Create customized toast component.

  • options
    • transition

Action Types

  • ADD_TOAST_MESSAGE
    • dispatch(ADD_TOAST_MESSAGE, { text, type, dismissAfter })
  • REMOVE_TOAST_MESSAGE
    • dispatch(REMOVE_TOAST_MESSAGE, messageId)

Getters

  • toastMessage
    • get all toast messages.

Toast Message Type

  • id Auto generated message ID
  • text Text of the toast message
  • type Type of the toast message
    • You can use any value for styling purpose.
    • There are default styles for info, success, warning, and danger
  • dismissAfter Milli-second that indicates the message dismiss after this time

License

MIT