-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tsx
93 lines (87 loc) · 3.07 KB
/
main.tsx
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import React from 'react';
import ReactDOM from 'react-dom';
import { VisorSelect } from '..';
import ScanVisor from '../ScanVisor';
import './demo.css';
const $body = document.querySelector('body');
type State = {
visor: 'select' | 'scan';
};
const consoleLog = () => {
console.log('clicked');
};
class App extends React.Component<{}, State> {
state: State = { visor: 'scan' };
radarRef: React.RefObject<HTMLImageElement>;
mapRef: React.RefObject<HTMLImageElement>;
constructor(props: {}) {
super(props);
this.radarRef = React.createRef();
this.mapRef = React.createRef();
}
render() {
if (this.state.visor === 'select') {
return (
<VisorSelect
top={{
text: 'my page',
href: 'https://pelmers.com/',
}}
left={{
text: 'scan visor',
onClick: () => this.setState({ visor: 'scan' as const }),
}}
right={{ text: 'is??', onClick: consoleLog }}
radar={{
component: (
<img
className="masked-image"
ref={this.radarRef}
src="favicon.ico"
></img>
),
getRef: () => this.radarRef,
}}
map={{
component: (
<img
className="masked-image"
ref={this.mapRef}
src="favicon.ico"
></img>
),
getRef: () => this.mapRef,
}}
/>
);
} else if (this.state.visor === 'scan') {
return (
<ScanVisor
centerPanel={
<div>
<div
onClick={() => this.setState({ visor: 'select' })}
style={{ cursor: 'pointer' }}
>
back to select
</div>
</div>
}
rightPanel={<div>right text</div>}
leftPanel={<div>left text</div>}
descriptionPanel={
<div className="scan-description-content">
description title
<div style={{ paddingTop: '1em', fontSize: '22px' }}>
this would be a sentence about the content.
</div>
<button>action button</button>
</div>
}
energyValue="99"
/>
);
}
}
}
ReactDOM.render(<App />, $body);