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

v1.0.0

Published

Simple to use Vue.Js sidebar modal

Downloads

21

Readme

vue-sidebar-modal

Simple to use sidebar modal based on the Vue JS Modal Plugin

Install

npm install vue-sidebar-modal --save

How to use

Include plugin in your main.js file.

import SidebarModal from 'vue-sidebar-modal'

Vue.use(SidebarModal)
Import css file

@import "~vue-sidebar-modal/dist/vue-sidebar-modal";

Create modal:

<sidebar-modal name="hello-world">
  hello, world!
</sidebar-modal>

Call it from anywhere in the app:

methods: {
  show () {
    this.$sidebarModal.show('hello-world');
  },
  hide () {
    this.$sidebarModal.hide('hello-world');
  }
}

You can easily send data into the modal:

this.$sidebarModal.show('hello-world', { foo: 'bar' })

And receive it in beforeOpen event handler:

<sidebar-modal name="hello-world" @before-open="beforeOpen"/>
methods: {
  beforeOpen (event) {
    console.log(event.params.foo);
  }
}

Dynamic Modals

In order to instantiate modals at runtime (for lazy-loading or decluttering templates), it is possible to create modals dynamically.

To start using this feature just include the <sidebar-modals-container /> component it in your project:

<sidebar-modals-container />

Call it (the first argument is the component definition, the second are component properties, the third modal parameters, and the fourth the modal event listeners):

this.$sidebarModal.show({
  template: `
    <div>
      <h1>This is created inline</h1>
      <p>{{ text }}</p>
    </div>
  `,
  props: ['text']
}, {
  text: 'This text is passed as a property'
}, {
  height: 'auto'
}, {
  'before-close': (event) => { console.log('this will be called before the modal closes'); }
})

It can also be used with .vue files:

import MyComponent from './MyComponent.vue'

this.$sidebarModal.show(MyComponent, {
  text: 'This text is passed as a property'
}, {
  height: 'auto'
})

You can close dynamic modals by emitting a 'close' event:

this.$sidebarModal.show({
  template: `
    <div>
      <p>Close using this button:</p>
      <button @click="$emit('close')">Close</button>
    </div>
  `
})

Properties

| Name | Required | Type | Default | Description | | --- | --- | --- | --- | --- | | name | true | [String, Number] | | Name of the modal | | delay | false | Number | 0 | Delay between showing overlay and actual modal box | | clickToClose | false | Boolean | true | If set to false, it will not be possible to close modal by clicking on the background | | classes | false | [Array] |[]| Classes that will be applied to the actual modal box| | width | false | [String, Number] | 600 | Width in pixels or percents (e.g. 50 or "50px", "50%") | | height | false | [String, Number] | 100% | Height in pixels or percents (e.g. 50 or "50px", "50%") or "auto" |

Events

| Name | Description | | --- | --- | | before-open | Emits while modal is still invisible, but was added to the DOM | | opened | Emits after modal became visible or started transition | | before-close | Emits before modal is going to be closed. Can be stopped from the event listener calling event.stop() (example: you are creating a text editor, and want to stop closing and ask the user to correct mistakes if the text is not valid) | closed | Emits right before modal is destroyed |