-
Notifications
You must be signed in to change notification settings - Fork 349
Expand file tree
/
Copy pathui.tsx
More file actions
36 lines (29 loc) · 920 Bytes
/
ui.tsx
File metadata and controls
36 lines (29 loc) · 920 Bytes
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
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import './ui.css'
import Logo from './logo.svg'
declare function require(path: string): any
const App = () => {
let textbox: HTMLInputElement;
const countRef = (element: HTMLInputElement) => {
if (element) element.value = '5'
textbox = element
}
const onCreate = () => {
const count = parseInt(textbox.value, 10)
parent.postMessage({ pluginMessage: { type: 'create-rectangles', count } }, '*')
}
const onCancel = () => {
parent.postMessage({ pluginMessage: { type: 'cancel' } }, '*')
}
render() {
return <div>
<img src={Logo} />
<h2>Rectangle Creator</h2>
<p>Count: <input ref={countRef} /></p>
<button id="create" onClick={onCreate}>Create</button>
<button onClick={onCancel}>Cancel</button>
</div>
}
}
ReactDOM.render(<App />, document.getElementById('react-page'))