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

Commit 964afa6

Browse files
committed
Pass a react element to LabelWithTip
1 parent 5f75ae6 commit 964afa6

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

core/src/plugins/gui.ajax/res/js/ui/reactjs/jsx/ReactPydioComponents.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@
655655

656656
propTypes: {
657657
label:React.PropTypes.string,
658+
labelElement:React.PropTypes.object,
658659
tooltip:React.PropTypes.string,
659660
tooltipClassName:React.PropTypes.string,
660661
className:React.PropTypes.string,
@@ -670,19 +671,21 @@
670671

671672
render:function(){
672673
if(this.props.tooltip){
673-
var tooltipStyle={};
674-
if(this.props.label){
674+
let tooltipStyle={};
675+
if(this.props.label || this.props.labelElement){
675676
if(this.state.show){
676677
tooltipStyle = {bottom: -10, top: 'inherit'};
677678
}
678679
}else{
679680
tooltipStyle = {position:'relative'};
680681
}
681-
var label;
682+
let label;
682683
if(this.props.label){
683684
label = <span className="ellipsis-label">{this.props.label}</span>;
685+
}else if(this.props.labelElement){
686+
label = this.props.labelElement;
684687
}
685-
var style = this.props.style || {position:'relative'};
688+
let style = this.props.style || {position:'relative'};
686689

687690
return (
688691
<span onMouseEnter={this.show} onMouseLeave={this.hide} style={style} className={this.props.className}>
@@ -692,8 +695,13 @@
692695
</span>
693696
);
694697
}else{
695-
if(this.props.label) return (<span>{this.props.label}</span>);
696-
else return (<span>this.props.children</span>);
698+
if(this.props.label) {
699+
return <span>{this.props.label}</span>;
700+
} else if(this.props.labelElement) {
701+
return this.props.labelElement;
702+
} else {
703+
return <span>{this.props.children}</span>;
704+
}
697705
}
698706
}
699707

0 commit comments

Comments
 (0)