Created
April 19, 2017 16:15
-
-
Save damon-kreft/b4eb0f992f503a70ca3cd752c3bcc438 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {Component} from 'react' | |
import {connect} from 'react-redux' | |
import classNames from 'classnames' | |
class InjectPoint extends Component { | |
render () { | |
const {popUpStack} = this.props | |
const children = popUpStack.map((item, i) => { | |
const clonedChild = React.cloneElement(item.Component, { | |
...item.Component.props, | |
ref: item.Component.key, | |
className: classNames('c-popup', item.Component.props.className) | |
}) | |
return ( | |
<div | |
key={item.Component.key + 'backdrop'} | |
className='c-popup-modal' | |
style={{zIndex: (i + 1) * 100 - 1}}> | |
{clonedChild} | |
</div> | |
) | |
}) | |
return ( | |
<div className='c-popup-inject-point'> | |
{children} | |
</div> | |
) | |
} | |
} | |
export default connect((state) => { | |
return state.popUps | |
})(InjectPoint) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment