Some parts borrowed from this demo. In general don't expect anything here to reflect best or even decent practices. I have no idea what I'm doing.
To try it:
yarn install
yarn watch
And then open the manifest.json
file in Figma via Plugins > Development > Import plugin from manifest
.