Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Make LabelWithTip more generic
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Mar 25, 2016
1 parent 5809584 commit 12568db
Showing 1 changed file with 14 additions and 4 deletions.
Expand Up @@ -656,7 +656,9 @@
propTypes: {
label:React.PropTypes.string,
tooltip:React.PropTypes.string,
tooltipClassName:React.PropTypes.string
tooltipClassName:React.PropTypes.string,
className:React.PropTypes.string,
style:React.PropTypes.object
},

getInitialState:function(){
Expand All @@ -672,14 +674,22 @@
if(this.state.show){
style = {bottom: -10, top: 'inherit'};
}
var label;
if(this.props.label){
label = <span className="ellipsis-label">{this.props.label}</span>;
}
var style = this.props.style || {position:'relative'};

return (
<span onMouseEnter={this.show} onMouseLeave={this.hide} style={{position:'relative'}}>
<span className="ellipsis-label">{this.props.label}</span>
<span onMouseEnter={this.show} onMouseLeave={this.hide} style={style} className={this.props.className}>
{label}
{this.props.children}
<ReactMUI.Tooltip label={this.props.tooltip} style={style} className={this.props.tooltipClassName} show={this.state.show}/>
</span>
);
}else{
return <span>{this.props.label}</span>
if(this.props.label) return <span>{this.props.label}</span>
else return <span>this.props.children</span>
}
}

Expand Down

0 comments on commit 12568db

Please sign in to comment.