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-next-modal

v1.0.7

Published

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

Downloads

6

Readme

vue-next-modal

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

Install

$ npm install vue-next-modal
// or
$ yarn add vue-next-modal

Since the modal component is created by sass, please make sure you have sass & sass-loader installed in your webpack or other bundlers.

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.

If you still need to use option API, you can still access modal by this.$modal.

Usage

Register

Fisrt to install in your main.js

import { createApp } from 'vue';
import { createModal } from 'vue-next-modal';
import App from './App.vue';
import ErrorModal from './components/ErrorModal.vue';

// create a new modal instance
const modal = createModal();

// 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,
};

const app = createApp(App)
  // provide components for plugin
  .use(modal, {
    components,
  })
  .mount('#app');

template use

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

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

<script>
import { ref, onMounted } from 'vue';

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

About props

There are only 3 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

import { useModal } from 'vue-next-modal';

export default {
  setup() {
    const modal = useModal();
    // will render & open ErrorModal in modal component
    modal.update('ErrorModal', {
      msg: 'Something Error!'
    });

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

About modal object

There are 2 methods, 3 properties in modal object.

currentModal

  • type: vue-reactive-object
  • description: real reactive object, do not modified data here directly, it may cause some unexpected error, this just used for some situation when you can not access data correctly by composition API.

name

  • type: vue-ref(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: vue-ref(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