-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(widgets): auto hide some widgets
We now auto hide: - refinementList - menu - rangeSlider - toggle - pagination + option hideWhenNoResults available for all widgets + refactor the way we handle hiding: now somehow a decorator, see: - https://gist.github.com/sebmarkbage/ef0bf1f338a7182b6775 - https://gist.github.com/sebmarkbage/ef0bf1f338a7182b6775#gistcomment-1574787 For more details, or ask me.
- Loading branch information
vvo
committed
Sep 24, 2015
1 parent
8435bc5
commit 187b4bd
Showing
18 changed files
with
121 additions
and
60 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
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
var React = require('react'); | ||
|
||
function autoHide(ComposedComponent) { | ||
class AutoHide extends React.Component { | ||
componentDidMount() { | ||
this._hideOrShowContainer(this.props); | ||
} | ||
|
||
componentWillReceiveProps(nextProps) { | ||
this._hideOrShowContainer(nextProps); | ||
} | ||
|
||
_hideOrShowContainer(props) { | ||
var container = React.findDOMNode(this).parentNode; | ||
if (props.hideIfEmpty === true && props.hasResults === false) { | ||
container.style.display = 'none'; | ||
} else if (props.hideIfEmpty === true) { | ||
container.style.display = ''; | ||
} | ||
} | ||
|
||
render() { | ||
if (this.props.hasResults === false && | ||
this.props.hideIfEmpty === true) { | ||
return <div/>; | ||
} | ||
|
||
return <ComposedComponent {...this.props} />; | ||
} | ||
} | ||
|
||
AutoHide.propTypes = { | ||
hasResults: React.PropTypes.bool.isRequired, | ||
hideIfEmpty: React.PropTypes.bool.isRequired | ||
}; | ||
|
||
// precise displayName for ease of debugging (react dev tool, react warnings) | ||
AutoHide.displayName = ComposedComponent.name + '-AutoHide'; | ||
|
||
return AutoHide; | ||
} | ||
|
||
module.exports = autoHide; |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.