Coder Social home page Coder Social logo

trendingtechnology / vuetify-snackbar-queue Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ajanes93/vuetify-snackbar-queue

0.0 3.0 0.0 274 KB

Component to queue vuetify snackbars. Example on:

Home Page: https://codesandbox.io/s/z2v919669m

JavaScript 20.25% HTML 9.73% Vue 70.02%

vuetify-snackbar-queue's Introduction

vuetify-snackbar-queue

Simple plugin for queueing v-snackbars in Vuetify

  • Extends VSnackbar component and adds items[] prop
  • Queues Snackbars displaying one at a time

##Use as Plugin

Import as plugin in your main.js file

//main.js
import Vue from 'vue'
import VuetifySnackbarQueue from 'vuetify-snackbar-queue'

Vue.use(VuetifySnackbarQueue)

Use in templates

<template>
    <v-container grid-list-lg fluid>
        <v-layout wrap>
            <v-flex xs2>
               <v-btn color="primary" @click="addItem">Add to Queue</v-btn>
            </v-flex>
        </v-layout>
        <v-snackbar-queue
            :items="items"
            @remove="removeItem"
        ></v-snackbar-queue>
    </v-container>
</template>
<script>
	export default {
		data: () => ({
		    id: 0,
		    items: [],
		    colors: ['warning', 'error', 'info']
		}),
		methods: {
		    addItem () {
		        const vm = this
		        const index = vm.randomInt(0, 2)
		        vm.id++
		        vm.items.push({
		            id: vm.id,
		            color: vm.colors[index],
		            message: 'This is an example alert'
		        })  
		    },
		    removeItem (id) {
		        const vm = this
		        const index = _.findIndex(vm.items, {id})
		        
		        if (index !== -1) {
		            vm.items.splice(index, 1)
		        }   
		    },
		    randomInt(min, max) {
                return Math.floor(Math.random() * (max - min + 1) ) + min;
            }
 		}
	}
</script>

##Development Setup

Project setup

yarn install

Compiles and hot-reloads for development

yarn run serve

Compiles and minifies for production

yarn run build

Lints and fixes files

yarn run lint

vuetify-snackbar-queue's People

Watchers

James Cloos avatar Trending Technology avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.