-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathapp.js
71 lines (61 loc) · 1.98 KB
/
app.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import { Tooltip, Origin, actions } from '../../src/index';
const SVGOrigin = Origin.wrapBy('g');
class App extends Component {
constructor(props) {
super(props);
this.handleMove = this.handleMove.bind(this);
this.handleLeave = this.handleLeave.bind(this);
}
handleMove(e) {
const origin = { x: e.clientX, y: e.clientY };
this.props.dispatch(actions.show({ origin, content: 'Moving Tooltip!' }));
}
handleLeave() {
this.props.dispatch(actions.hide());
}
render() {
return (
<div>
<h1>Origin Example</h1>
<h2>Custom Origin</h2>
<p>
<svg width="240" height="70">
<g transform="translate(40, 10)">
<SVGOrigin className="red" content="Red">
<rect fill="red" x="0" y="0" width="50" height="50" />
</SVGOrigin>
<SVGOrigin className="green" content="Green">
<circle fill="green" cx="85" cy="25" r="25" />
</SVGOrigin>
<g transform="translate(120, 0)">
<SVGOrigin className="blue" content="Blue">
<rect fill="blue" x="0" y="0" width="50" height="50" />
</SVGOrigin>
<g transform="translate(15, 15)">
<SVGOrigin className="inner" content="Inner">
<rect fill="lightblue" x="0" y="0" width="20" height="20" />
</SVGOrigin>
</g>
</g>
</g>
</svg>
</p>
<h2>Moving Tooltip</h2>
<div
className="moving"
style={{ width: '260px', height: '120px', backgroundColor: 'lightgray' }}
onMouseMove={this.handleMove}
onMouseLeave={this.handleLeave}
/>
<Tooltip />
</div>
);
}
}
function select(state) {
const { app } = state;
return { app };
}
export default connect(select)(App);