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
import React, { useState } from 'react';
import type { NextPage } from 'next';
import { Page, Container, Canvas } from 'components/content';
import {
View,
Layer,
Rectangle as Rect,
Circle as Circ,
} from 'react-paper-bindings';
type RectangleProps = {
center: [number, number];
size: [number, number];
};
const Rectangle = (props: RectangleProps) => {
const [hovered, set] = useState(false);
return (
<Rect
{...props}
fillColor={hovered ? 'green' : 'red'}
onClick={() => alert('Clicked on Rectangle')}
onMouseEnter={() => set(true)}
onMouseLeave={() => set(false)}
/>
);
};
type CircleProps = {
center: [number, number];
radius: number;
};
const Circle = (props: CircleProps) => {
const [hovered, set] = useState(false);
return (
<Circ
{...props}
fillColor={hovered ? 'orange' : 'blue'}
onClick={() => alert('Clicked on Circle')}
onMouseEnter={() => set(true)}
onMouseLeave={() => set(false)}
/>
);
};
const EventsPage: NextPage = () => {
return (
<Page title="Events">
<Container>
<Canvas>
<View>
<Layer>
<Rectangle center={[75, 75]} size={[100, 100]} />
<Circle center={[225, 120]} radius={50} />
</Layer>
</View>
</Canvas>
</Container>
</Page>
);
};
export default EventsPage;