simple-react-modal-v1-adrienlzl
v0.1.0
Published
simple react component
Downloads
1
Readme
simple-react-modal-component
A simple react modal component
Prerequisites
Install
npm i simple-react-modal-v1-adrienlzl
You can check your node_modules folder to make sure the package has been installed correctly
How to use this modal
Usage
import React, { useState } from 'react';
import { Modal } from 'simple-react-modal-v1-adrienlzl/dist/index';
function App() {
const [isOpen, setIsOpen] = useState(false);
return (
<div>
<button onClick={() => setIsOpen(true)}>Click to open</button>
<Modal
isOpen={isOpen}
onClose={() => setIsOpen(false)}
onExternalClick={() => setIsOpen(false)}
>
Modal message !
</Modal>
</div>
);
}
export default App;
CSS
https://github.com/adrienlzl/Projet-14-Wealth-Health-092023-modal-component/blob/main/src/lib/component/Modal.scss
or copy this css code :
.blocker {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
overflow: auto;
z-index: 1;
padding: 20px;
box-sizing: border-box;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.75);
text-align: center;
}
.modal {
display: inline-block;
vertical-align: middle;
position: relative;
z-index: 2;
max-width: 500px;
box-sizing: border-box;
width: 90%;
background: #fff;
padding: 15px 30px;
border-radius: 8px;
-o-box-shadow: 0 0 10px #000;
-ms-box-shadow: 0 0 10px #000;
box-shadow: 0 0 10px #000;
text-align: left;
}
.modal a.close-modal, .close-modal {
position: absolute;
top: -12.5px;
right: -12.5px;
display: block;
width: 30px;
height: 30px;
text-indent: -9999px;
background-size: contain;
background-repeat: no-repeat;
background-position: center center;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAA3hJREFUaAXlm8+K00Acx7MiCIJH/yw+gA9g25O49SL4AO3Bp1jw5NvktC+wF88qevK4BU97EmzxUBCEolK/n5gp3W6TTJPfpNPNF37MNsl85/vN/DaTmU6PknC4K+pniqeKJ3k8UnkvDxXJzzy+q/yaxxeVHxW/FNHjgRSeKt4rFoplzaAuHHDBG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