0.1.4 • Published 1 year ago

modal-celestin v0.1.4

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

Modal Project 14

logo

Install

Install using npm i modal-celestin

Usage

In a React app, use the Modal components: import { Modal } from 'modal'

Modal props

NameDescription
onClickfunction to include in a button to open or close the modal
openModala boolean value to initialize the modal to a closed and not apparent state
setOpenModalto toggle the state and open/close the modal
customTexta string containing a text
customIconea string containing an emoji or HTML CODE SYMBOL

Make it as a component !

  • in your component folder, create a file for your modal that you will import later as it should be.

  • then, at the top of your component page

import React, { useState } from "react";

import { Modal } from "modal";

  • then, set the props :
const [openModal, setOpenModal] = useState(false);

const handleModal = (e) => {
    e.preventDefault();
    e.stopPropagation();
    setOpenModal((toggle) => !toggle);
  };

const customText =
    "Employee created";

const customIcone = <p>🛎️</p>;
  • then insert in your function the Modal and export
<Modal
    openModal={openModal}
    setOpenModal={setOpenModal}
    customText={customText}
    customIcone={customIcone}
        />
  • don't forget to insert onClick={handleModal} in a button for exemple

Submit