make icon optional in action button

as we'll draw the icon with css
pull/21833/head
Bruno Windels 2018-12-10 15:33:35 +01:00
parent 7936e1a0b7
commit 10a989a003
1 changed files with 6 additions and 2 deletions

View File

@ -30,7 +30,7 @@ export default React.createClass({
action: PropTypes.string.isRequired, action: PropTypes.string.isRequired,
mouseOverAction: PropTypes.string, mouseOverAction: PropTypes.string,
label: PropTypes.string.isRequired, label: PropTypes.string.isRequired,
iconPath: PropTypes.string.isRequired, iconPath: PropTypes.string,
}, },
getDefaultProps: function() { getDefaultProps: function() {
@ -72,6 +72,10 @@ export default React.createClass({
tooltip = <RoomTooltip className="mx_RoleButton_tooltip" label={this.props.label} />; tooltip = <RoomTooltip className="mx_RoleButton_tooltip" label={this.props.label} />;
} }
const icon = this.props.iconPath ?
(<TintableSvg src={this.props.iconPath} width={this.props.size} height={this.props.size} />) :
undefined;
return ( return (
<AccessibleButton className="mx_RoleButton" <AccessibleButton className="mx_RoleButton"
onClick={this._onClick} onClick={this._onClick}
@ -79,7 +83,7 @@ export default React.createClass({
onMouseLeave={this._onMouseLeave} onMouseLeave={this._onMouseLeave}
aria-label={this.props.label} aria-label={this.props.label}
> >
<TintableSvg src={this.props.iconPath} width={this.props.size} height={this.props.size} /> { icon }
{ tooltip } { tooltip }
</AccessibleButton> </AccessibleButton>
); );