├── .gitattributes
├── .gitignore
├── README.md
├── dist
├── code.js
├── index.html
└── manifest.json
├── gulpfile.js
├── package-lock.json
├── package.json
├── src
├── main
│ └── code.ts
├── manifest.json
└── ui
│ ├── index.html
│ ├── scripts
│ ├── helper-functions.js
│ └── scripts.js
│ └── styles
│ └── styles.scss
├── static
└── plugin-experiment-docs.gif
└── tsconfig.json
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | .DS_Store
3 | package-lock.json
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # External Docs - Figma Plugin Experiment
2 |
3 |
4 | A plugin experiment to show related external documentation for a selected component/instance.
5 |
6 | ## How it works
7 | The plugin reads the component description of the currently selected component and searches for the term `@api` (this could be anything). If there's a match, it uses the component name to serve the corresponding page of the documentation (by simple URL matching).
8 |
9 | I've used Github Primer and the Primer docs as an example as this requires cross-origin requests and not a lot of public styleguides have this enabled :)
10 |
11 | ## Thoughts
12 | This is a very simple approach to a very powerful concept. A lot of design systems and/or dev teams have existing docs that would be valuable to reference while designing - why not pull them straight in!
13 |
14 | There's a lot of fragility and room for human error by matching text strings and I could imagine a much more robust approach with:
15 | - uuid references instead of text
16 | - actual API request for urls
17 | - two-way data to populate the Figma canvas with useful info from the docs
18 | - local and external docs
19 |
20 | ## Next steps
21 | I don't have any further plans for this experiment - but perhaps it will be useful for someone else!
22 |
23 | ## Thanks
24 | - [@thomas-lowry](https://github.com/thomas-lowry) and the invaluable [Figma Plugin Boilerplate (FPB)](https://github.com/thomas-lowry/figma-plugin-boilerplate#intro)
25 | - The [Primer](https://github.com/primer) team for their amazing [styleguide](https://primer.style/) and their [Primer Web Figma Community File](https://www.figma.com/community/file/854767373644076713)
26 |
--------------------------------------------------------------------------------
/dist/code.js:
--------------------------------------------------------------------------------
1 | // This plugin will open a modal to prompt the user to enter a number, and
2 | // it will then create that many of the chose shape on screen
3 | // This shows the HTML page in "index.html".
4 | figma.showUI(__html__, { width: 400, height: 700 });
5 | const node = figma.currentPage.selection[0];
6 | sendDescription(node);
7 | function sendDescription(nodeSelected) {
8 | if (nodeSelected.masterComponent) {
9 | figma.ui.postMessage(nodeSelected.masterComponent.description);
10 | }
11 | else {
12 | figma.ui.postMessage(nodeSelected.description);
13 | }
14 | }
15 | figma.on("selectionchange", () => {
16 | sendDescription(figma.currentPage.selection[0]);
17 | });
18 |
--------------------------------------------------------------------------------
/dist/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |