Created
February 11, 2022 23:15
-
-
Save colinfwren/182d876c58b9c733dc4e99905dce8c15 to your computer and use it in GitHub Desktop.
Basic Handler Example for Figma Plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main.js | |
import {on, showUI} from '@create-figma-plugin/utilities' | |
export default function () { | |
on('HIDE_ALL', (args) => { | |
const allNodes = figma.currentPage.children.slice() | |
allNodes.map((node) => { | |
node.visible = false | |
}) | |
figma.closePlugin() | |
} | |
showUI() | |
} | |
// ui.jsx | |
import {Container, render} from '@create-figna-plugin/ui' | |
import {emit} from '@create-figma-plugin/utilities' | |
import {h} from 'preact' | |
function Plugin() { | |
function handleClick() { | |
emit('HIDE_ALL') | |
} | |
return ( | |
<Container> | |
<button onClick={handleClick}>Hide all content</button> | |
</Container> | |
) | |
} | |
export default render(Plugin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment