forked from runtastic/react-hexagon-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.js
50 lines (45 loc) · 997 Bytes
/
demo.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
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import HexagonGrid from '../src/HexagonGrid';
import times from 'lodash/times';
class HexGridDemo extends Component {
getHexProps(hexagon) {
return {
style: {
fill: '#007aff',
stroke: 'white'
},
onClick: () => alert(`Hexagon n.${hexagon} has been clicked`)
};
}
renderHexagonContent(hexagon) {
return (
<text
x="50%"
y="50%"
fontSize={100}
fontWeight="lighter"
style={{ fill: 'white' }}
textAnchor="middle"
>
{hexagon}
</text>
);
}
render () {
let hexagons = times(102, id => id);
return (
<HexagonGrid
gridWidth={500}
gridHeight={500}
hexagons={hexagons}
hexProps={this.getHexProps}
renderHexagonContent={this.renderHexagonContent}
/>
);
}
}
ReactDOM.render(
<HexGridDemo />,
document.getElementById('root')
);