Skip to content

Instantly share code, notes, and snippets.

@colinfwren
Created February 11, 2022 23:15
Show Gist options
  • Save colinfwren/182d876c58b9c733dc4e99905dce8c15 to your computer and use it in GitHub Desktop.
Save colinfwren/182d876c58b9c733dc4e99905dce8c15 to your computer and use it in GitHub Desktop.
Basic Handler Example for Figma Plugin
// 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