Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
env:
browser: true
es6: true
extends: 'eslint:recommended'
installedESLint: true
parserOptions:
ecmaFeatures:
experimentalObjectRestSpread: true
jsx: true
sourceType: module
plugins:
- react
rules:
indent:
- error
- 2
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- never
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"devDependencies": {
"babel": "^5.8.23",
"chai": "^3.3.0",
"eslint": "3.2.2",
"eslint-plugin-react": "6.0.0",
"gulp": "^3.8.11",
"legit-tests": "^0.4.4",
"mocha": "^2.3.3",
Expand Down
27 changes: 21 additions & 6 deletions src/simple-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ export default class Modal extends React.Component{

let opacity = 0,
display = 'block',
visibility = 'hidden';
visibility = 'hidden'

if(props.show){
opacity = 1;
display = 'block';
opacity = 1
display = 'block'
visibility = 'visible'
}

Expand All @@ -24,13 +24,13 @@ export default class Modal extends React.Component{
display,
visibility,
show: props.show
};
}

}

hideOnOuterClick(event){
if(this.props.closeOnOuterClick === false) return
if(event.target.dataset.modal) this.props.onClose(event)
if(event.target.dataset.modal && this.props.onClose instanceof Function) this.props.onClose(event)
}

componentWillReceiveProps(props){
Expand Down Expand Up @@ -78,12 +78,27 @@ export default class Modal extends React.Component{
if(this.props.transitionSpeed) modalStyle = Object.assign({}, this.state, modalStyle)

return (
<div {...this.props} style={modalStyle} onClick={this.hideOnOuterClick} data-modal="true">
<div {..._filteredProps(this.props)} style={modalStyle} onClick={this.hideOnOuterClick} data-modal="true">
<div className={this.props.containerClassName} style={containerStyle}>
{this.props.children}
</div>
</div>
)
}
}

function _filteredProps(props) {
const filtered = Object.assign({}, props);
[
'containerStyle',
'containerClassName',
'closeOnOuterClick',
'show',
'onClose'
].map( p => {
delete filtered[p]
})
return filtered
}

export var closeStyle = styles.close