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

modal-vue

v0.0.3

Published

A modal dialog component for Vue.js 2.x

Downloads

1,318

Readme

modal-vue

A modal dialog component for Vue.js 2.x

Example image

installation

npm install --save modal-vue

Then, within the <script> tag of the component in which you want to use the modal-vue component you need to import it and register it as a component.

import Modal from 'modal-vue'
export default {
  components: { Modal },
  ...rest of component properties
}

Refer to the vuejs documentation page for full details of using components.

usage

Let's start with a quick example extracted from the <template> tag of a component which uses modal-vue. Maybe that's all you need! but see below for full details of all options.

<modal :showModal="showSourceDialog" :closeAction="closeSourceDialog">
  <h1 slot="header">Select Source</h1>
  <select slot="body" :value="database.source" @change="changeSource($event.target.value)">
    <option v-for="source in ['', ...refdata.sources]">{{ source }}</option>
  </select>
</modal>

properties

modal-vue accepts 3 props which are passed to it as attributes in the <modal> element:

showModal

If true, the modal dialog will be displayed. Pass in whatever state in your application controls this.

closeAction

This is the function to called when the close button of the modal dialog is clicked. This can do whatever you need it to, but don't forget to change the state which controls the showModal prop or you will have a dialog for life.

containerClass

This is optional and specifies a CSS class to be used for the that wraps the modal dialog if required.

slots

modal-vue has 3 html slots which are defined as child elements of the <modal> element:

header

This is optional and the contents of it will be used for the heading of the modal dialog. A close button will also be displayed in the header.

If both no header slot and no closeAction prop are defined a dialog without a close button will be displayed. Hopefully in this case you will have provided some other mechanism in the body or footer to allow the dialog to be closed.

body

This defines the contents of the body of the modal dialog. In the example at the start of this section, the body consists of an html select dropdown including an onChange handler. In this example when the onChange handler is fired the dialog is closed, so no need for any footer buttons etc.

footer

This defines the contents of the body of the modal dialog. Often it might be used for such things as Ok / Cancel buttons.

dependencies

This component uses Bootstrap v3 for CSS. If you are not already using Bootstrap, you can find installation instructions here.

credits

This component was originally based on Kris Jenkin's excellent Elm Dialog library.