Gathering detailed insights and metrics for boss-react-modal-dialog
Gathering detailed insights and metrics for boss-react-modal-dialog
npm install boss-react-modal-dialog
Typescript
Module System
Node Version
NPM Version
46.1
Supply Chain
87
Quality
73.3
Maintenance
25
Vulnerability
98.9
License
JavaScript (93.94%)
CSS (5.19%)
Shell (0.87%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
1,237
Last Day
2
Last Week
4
Last Month
18
Last Year
113
MIT License
104 Commits
1 Forks
3 Watchers
4 Branches
3 Contributors
Updated on Jun 08, 2017
Minified
Minified + Gzipped
Latest Version
4.0.7
Package Id
boss-react-modal-dialog@4.0.7
Size
33.56 kB
NPM Version
4.2.0
Node Version
7.8.0
Cumulative downloads
Total Downloads
Last Day
100%
2
Compared to previous day
Last Week
0%
4
Compared to previous week
Last Month
38.5%
18
Compared to previous month
Last Year
-32.7%
113
Compared to previous year
8
3
2
React modal dialog is an idiomatic way to represent modal dialogs in react. It is nested inside the components that require them, and can themselves nest other dialogs. There are no global switches or state, and the contents of the dialog are defined where you need it.
React modal dialog was built with a few fundamental assumptions and constraints in mind:
From the very beginning, the goal was a syntax very similar to the one below, where the modal component is held within a button or the view with the closest common ancestor of two buttons.
1class Button extends React.Component { 2 state = { 3 isShowingModal: false, 4 } 5 handleClick = () => this.setState({isShowingModal: true}) 6 handleClose = () => this.setState({isShowingModal: false}) 7 render() { 8 return <a onClick={this.handleClick}> 9 <span>Button Text</span> 10 { 11 this.state.isShowingModal && 12 <ModalComponentHere onClose={this.handleClose}/> 13 } 14 </a>; 15 } 16}
This is how react-modal-dialog works. You can create a component that wraps ModalContainer and ModalDialog into one CustomDialog, but the reason I have separated is so that I can add a loading spinner above the background but below the dialog.
1import React from 'react'; 2import PropTypes from 'prop-types'; 3import {ModalContainer, ModalDialog} from 'react-modal-dialog'; 4 5class View extends React.Component { 6 state = { 7 isShowingModal: false, 8 } 9 handleClick = () => this.setState({isShowingModal: true}) 10 handleClose = () => this.setState({isShowingModal: false}) 11 render() { 12 return <div onClick={this.handleClick}> 13 { 14 this.state.isShowingModal && 15 <ModalContainer onClose={this.handleClose}> 16 <ModalDialog onClose={this.handleClose}> 17 <h1>Dialog Content</h1> 18 <p>More Content. Anything goes here</p> 19 </ModalDialog> 20 </ModalContainer> 21 } 22 </div>; 23 } 24}
1import React from 'react'; 2import PropTypes from 'prop-types'; 3import {ModalContainer, ModalDialog} from 'react-modal-dialog'; 4import ReactSpinner from 'react-spinjs'; 5 6class View extends React.Component { 7 static propTypes = { 8 // This view takes a isLoading property 9 isLoading: PropTypes.bool, 10 } 11 state = { 12 isShowingModal: false, 13 } 14 handleClick = () => this.setState({isShowingModal: true}) 15 handleClose = () => this.setState({isShowingModal: false}) 16 render() { 17 const { 18 props: { 19 isLoading, 20 }, 21 } = this; 22 23 return <div onClick={this.handleClick}> 24 { 25 this.state.isShowingModal && 26 <ModalContainer onClose={this.handleClose}> 27 { 28 isLoading ? 29 <ReactSpinner/> : 30 <ModalDialog onClose={this.handleClose}> 31 <h1>Dialog Content</h1> 32 <p>More Content. Anything goes here</p> 33 </ModalDialog> 34 } 35 </ModalContainer> 36 } 37 </div>; 38 } 39}
In version 4.0+ react-modal-dialog has finally shifted to using narcissus, narcissus makes inline css styles sane, and also works in pure javascript so you don't have to spend time requiring css files awkwardly with NPM and packaging them in webpack with custom loaders yourself.
For a similar reason of not having to deal with external dependencies or awkward loaders/hacked require statements, starting in 4.0+, react-modal-dialog uses hand-written svg for the one "image" that comes with the package, the close button.
For now, I recommend you check out the source code of this project, as it is quite simple, to really get an understanding of how this dialog works. I've spent a lot of time trying many paradigms (you can read about all that here), and I've settled on this one for good reasons.
The hardest part about dialogs is their architecture, not the UI or specific implementation. Feel free to swap out your own ModalDialog class into my existing ModalContainer, or disassemble ModalContainer into your own portal and background class.
To get the esc key to only close the top dialog when there are two modal dialogs, I employed the use of an event controller. However, you may find this to be peculiar or you may want to attach your dialogs to your own event controller. If that's true, you may want to branch this project to edit the code in componentDidMount
and componentWillUnmount
of ModalPortal
.
Feel free to send pull requests, or help document this project more.
package.json
package.json points to src/index.js
, so that it is easy to develop against. However, this folder does not exist in the npm distribution, so the whole thing falls back to the /index.js
at the root, which points to the compiled /lib/index.js
.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
45 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More