Nested Modal is a component that helps manage lots of modals shown at the same time.
- Easy to use: Very easy to create all the modals you need by just wrapping the content nodes with the Nested Modal wrapper.
- Full Control: Abstracts only the main parts, you can fully control visiblity with ids and callbacks.
npm install nested-modal
We are still working on some proper docs.
Main example:
- Use a useState hook to control Visibility.
- Each node added will be a modal.
- Ids have to be unique.
import NestedModal from 'nested-modal'
const App = () => {
return (
<NestedModal
currentOpenedModal={currentOpenedModal}
setCurrentOpenedModal={setCurrentOpenedModal}
onClose={() => {}}
>
<div id='first-modal'>
Modal content
<button onClick={() => setCurrentOpenedModal('second-modal')}>asd</button>
</div>
<div id='second-modal'>Modal content 2</div>
</NestedModal>
)
}
I made this package just for fun. Anyone who would like to contribute is welcomed to open PR's or post suggestions/issues.
In order to work on this package you need to follow these steps:
- Create a react project. e.g. with CRA
- In nested-modal create a link:
npm link
- Go to your project and link nested-modal with your project:
npm link nested-modal
- One last thing, you need to link your projects react copy in the nested-modal codebase:
npm link ../path-to-my-cra-project/node_modules/react
- Before opening a pr please undo the last step as it will break the packge release workflow.
npm unlink ../path-to-my-cra-project/node_modules/react
We will be using Facebook code of conduct. Please read the full text so that you can understand what actions will and will not be tolerated.
Nested Modal is MIT licensed.