UNPKG

@pixso/create-plugin

Version:

plugin template

38 lines (32 loc) 840 B
import { h } from "preact"; import { useState } from "preact/hooks"; const App = function () { const [count, setCount] = useState(5); const create = () => { parent.postMessage( { pluginMessage: { type: "create-rectangles", count: count } }, "*" ); }; const cancel = () => { parent.postMessage({ pluginMessage: { type: "cancel" } }, "*"); }; const onchange = (e) => { const target = e.target; if (!target) return; setCount(Number(target.value)); } return ( <div className="main-wrapper"> <h2>Rectangle Creator</h2> Count: <input value={count} onChange={onchange} /> <div className="operate"> <button onClick={create}> Create </button> <button onClick={cancel}>Cancel</button> </div> </div> ); }; export default App;