1.1.5 • Published 2 years ago
afournier-modal v1.1.5
afournier-modal
What is it ?
afournier-modal is a library created by Alexis Fournier for the project 14 of Open Classroom developer courses.
What's the purpose of this library ?
afournier-modal allows you to create and use some modals and custom it.
How to use it
import Modal from "afournier-modal"
const App = ():React.FunctionComponent => {
const [isModalOpen, toggleModal] = useState(false);
const closeModal = ():void => {
toggleModal(false);
}
return (
<main>
<button onClick={toggleModal(true)}>Open</button>
<Modal
isOpen={isModalOpen}
handleClose={closeModal}
>
<h1>I'm a modal !</h1>
</Modal>
</main>
)
}
Type
type Position = {
vertical: "top" | "bottom";
horizontal: "left" | "right";
}
Parameters
Parameter | Required | Type | Default |
---|---|---|---|
isOpen | true | boolean | false |
handleClose | true | () => void | undefined |
backgroundOpacity | false | number | 0.6 |
closePosition | false | Position | top-right |
closeColor | false | string | #5D3FD3 |
children | false | React.ReactChild | undefined |