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

@johnnywang/vue2-modal

v1.0.3

Published

A vue based modal plugin with `modal` component being defined globally.

Downloads

2

Readme

vue2-modal

A vue based modal plugin with modal component being defined globally.

Install

$ npm i @johnnywang/vue2-modal
// or
$ yarn add @johnnywang/vue2-modal

What plugin does?

This plugin will register a global component named modal, which would automatically use the plugin features.

Then you can use useModal globally to import the modal instance.

Or just use this.$modal in any components.

Usage

Register

Fisrt to install in your main.js

import Vue from 'vue';
import VueModal from '@johnnywang/vue2-modal';
import App from './App.vue';
import ErrorModal from './components/ErrorModal.vue';

// here we've to wrap all the modals going to be used in the modal.
// The global `modal` component will use `component` tag inside to change
// the modal based on your setting.
const components = {
  ErrorModal,
};

Vue.use(VueModal, {
  components,
});

template use

modal component has an loading slot, which you can used to customize your loading layout for modal.

<template>
  <div id="app">
    <div class="main">
      <router-view />
    </div>
    <modal :loading="loading" :firstup="true">
      <template #loading>
        Loading Modal...
      </template>
    </modal>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      // if there's some api calling when landing on page
      // default loading state should be set to "true"
      loading: true,
    }
  },
  mounted() {
    setTimeout(() => {
      this.loading = false;
    }, 2000);
  },
};
</script>

About props

There are only 5 props here.

loading

  • type: Boolean
  • default: true
  • description: whether open loading statement

firstup

  • type: Boolean
  • default: true
  • description: Whether modal components should use uppercase for first letter

modalClass

  • type: Object
  • default: {}
  • description: Customize modal-inner classname for UI purpose(eg: changing bg img...)

wrapperTransition

  • type: String
  • default: fade
  • description: transition name to set outside wrapper

innerTransition

  • type: String
  • default: ''
  • description: transition name to set outside inner

Use in components

export default {
  mounted() {
    // will render & open ErrorModal in modal component
    this.$modal.update('ErrorModal', {
      msg: 'Something Error!'
    });

    // will close modal after 2 seconds
    setTimeout(() => {
      this.$modal.close();
    }, 2000);
  },
};

Outside components

import { useModal } from '@johnnywang/vue2-modal';

const modal = useModal();
// ...

About modal object

There are 2 methods, 2 properties in modal object.

name

  • type: String
  • default: undefined
  • description: This is modal's name which directly based to your component name

after calling close method, name will become undefined which auto close the modal.

data

  • type: Object
  • default: {}
  • description: Modal data, you can define whatever inside the data to bring to your modal component

after calling close method, data will become {}.

update

  • type: Function
  • description: Update the modal content

close

  • type: Function
  • description: Close the modal

Emits

Then the grey overlay is clicked, it'll emit an event called close