0.2.7 • Published 9 months ago

generic-react-modal v0.2.7

Weekly downloads
-
License
-
Repository
github
Last release
9 months ago

generic-react-modal

Provide simple generic modal components for React.js

Table of Contents

Installation

To install, you can use npm or yarn:

$ npm install generic-react-modal
$ yarn add generic-react-modal

Features

  • Modal component : renders a modal and its background. You can easily customize the header's title, body's content, body's padding, background opacity, but also choose it's type (default, error, success), display a close button or allow a click on the background to close the modal.
  • ModalBackground component : just renders a background. You can easily customize the opacity and allow a click on it to close the modal it contains.

Example

A simple example of a generic-react-modal used to show a modal when the user successfully send a form:

import React from "react";
import ReactDOM from "react-dom";
import { Modal } from "generic-react-modal";

function App() {
    const [modalIsOpen, setModalIsOpen] = React.useState(false);
    function openModal() {
        setModalIsOpen(true);
    }

    return (
        <div>
            <button onClick={openModal}>Send form</button>
            <Modal
                opened={modalIsOpen}
                setOpened={setModalIsOpen}
                type="success"
                title="Form sent"
                paddingH={40}
                paddingV={20}
            >
                <p>
                    We have received your answers. Thank you for participating
                    in this survey!
                </p>
            </Modal>
        </div>
    );
}

ReactDOM.render(<App />, appElement);
0.2.7

9 months ago

0.2.6

9 months ago

0.2.5

9 months ago

0.2.4

10 months ago

0.2.3

10 months ago

0.2.2

10 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.1.0

10 months ago