forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added react-overlays for base overlay components
- Loading branch information
Showing
15 changed files
with
35 additions
and
1,370 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,3 @@ | ||
import React from 'react'; | ||
import CustomPropTypes from './utils/CustomPropTypes'; | ||
import domUtils from './utils/domUtils'; | ||
|
||
let Portal = React.createClass({ | ||
|
||
displayName: 'Portal', | ||
|
||
propTypes: { | ||
/** | ||
* The DOM Node that the Component will render it's children into | ||
*/ | ||
container: CustomPropTypes.mountable | ||
}, | ||
|
||
componentDidMount() { | ||
this._renderOverlay(); | ||
}, | ||
|
||
componentDidUpdate() { | ||
this._renderOverlay(); | ||
}, | ||
|
||
componentWillUnmount() { | ||
this._unrenderOverlay(); | ||
this._unmountOverlayTarget(); | ||
}, | ||
|
||
_mountOverlayTarget() { | ||
if (!this._overlayTarget) { | ||
this._overlayTarget = document.createElement('div'); | ||
this.getContainerDOMNode() | ||
.appendChild(this._overlayTarget); | ||
} | ||
}, | ||
|
||
_unmountOverlayTarget() { | ||
if (this._overlayTarget) { | ||
this.getContainerDOMNode() | ||
.removeChild(this._overlayTarget); | ||
this._overlayTarget = null; | ||
} | ||
}, | ||
|
||
_renderOverlay() { | ||
let overlay = !this.props.children | ||
? null | ||
: React.Children.only(this.props.children); | ||
|
||
// Save reference for future access. | ||
if (overlay !== null) { | ||
this._mountOverlayTarget(); | ||
this._overlayInstance = React.render(overlay, this._overlayTarget); | ||
} else { | ||
// Unrender if the component is null for transitions to null | ||
this._unrenderOverlay(); | ||
this._unmountOverlayTarget(); | ||
} | ||
}, | ||
|
||
_unrenderOverlay() { | ||
if (this._overlayTarget) { | ||
React.unmountComponentAtNode(this._overlayTarget); | ||
this._overlayInstance = null; | ||
} | ||
}, | ||
|
||
render() { | ||
return null; | ||
}, | ||
|
||
getOverlayDOMNode() { | ||
if (!this.isMounted()) { | ||
throw new Error('getOverlayDOMNode(): A component must be mounted to have a DOM node.'); | ||
} | ||
|
||
if (this._overlayInstance) { | ||
if (this._overlayInstance.getWrappedDOMNode) { | ||
return this._overlayInstance.getWrappedDOMNode(); | ||
} else { | ||
return React.findDOMNode(this._overlayInstance); | ||
} | ||
} | ||
|
||
return null; | ||
}, | ||
|
||
getContainerDOMNode() { | ||
return React.findDOMNode(this.props.container) || domUtils.ownerDocument(this).body; | ||
} | ||
}); | ||
import Portal from 'react-overlays/lib/Portal'; | ||
|
||
export default Portal; |
Oops, something went wrong.