simple-modal-jr-lib

2.0.1 • Public • Published

simple-modal-jr-lib

Simple modal library

NPM JavaScript Style Guide

Install

npm install --save simple-modal-jr-lib

Usage

import React, { useState } from 'react'
import Modal from 'simple-modal-jr-lib'
import 'simple-modal-jr-lib/dist/index.css'

export default function Example() {
  const [openModal, setOpenModal] = useState(false) // this hook will determine when the modal opens or closes
  return (
    <div className='Example'>
      <h1>Modal Test</h1>
      <button onClick={() => setOpenModal(true)}>Open Modal</button>{' '}
      {/* We set the OpenModal hook on true to open the modal when we click on the button */}
      <Modal isOpen={openModal} onClose={() => setOpenModal(false)}>
        <p>Exemple text !</p>
      </Modal>
      {/* The modal component needs at least the 'setIsOpen' and the onClose function  */}
    </div>
  )
}

## License

MIT © [RenierJordan](https://github.com/RenierJordan)

Customisation

Props Description Type
isOpen /!\Required/!\ this will allow the component to change the state to "false" to close the modal boolean
onClose /!\Required/!\ this will be called to close the modal function

/simple-modal-jr-lib/

    Package Sidebar

    Install

    npm i simple-modal-jr-lib

    Weekly Downloads

    7

    Version

    2.0.1

    License

    MIT

    Unpacked Size

    9.27 kB

    Total Files

    7

    Last publish

    Collaborators

    • renierjordan