Socket
Socket
Sign inDemoInstall

@melmacaluso/vue-modal

Package Overview
Dependencies
10
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @melmacaluso/vue-modal

[![npm](https://img.shields.io/npm/dw/@melmacaluso/vue-modal.svg?label=Downloads)](https://www.npmjs.com/package/@melmacaluso/vue-modal) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https:


Version published
Weekly downloads
105
increased by23.53%
Maintainers
1
Install size
3.71 MB
Created
Weekly downloads
 

Readme

Source

Vue Modal 🖼

npm semantic-release CircleCI (all branches) Commitizen friendly

Reusable Modal component, supports own custom HTML, text and classes and/or passing a component. Featuring multiple modal content / buttons.

Intro

Reusable Modal component, supports own custom HTML, text and classes and/or passing a component. Featuring multiple modal content / buttons.

What this ISN'T

This component is not meant to be a bootstrap-ish already-styled-modal-replacer for Vue.

What this IS

Instead: it wants to take it a step further: it gives you a skeleton base structure where you are free to apply your own css styling according to your requirements/website and gives you freedom of formatting the content/arrows/buttons/events as you wish with little to no effort.

Features

  • Animated modal transition
  • Overlay on modal background
  • Custom event triggering on before-close and before-open
  • Conditional: Next/prev arrows, close button, paging
  • Next and prev arrow for switching between modal contents
  • Modal contents navigation with custom paging
  • CSS/HTML customisation of: prev/next arrows, modal content, modal navigation, modal trigger button/s

Demo

Vue modal animated demo

Installation

npm i @melmacaluso/vue-modal

Usage

Simply import it in your desired vue component as follows:

import Modal from "@melmacaluso/vue-modal";

Props

PropTypeComment
btnTextStringText label for modal button
modalContentStringPass here your html for the modal main modal
closeBtnBooleanConditionally add a close button
closeBtn-contentStringPass here your html for the close button
multipleBooleanAllow multiple buttons/content within the modal
modalsArrayPass here an array of objects, they retain the same props within the array's scope ie. <scope>.btnText
showNavBooleanConditionally show a navigation with each modal's btnText
showArrowsBooleanConditionally show an arrow based navigation
showArrowsCloseBtnBooleanConditionally show an the close button between the prev/next arrows, it inherits closeBtn-content
arrowNextContentStringPass here your html for the next arrow
arrowPrevContentStringPass here your html for the previous arrow
@before-openFunctionAttach here your custom function, it will be invoked before the modal opens
@before-closeFunctionAttach here your custom function, it will be invoked before the modal closes

Examples

Inline HTML:

<Modal
  btnText="Press me, senpai 😊"
  modalContent="
        <div>
          <h2> Hello I am a modal</h2>
          <p>I like stating the obvious: <b>the obvious</b></p>
          <p>Now, try this trick: <code>Ctrl + Shift + W </code> 😉</p>
        </div>
        "
  :closeBtn="true"
  closeBtn-content="
        <span>X</span>
        "
/>

Passing component:

<Modal
  btnText="Press me, senpai 😊"
  :closeBtn="true"
  closeBtnHTML="<span>X</span>"
>
  <ExampleComponent/>
</Modal>

Multiple buttons & modal content + custom functions:

<Modal
  :multiple="true"
  @before-open="yourOpenFn()"
  @before-close="yourCloseFn()"
  :modals="[
    {
      btnText: 'Press me 1',
      modalContent: 'This is <strong>the</strong> content 1'
    },
    {
      btnText: 'Press me 2',
      modalContent:
        '<img src=\'https://media.giphy.com/media/5exwXWg9u7yow/giphy.gif\'>'
    },
    {
      btnText: 'Press me 3',
      modalContent: 'This is the <h3>content 3</h3>'
    }
  ]"
  :showNav="true"
/>

From Api/Json feed + Prev/Next Arrows:

<Modal
  :multiple="true"
  :modals="formattedUsers"
  :showArrows="true"
/>

export default {
  data: () => {
    return {
      users: []
    }
  },
  mounted(){
    fetch('https://jsonplaceholder.typicode.com/users')
      .then(res => res.json())
      .then(res => this.users = res)
      .catch(err => console.log(err))
  },
  computed: {
    formattedUsers: function() {
      return this.users.map(user => {
        return {
          btnText: `${user.name}`,
          modalContent: `
            <h2>Email:${user.email}</h2>
            <h2>Phone:${user.phone}</h2>
          `
        };
      });
    }
  }
}

Keywords

FAQs

Last updated on 04 Mar 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc