1.1.8 • Published 1 year ago

tiny-modal-testy v1.1.8

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

tiny-modal-testy

A modal component for Reactjs application.

Installation

npm i tiny-modal-testy

Usage

The modal component is simple :

  • Displays an array of messages
  • Can be closed with a click on a top-right cross or outside.
  • Can be customed with some css properties

Here is an usage example :

import { Modal } from "tiny-modal-testy";
import { useState } from "react";

export const MyComponent = () => {

    // A modal opening state
    const [isOpen, setIsOpen] = useState<boolean>(false);

    // You have to add an handler for the modal opening
    const handleModalOpening = (): void => {
        setIsOpen(!isOpen);
    };

    // You may want to add an handler for the modal closing
    const closeModal = (): void => {
        // do stuff
    };

    const getMessages = (): string[] => {
        return ["Employee successfully created !"];
    };

    // All of these are optional
    const modalCSSProperties = {
        zIndex: 1000,
        backgroundColor: "#eff9bd",
        color: "black",
        fontWeight: 400,
    };
    // All of these are optional
    const closeModalCSSProperties = {
        backgroundColor: "transparent",
        color: "#6c850f",
    };
    // If true, the background around the modal is darker
    const backgroundShadow: boolean = true;

    return (
        <main>
            <Modal
                isOpen={isOpen}
                modalMessages={getMessages()}
                closeModal={closeModal}
                modalCSSProperties={modalCSSProperties}
                closeModalCSSProperties={closeModalCSSProperties}
                backGroundShadow={backgroundShadow}
            />
        </main>
    );
};

Props details

PropTypeDescription
isOpenbooleanIf true, the modal is displayed
modalMessagesstring []The array of messages displayed in the modal
closeModal()=>{void}The function that closes the modal. You can add any other action you want to trigger when the modal is closed
modalCSSPropertiesmodalCSSProperties : { zIndex?: number; backgroundColor?: string; color?: string; boxShadow? : string; fontWeight? : number}Custom the modal style
closeModalCSSPropertiescloseModalCSSProperties : { backgroundColor?: string; color?: string }custom the cross to close the modal
backGroundShadowbooleanIf the background around the modal is darker or transparent

License

MIT

1.1.8

1 year ago

1.1.7

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago