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

Commit

Permalink
Pass a react element to LabelWithTip
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed Sep 24, 2016
1 parent 5f75ae6 commit 964afa6
Showing 1 changed file with 14 additions and 6 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@


propTypes: { propTypes: {
label:React.PropTypes.string, label:React.PropTypes.string,
labelElement:React.PropTypes.object,
tooltip:React.PropTypes.string, tooltip:React.PropTypes.string,
tooltipClassName:React.PropTypes.string, tooltipClassName:React.PropTypes.string,
className:React.PropTypes.string, className:React.PropTypes.string,
Expand All @@ -670,19 +671,21 @@


render:function(){ render:function(){
if(this.props.tooltip){ if(this.props.tooltip){
var tooltipStyle={}; let tooltipStyle={};
if(this.props.label){ if(this.props.label || this.props.labelElement){
if(this.state.show){ if(this.state.show){
tooltipStyle = {bottom: -10, top: 'inherit'}; tooltipStyle = {bottom: -10, top: 'inherit'};
} }
}else{ }else{
tooltipStyle = {position:'relative'}; tooltipStyle = {position:'relative'};
} }
var label; let label;
if(this.props.label){ if(this.props.label){
label = <span className="ellipsis-label">{this.props.label}</span>; label = <span className="ellipsis-label">{this.props.label}</span>;
}else if(this.props.labelElement){
label = this.props.labelElement;
} }
var style = this.props.style || {position:'relative'}; let style = this.props.style || {position:'relative'};


return ( return (
<span onMouseEnter={this.show} onMouseLeave={this.hide} style={style} className={this.props.className}> <span onMouseEnter={this.show} onMouseLeave={this.hide} style={style} className={this.props.className}>
Expand All @@ -692,8 +695,13 @@
</span> </span>
); );
}else{ }else{
if(this.props.label) return (<span>{this.props.label}</span>); if(this.props.label) {
else return (<span>this.props.children</span>); return <span>{this.props.label}</span>;
} else if(this.props.labelElement) {
return this.props.labelElement;
} else {
return <span>{this.props.children}</span>;
}
} }
} }


Expand Down

0 comments on commit 964afa6

Please sign in to comment.