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

@jadina/modal-plugin

v0.1.7

Published

customizable modal plugin for React applications

Downloads

24

Readme

Modal Plugin

A flexible and customizable modal plugin for React applications.

npm version

Installation

You can install this modal plugin using npm or yarn:


npm install  @jadina/modal-plugin

# or

yarn add  @jadina/modal-plugin

Usage

  • import the necessary components and use them in your React application:

[!NOTE]

Manual Setup: Users need to include Font Awesome via a CDN:


<link  rel="stylesheet"  href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css"  />


Basic Modal with Custom Content



import React from  'react';

import { Modal, useModal } from  '@jadina/modal-plugin';

  

const App = () => {

const { showModal, activeModal, handleOpenModal, handleCloseModal } = useModal();

return (

<>

<button  type='button'  className='buttonDefault'

onClick={() => handleOpenModal('customContent')}>

Modal with Custom Content

</button>

<Modal

isOpen={showModal && activeModal === 'customContent'}  close={handleCloseModal}  addCloseIcon={true}>

<div  className="custom-modal-content">

<h2>Custom Content Modal</h2>

<p>This modal contains custom content, such as images and text.</p>

<img  src="./modal-image.png"  alt=""  />

</div>

</Modal>

</>

);

};

export  default App;

Resizable Modal



  

import React, { useState } from  'react';

import { ResizableModal } from  '@jadina/modal-plugin';

  

const App = () => {

const [showModal, setShowModal] = useState(false);

const openModal = () => {

setShowModal(true);

};

const closeModal = () => {

setShowModal(false);

};

return (

<>

<button  type='button'  className='buttonDefault'

onClick={openModal}>Open Resizable Modal</button>

{showModal && (

<ResizableModal

onClose={closeModal}

initialWidth={400}

initialHeight={300}

minWidth={300}

minHeight={200}

maxWidth={800}

maxHeight={600}

addCloseIcon={true}

>

{/* Your resizable modal content */}

<h2>Resizable Modal Content</h2>

<p>This modal can be resized.</p>

</ResizableModal>

)}

</>

);

};

export  default App;

Modal with Footer Button



import React from  'react';

import { Modal, useModal } from  '@jadina/modal-plugin';

  

const App = () => {

const { showModal, activeModal, handleOpenModal, handleCloseModal } = useModal();

return (

<>

<button  type='button'  className='buttonDefault'

onClick={() => handleOpenModal('footerButton')}>

Modal with footerButton

</button>

<Modal

isOpen={showModal && activeModal === 'footerButton'}  close={handleCloseModal}  addFooterButton={true}

addCloseIcon={false}>

<h2>footerButton</h2>

</Modal>

</>

);

};

export  default App;

Modal with Close Overlay



import React from  'react';

import {Modal, useModal } from  '@jadina/modal-plugin';

  

const App = () => {

const { showModal, activeModal, handleOpenModal, handleCloseModal } = useModal();

return (

<>

<button  type='button'  className='buttonDefault'

onClick={() => handleOpenModal('closeOverlay')}>

Modal with closeOverlay

</button>

<Modal

isOpen={ showModal && activeModal === 'closeOverlay'  }  close={handleCloseModal}  addCloseOverlay={true}>

<h2>closeOverlay</h2>

</Modal>

</>

);

};

export  default App;

Modal with Close Escape



import React from  'react';

import {Modal, useModal } from  '@jadina/modal-plugin';

  

const App = () => {

const { showModal, activeModal, handleOpenModal, handleCloseModal } = useModal();

return (

<>

<button  type='button'  className='buttonDefault'

onClick={() => handleOpenModal('closeEscape')}>

Modal with closeEscape

</button>

<Modal

isOpen={ showModal && activeModal === 'closeEscape'  }  close={handleCloseModal}  addCloseEscape={true}>

<h2>closeEscape</h2>

</Modal>

</>

);

};

  

export  default App;

Modal with Loader



  

import React from  'react';

import { Modal, useModal } from  '@jadina/modal-plugin';

  

const App = () => {

const { showModal, activeModal, handleOpenModal, handleCloseModal, isLoading, toggleLoader } = useModal();

const loaderTimer = () => {

toggleLoader();

setTimeout(() => {

handleOpenModal('loader');

}, 1000);

};

const closeModal = () => {

handleCloseModal('loader');

};

return (

<>

<button  type='button'  className='buttonDefault'

onClick= {loaderTimer}>

Modal with loader

</button>

<Modal

isOpen={showModal && activeModal === 'loader'}  close={closeModal}  loader={isLoading}  addCloseIcon={true}>

<h2>loader</h2>

</Modal>

</>

);

};

export  default App;

  

Modal with ScrollingButton



import React from  'react';

import { CustomScrollingModal, ScrollingButton, useModal } from  '@jadina/modal-plugin';

  

const App = () => {

const { showModal, activeModal, handleOpenModal, handleCloseModal } = useModal();

const openScrollingModal = () => {

handleOpenModal('scrolling-modal');

};

const closeScrollingModal = () => {

handleCloseModal('scrolling-modal');

};

return (

<>

<ScrollingButton  text="Open Scrolling Modal"

onClick= {openScrollingModal}  />

<CustomScrollingModal

isOpen={showModal && activeModal === 'scrolling-modal'}  onClose={closeScrollingModal}>

<h2>Custom Scrolling Modal</h2>

<p>This modal contains custom scrolling content.</p>

<div  className="scrollable-content">

<p>

Lorem ipsum dolor sit amet, consectetur adipiscing elit...

</p>

</div>

</CustomScrollingModal>

</>

);

};

export  default App;

Features

Classic modal with customizable content and options.

Modal with custom scrolling content for long text.

Button that triggers a custom scrolling modal.

Resizable modal for flexible dimensions.

Props

  • isOpen - Boolean indicating if the modal is open

  • close - Callback function to close the modal.

  • children - Content to be displayed inside the modal

  • addCloseEscape - Whether to close the modal on Escape key press.

  • addCloseOverlay - Whether to close the modal on clicking outside overlay.

  • addCloseIcon - Whether to show the close icon button.

  • customClassName - Custom CSS class name for the modal.

  • addFooterButton - Whether to add a footer button.

  • loader - Whether to display the loader.

  • darkTheme - enable dark theme for the modal

Each modal component accepts specific props. Refer to the documentation for detailed information on available props for each modal type.

Dependencies

License

This project is licensed under the MIT License - see the LICENSE file for details.

https://github.com/samarkand-fr/modal_plugin_p14#readme