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

v0.6.1

Published

elegant to manage spa modals

Downloads

67

Readme

vue-modal-router

elegant to manage spa modals

0.6.0

  • async modal support
{
  modals:{
    AsyncModal:()=>import('./test/async-modal.vue')
  },
  methods:{
    onClick(){
      this.$modalRouter.push({
        name:'async-modal' // this will load script then open the modal
      })
    }
  }
}

0.5.1

  • add modalRouter.closeAll()
  • fix close custom modal bug

{
  methods:{
    onClick(){
      this.$modalRouter.closeAll()
    }
  }
}

0.5.0

  • add modalRouter.close() method
const mid = this.$modalRouter.push({
  name: "test"
});

this.$modalRouter.close(mid);

Breaking Change

  • 0.4.0 is differenet to 0.3.x
  • [delay] and [model] is config in Vue.use()
  • suport component level modals,friendly for dyamicImport,to impress performance

install

npm install vue-modal-router

vue-modal-router

use modals like vue-router style way

install

modal component

<template>
  <!-- your modal component -->
  <modal v-model="show">
    <h1>something</h1>
    <button @click="onTest">test</button>
  </modal>
</template>

<script>
  export default {
    props: ["a", "b"],
    data() {
      return {
        show: false
      };
    },
    methods: {
      onTest() {
        this.$emit("test");
      }
    }
  };
</script>

App.vue

<template>
  <div id="app">
    <router-view></router-view>
    <!-- modal placeholder -->
    <modal-router-view></modal-router-view>
  </div>
</template>
import Vue from "vue";
import VueModalRouter from "vue-modal-router";

import CustomEdit from "./custom-edit.vue";
Vue.use(VueModalRouter, {
  model: "show", // this should be equal to modal component model name
  delay: 300 // delay time to destroy modal instance
});

const modalRouter = new VueModalRouter({
  CustomEdit // now modal name can be 'CustomEdit' or 'custom-edit',it will try pascal name
});

new Vue({
  el: "#app",
  modalRouter
});

then in page component

<template>
  <!-- button to open modal -->
  <button v-modal-link="{name: 'custom-edit' }">open custom edit modal</button>
</template>

pass props to modal

<template>
  <!-- button to open modal -->
  <button
    tag="button"
    v-modal-link="{name: 'custom-edit',props: {a: 1, b: 2} }"
  >
    open custom edit modal
  </button>
</template>

with event

<template>
  <!-- button to open modal -->
  <button v-modal-link="{ name: 'custom-edit', on: {test: onModalTest } }">
    open custom edit modal
  </button>
</template>

<script>
  export default {
    methods: {
      onModalTest() {
        console.log("get modal event here");
      }
    }
  };
</script>

use manual api to open a modal

<template>
  <div>
    <button @click="onOpen">
      open
    </button>
  </div>
</template>

<script>
  export default {
    methods: {
      onModalTest() {
        console.log("test here");
      },
      onOpen() {
        const mid = this.$modalRouter.push({
          name: "custom-edit",
          props: { a: 1, b: 2 },
          on: {
            test: this.onModalTest
          }
        });

        setTimeout(() => {
          this.$modalRouter.close(mid);
        }, 2000);
      }
    }
  };
</script>

dyamic modals,now you can import modals only in component what you need no need to import all modals at ones

<template>
  <!-- button to open modal here will  use `modals` config -->
  <button
    tag="button"
    v-modal-link="{name: 'custom-edit-local',props: {a: 1, b: 2} }"
  >
    open custom edit modal
  </button>
</template>

<script>
  import CustomEditLocal from "./modals/custom-edit.vue";

  export default {
    modals: {
      CustomEditLocal
    }
  };
</script>

Development Setup

# install deps
npm install

# serve demo at localhost:8080
npm run dev

# build library and demo
npm run build

# build library
npm run build:library

# build demo
npm run build:demo

License

MIT

Copyright (c) 2018 FlynnLee