From fd7e81193eaacb0262eac089ec1bcbcbd64030cf Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Mon, 25 Sep 2017 16:06:46 +0100 Subject: [PATCH] Less coupling between HeaderButton and RightPanel Use isHighlighted as a prop instead of computing based on phases and currentPhase --- src/components/structures/RightPanel.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/components/structures/RightPanel.js b/src/components/structures/RightPanel.js index c58d3c625..6b7633ad4 100644 --- a/src/components/structures/RightPanel.js +++ b/src/components/structures/RightPanel.js @@ -44,7 +44,6 @@ class HeaderButton extends React.Component { render() { const TintableSvg = sdk.getComponent("elements.TintableSvg"); const AccessibleButton = sdk.getComponent("elements.AccessibleButton"); - const isHighlighted = this.props.phases.includes(this.props.currentPhase); return  } - { isHighlighted ?
:
} + { this.props.isHighlighted ?
:
} ; } } HeaderButton.propTypes = { - // If currentPhase is one of the specified phases, the button will be highlighted - phases: PropTypes.arrayOf(PropTypes.string).isRequired, - // The currentPhase of the RightPanel - currentPhase: PropTypes.string.isRequired, + // Whether this button is highlighted + isHighlighted: PropTypes.bool.isRequired, // The phase to swap to when the button is clicked clickPhase: PropTypes.string.isRequired, // The source file of the icon to display @@ -243,22 +240,18 @@ module.exports = React.createClass({ if (this.props.roomId) { headerButtons = [ , , , ];