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

open-modal

v1.0.2

Published

This is a simple modal, which uses animate.css as an effect and it is possible to change the transparent background color.

Downloads

148

Readme

OpenModal

Open Modal is a pure Js module, which uses the animate.css library to create the modal effects.

https://github.com/isaacangello/openModal/assets/13286180/8b2cc536-6f23-460c-9316-eadd6661cf2c

install


  npm install open-modal

How to use?

To use Open Modal you need to have animate.css installed in your application, go to https://animate.style/ to configure it, then initialize Open Modal like this.

import OpenModal  from "./dist/open-modal.js"

const openModal = new OpenModal()

openModal.init()

After the Open modal is initialized, you will need a button with a defined ID that by default works with the ID "showModal", and you will also need a modal window with a css class to hide and show the modal elements, this class could be the class ".hide" of materialize.css or the '.d-none" class from bootstrap, or you can define your own class to hide/show the modal elements. You will need a Container div with the class ".open-modal" defined, or a class of its own defined in the cotainer, and a div with a class defined as modal-content, this step is important to activate the effects.

OBS

If you want to use the project's css, there is an open-modal css file in the same folder as the module

button code example
<button id="showModal" class="btn"> show modal</button>
Modal code example
    <div id="modal1" class="open-modal hide">
    <div class="modal-content">
        <div class="modal-body">
            <h4>Modal Header</h4>
            <p>
                Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
                ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
                laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
                velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident,
                sunt in culpa qui officia deserunt mollit anim id est laborum
            </p>
        </div>
        <div class="modal-footer">
            <button id="cancelButton" class="btn-materialize">disAgree</button>
            <button  class="btn-materialize">Agree</button>
        </div>
    </div>
</div>

Open Modal Options

It is possible to configure some options to change the way Open Modal works, the configurable options are passed to the class constructor as a literal object

Example

import OpenModal  from "./dist/open-modal.js"

const openModal = new OpenModal({
    optionKey1: "optionValue1",
    optionKey2: "optionValue2",
})

openModal.init()

Options and standards values

   let options = {
            btnShowId : "showModal",            
            btnCancelId : "cancelButton",
            containerClass : 'open-modal',
            contentClass : 'modal-content',
            hideClass : 'hide',
            containerBackground : false,
            containerEffects : false,
            contentEffects : false,
  }

| --- | Options | --- | |---------------------|--------------------|-------------------------------------------------------------------------------------------------------------------------------------------------| | Option key | Standard value | Option value description | | btnShowId | "showModal" | Receives the id of the button responsible for opening the modal using the click event. | | btnCancelId | "cancelButton" | Receives the id of the button responsible for closing the modal | | containerClass | "open-modal" | Receives the Class of the modal container | | contentClass | 'modal-content' | Receives the Class of the div in which the content is located | | hideClass | "hide" | This css class that hides the elements, this class is applied together with the '.open-modal" class | | containerBackground | false | this value receives the Rgb or Exadecimal code for a color, | | containerEffects | false | This Key returns an array as values containing the classes necessary to activate the effects in the container div using the animate.css library | | contentEffects | false | This Key returns an array as values containing the classes necessary to activate the effects in the content div using the animate.css library |

Exemple of containerEffects & contentEffects

import OpenModal  from "./dist/open-modal.js";

const openModal = new OpenModal(
    {
        btnShowId:'botaoMostrar',
        containerBackground: "rgba(19, 247, 15, 0.471)",
        containerEffects:{
            containerInEffects:['animate__animated','animate__fadeInDown'],
            containerOutEffects:['animate__animated', 'animate__bounceOutUp']
        },
        contentEffects:{
            contentInEffects: ['animate__animated','animate__fadeInDown'],
            contentOutEffects: ['animate__animated','animate__bounceOutUp'],
        },


    }
)

openModal.init()

OBS:

If you decide to change the ID's of the container and content you will have to change your css, as changing their names will undo the references to the open-modal.css file, or you can change the names and use Tailwindcss, materializecss, Bootstrap if you prefer.