Giter Site home page Giter Site logo

vue-modal's Introduction

vue-modal

Simple modal plugin with some nice hooks for toggling modal.

Install

The plugin will self install. However it also comes with some additional pre made modals.

import {modalSlide} from 'vue-modal';
Vue.component('modal-slide-show', modalSlide);

For now it's just a slide show.

Example

Plain Modal:

  • The modals have events that cant be captured.
  • They can also accept any arbitrary data.
<template>
    <div v-on:click="$modal.show('login')">login</div>
    <div v-on:click="$modal.show('register', {boo: 'yaa'})">register</div>

    <modal name="login">
        <div slot="content">
            // login html
        </div>
    </modal>
</template>

<script>
    export default {
        modals: {
            login: {
                onShow: function () {
                    console.log('show');
                },
                onHide: function () {
                    console.log('hide');
                }
            },
            register: {
                onShow: function () {
                    console.log(this.$modal.data('register'));
                }
            }
        }
    }
</script>

Slideshow:

If no index is provided it will just go to 0 on start.

<template>
    <div v-for="(index, video) in videos" v-on:click="$modal.show('videos-slide-show', {index: index})">{{ video.name }}</div>
    <modal-slide-show name="videos-slide-show" :data="videos"></modal-slide-show>
</template>

<script>
    export default {
        data: function () {
            return {
                videos: [{
                    link: 'http://somelink.com/123',
                    name: 'zero'
                }, {
                    link: 'http://somelink.com/456',
                    name: 'one'
                }]
            };
        }
    }
</script>

Methods

There are also some other methods available. Probably they will not be required unless building a more generic style plugin.

  • $modal.show(name, data, overlap)
  • $modal.hide(name, reset)
  • $modal.data(name)
  • $modal.visible(name)
  • $modal.register(name)

vue-modal's People

Contributors

websanova 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.