/
Overlay.js
56 lines (48 loc) · 1.35 KB
/
Overlay.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class Example extends React.Component {
constructor(props, context) {
super(props, context);
this.getTarget = this.getTarget.bind(this);
this.handleToggle = this.handleToggle.bind(this);
this.state = {
show: true,
};
}
getTarget() {
return ReactDOM.findDOMNode(this.target);
}
handleToggle() {
this.setState((s) => ({ show: !s.show }));
}
render() {
const sharedProps = {
container: this,
target: this.getTarget,
show: this.state.show,
};
return (
<div style={{ height: 100, paddingLeft: 150, position: 'relative' }}>
<Button
ref={(button) => {
this.target = button;
}}
onClick={this.handleToggle}
>
Click me!
</Button>
<Overlay {...sharedProps} placement="left">
<Tooltip id="overload-left">Tooltip overload!</Tooltip>
</Overlay>
<Overlay {...sharedProps} placement="top">
<Tooltip id="overload-top">Tooltip overload!</Tooltip>
</Overlay>
<Overlay {...sharedProps} placement="right">
<Tooltip id="overload-right">Tooltip overload!</Tooltip>
</Overlay>
<Overlay {...sharedProps} placement="bottom">
<Tooltip id="overload-bottom">Tooltip overload!</Tooltip>
</Overlay>
</div>
);
}
}
render(<Example />);