Skip to content

Commit a5562cc

Browse files
committed
Change tooltip to openOn and pass in string
1 parent be08413 commit a5562cc

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

components/SLDSTooltip/index.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ module.exports = React.createClass( {
2727
content: PropTypes.node,
2828
hoverCloseDelay: PropTypes.number,
2929
openByDefault: PropTypes.bool,
30-
openOnClick: PropTypes.bool,
31-
openOnHover: PropTypes.bool,
30+
openOn: PropTypes.string,
3231
},
3332

3433

@@ -38,8 +37,7 @@ module.exports = React.createClass( {
3837
content: <span>Tooltip</span>,
3938
hoverCloseDelay: 350,
4039
openByDefault: false,
41-
openOnClick: false,
42-
openOnHover: false,
40+
openOn: 'hover',
4341
};
4442
},
4543

@@ -142,7 +140,7 @@ module.exports = React.createClass( {
142140

143141
render(){
144142
return (
145-
<span refs='tooltipTarget' onClick={this.props.openOnClick?this.handleMouseClick:null} onMouseEnter={this.props.openOnHover?this.handleMouseEnter:null} onMouseLeave={this.props.openOnHover?this.handleMouseLeave:null}>
143+
<span refs='tooltipTarget' onClick={this.props.openOn === 'click' ? this.handleMouseClick:null} onMouseEnter={this.props.openOn === 'hover' ? this.handleMouseEnter:null} onMouseLeave={this.props.openOn === 'hover' ? this.handleMouseLeave:null}>
146144
{ this.props.children }
147145
{ this.getTooltip() }
148146
</span>

demo/pages/HomePage/TooltipSection.jsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@ const alignNames = ['left','top','right','bottom'];
1818

1919
module.exports = React.createClass( {
2020

21+
displayName: 'Toolip',
22+
2123
getDefaultProps () {
2224
return {};
2325
},
2426

2527
getInitialState () {
2628
return {
27-
alignIndex:0
29+
alignIndex: 0
2830
};
2931
},
3032

@@ -51,7 +53,7 @@ module.exports = React.createClass( {
5153
if (nextAlignIndex >= alignNames.length) {
5254
nextAlignIndex = 0;
5355
}
54-
this.setState({alignIndex:nextAlignIndex});
56+
this.setState({alignIndex: nextAlignIndex});
5557
},
5658

5759
render() {
@@ -67,7 +69,8 @@ module.exports = React.createClass( {
6769
{require("raw-loader!../../code-snippets/SLDSDropdownPage.txt")}
6870
</PrismCode>
6971
*/}
70-
<section style={{paddingLeft:'10rem'}}>
72+
<section style={{paddingLeft: '10rem'}}>
73+
{/*
7174
<div className="slds-p-vertical--large">
7275
<p>
7376
<SLDSTooltip
@@ -78,25 +81,26 @@ module.exports = React.createClass( {
7881
</SLDSTooltip>
7982
</p>
8083
</div>
84+
*/}
8185

82-
<div ref="tooltipOnHover" className="slds-p-vertical--large">
83-
<p style={{marginTop:'5rem'}}>
86+
<div ref="tooltipOnHover" className="slds-p-vertical--medium">
87+
<p style={{marginTop: '5rem'}}>
8488
<SLDSTooltip
85-
content={<span>Tooltip with bottom alignment</span>}
86-
align='bottom'
87-
openOnHover={true}
89+
content={<span>Tooltip with top alignment</span>}
90+
align='top'
91+
openOn='hover'
8892
targetElement={this.refs.tooltipOnHover}>
8993
Tooltip open on hover
9094
</SLDSTooltip>
9195
</p>
9296
</div>
9397

94-
<div ref="tooltipOnClick" className="slds-p-vertical--large">
95-
<p style={{marginTop:'5rem'}}>
98+
<div ref="tooltipOnClick" className="slds-p-vertical--medium">
99+
<p style={{marginTop: '5rem'}}>
96100
<SLDSTooltip
97101
content={<span>Tooltip with right alignment</span>}
98102
align='right'
99-
openOnClick={true}
103+
openOn='click'
100104
targetElement={this.refs.tooltipOnClick}>
101105
Tooltip open on click
102106
</SLDSTooltip>

0 commit comments

Comments
 (0)