![Screenshot 2023-11-17 at 2 38 14 PM](https://private-user-images.githubusercontent.com/110813/283916644-885bc2a1-cd34-41c7-b36b-ed1d5783e453.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM2NTYzOTYsIm5iZiI6MTcyMzY1NjA5NiwicGF0aCI6Ii8xMTA4MTMvMjgzOTE2NjQ0LTg4NWJjMmExLWNkMzQtNDFjNy1iMzZiLWVkMWQ1NzgzZTQ1My5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODE0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxNFQxNzIxMzZaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03YWFjNTI3ZjMzNmM4MGQ2ZDhlYjE5NDdiYWMyMzM2NTcxYjU4MmMyNzlmNDI1MDU2ZTM3MDI1Y2IzZWRmOTQ3JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.k6mTgVjCa_fj_70dSnv1Nw3O9Ra-8E07CkE7BU3Irds)
Draw and sketch UI in Figma and FigJam with this widget. Inspired by SawyerHood/draw-a-ui and tldraw/draw-a-ui.
Make sure to replace OPENAI_API_KEY
with your API key.
Below are the steps to get your widget running. You can also find instructions at:
https://www.figma.com/widget-docs/setup-guide/
This widget template uses TypeScript and NPM, two standard tools in creating JavaScript applications.
First, download Node.js which comes with NPM. This will allow you to install TypeScript and other libraries. You can find the download link here:
https://nodejs.org/en/download/
Next, install TypeScript, esbuild and the latest type definitions by running:
npm install
If you are familiar with JavaScript, TypeScript will look very familiar. In fact, valid JavaScript code is already valid Typescript code.
TypeScript adds type annotations to variables. This allows code editors such as Visual Studio Code to provide information about the Figma API while you are writing code, as well as help catch bugs you previously didn't notice.
For more information, visit https://www.typescriptlang.org/
Using TypeScript requires a compiler to convert TypeScript (widget-src/code.tsx) into JavaScript (dist/code.js) for the browser to run. We use esbuild to do this for us.
We recommend writing TypeScript code using Visual Studio code:
- Download Visual Studio Code if you haven't already: https://code.visualstudio.com/.
- Open this directory in Visual Studio Code.
- Compile TypeScript to JavaScript: Run the "Terminal > Run Build Task..." menu item, then select "npm: watch". You will have to do this again every time you reopen Visual Studio Code.
That's it! Visual Studio Code will regenerate the JavaScript file every time you save.