-
Notifications
You must be signed in to change notification settings - Fork 8
/
App.tsx
executable file
·49 lines (43 loc) · 1.21 KB
/
App.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
import * as React from "react";
import "../styles/figma.ds.css";
import "../styles/custom-ui.css";
declare function require(path: string): any;
const App = ({}) => {
const createTable = React.useCallback(() => {
parent.postMessage({ pluginMessage: { type: "create-table" } }, "*");
}, []);
const createPages = React.useCallback(() => {
parent.postMessage({ pluginMessage: { type: "create-pages" } }, "*");
}, []);
React.useEffect(() => {
// This is how we read messages sent from the plugin controller
window.onmessage = event => {
const { type, message } = event.data.pluginMessage;
if (type === "done") {
console.log(`Figma Says: ${message}`);
}
};
}, []);
return (
<div className="main">
<figure className="logo-wrapper">
<img src={require("../assets/logo.svg")} />
</figure>
<button
className="button button--secondary"
id="create"
onClick={createTable}
>
Create table of contents
</button>
<button
className="button button--secondary"
id="generate"
onClick={createPages}
>
Generate list of pages
</button>
</div>
);
};
export default App;