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

v1.1.0

Published

A simple modal implementation in Vue.

Downloads

202

Readme

vue-cute-modal

NPM version

A simple and easy to use Modal component for Vue applications.

Features

  • Simple API
  • Customizable modal classes
  • Customizable Vue transition name
  • Name component whatever you like!

Install

npm i vue-cute-modal

yarn add vue-cute-modal

For In-DOM templates include the JS CDN and optionally the CSS in your project:

CDN:

JS CSS

Usage

Edit Cute Modal

Setup

Include the plugin at the root of your application

import CuteModal from 'vue-cute-modal'

Vue.use(CuteModal)

Creating a Modal

Simply create your modal in your Vue app:

<cute-modal name="example">
  Your modal content.
</cute-modal>

Then open/hide the modal within the app:

// Opens the modal
this.$cuteModal.open('example')

// Hides the modal
this.$cuteModal.hide('example')

Basic Example

<template>
  <div>
    <button @click="open">Open Modal</button>
    <cute-modal name="hello">
      Hello World!
    </cute-modal>
  </div>
</template>

<script>
export default {
  methods: {
    open () {
      this.$cuteModal.open('hello')
    }
  }
}
</script>

<!-- import CSS through SCSS or Link to compiled CSS whichever you prefer -->
<!-- or use your own custom styles! -->
<style>
/* ... */
</style>

Customizing the Component

The plugin comes with some base styles and classes. These may not fit your project and you may wish to override. We can do this via global settings or props.

To override defaults globally pass in the configuration object when you register the component to Vue.use():

/** Default Settings */
const DEFAULT_OPTIONS = {
  body: 'cute-modal__body',
  container: 'cute-modal__container',
  footer: 'cute-modal__footer',
  header: 'cute-modal__header',
  height: 'auto',
  overlay: 'cute-modal__overlay',
  transition: 'modal',
  width: '600px'
}

Vue.use(CuteModal, {
  // Override the component's name to match your app's
  // Default 'cute-modal' = <cute-modal>
  component: '',

  // Override the component's base classes to match your app's
  body: '',
  container: '',
  footer: '',
  header: '',
  overlay: ''

  // Set default width and heights for all your modals
  height: '',
  width: '',

  // Set the transition name to use custom Vue transitions
  // This will be set as the transition's name <transition name="...">
  transition: ''
})

Alternatively, you could pass props separately to each component. Note that these will override the globally set options.

<cute-modal width="350px" headerClass="is-header">
  <!-- -->
</cute-modal>

API

Props

Full prop list

| Name | Required | Type | Description | | --- | --- | --- | --- | | name | true | String | Name of your modal | containerClass | false | String | Class name for container of modal | footerClass | false | String | Modal footer class name | headerClass | false | String | Modal header class name | height | false | String | Set the height of the modal | overlayClass | false | String | Overlay class name | transition | false | String | Name for Vue transition | wdith | false | String | Set the width of the modal

Methods

// Open a Modal
this.$cuteModal.open(/* modal name */)

// Close a Modal
this.$cuteModal.hide(/* modal name */)

In 1.1 a built in hide method is made available within the header and footer slots. It will be available on the slot-scope as a method named $hide. It takes no parameters.

<cute-modal name="myModal">
  Some content

  <template slot="footer" slot-scope="{ $hide }">
    <button @click="$hide">Hide Me</button>
  </template>
</cute-modal>

Development Setup

# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build

# run unit tests
npm run unit

# run all tests
npm test