This file contains 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
/* Dropdown */ | |
class FigDropdown extends HTMLElement { | |
constructor() { | |
super() | |
this.type = "select" | |
} | |
connectedCallback() { | |
this.trigger = this.querySelector('[slot=trigger]') | |
if (this.trigger) { |
This file contains 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
async function buildSFSymbolIcons(){ | |
const sfSymbolNames = "square.and.arrow.up,square.and.arrow.up.fill,square.and.arrow.up.circle,square.and.arrow.up.circle.fill,square.and.arrow.up.badge.clock,square.and.arrow.up.badge.clock.fill,square.and.arrow.up.trianglebadge.exclamationmark,square.and.arrow.down,square.and.arrow.down.fill,square.and.arrow.up.on.square,square.and.arrow.up.on.square.fill,square.and.arrow.down.on.square,square.and.arrow.down.on.square.fill,rectangle.portrait.and.arrow.right,rectangle.portrait.and.arrow.right.fill,rectangle.portrait.and.arrow.forward,rectangle.portrait.and.arrow.forward.fill,pencil,pencil.circle,pencil.circle.fill,pencil.slash,pencil.line,eraser,eraser.fill,eraser.line.dashed,eraser.line.dashed.fill,square.and.pencil,square.and.pencil.circle,square.and.pencil.circle.fill,rectangle.and.pencil.and.ellipsis,scribble,scribble.variable,pencil.and.scribble,highlighter,pencil.and.outline,pencil.tip,pencil.tip.crop.circle,pencil.tip.crop.circle.fill,pencil.tip.crop.circle.ba |
This file contains 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
let errorCreatingVideo = false | |
let video, paint | |
// Figma's pro (and higher plans) allow for embedding videos. There is no native code for a Figma plugin to be able | |
// to test what plan a user is on. So, this code attempts to create the video. If it can't, then it will notify the user | |
// of the error (I would imagine this error also will fire if the video is too large). | |
try { | |
video = await figma.createVideoAsync(args.webm) | |
paint = { | |
videoHash: video.hash, |
This file contains 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
// SAVING some settings on a layer (code.ts/figma scene) | |
// Namespace | |
const dataNamespace = 'stipple-settings' | |
// get a node | |
let layer = figma.currentPage.selection[0] | |
// options to save in json format | |
let options = { |
This file contains 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
// creating the client | |
// https://supabase.com/docs/reference/javascript/initializing | |
import { createClient } from '@supabase/supabase-js'; | |
import clientStorage from './FigmaClientStorage'; | |
const supabase = createClient( | |
<URL>, | |
<PUBLIC_ANON_KEY>, | |
{ |
This file contains 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
let nodesToSelect = [] | |
figma.currentPage.selection.forEach(node => { | |
// Change "Icon Right" to the node name you want to select | |
node.findAll(node => node.name == "Icon Right").forEach(node => nodesToSelect.push(node)) | |
}) | |
figma.currentPage.selection = nodesToSelect |
This file contains 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
/* code.ts (scene) */ | |
node.exportAsync({ | |
format: "PNG", | |
constraint: { | |
type: "WIDTH", | |
value: 1000 | |
} | |
}).then(imageData => { | |
// Send the image data to the plugin window |
This file contains 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
async function insertAllComponentsFromFile(){ | |
// Uses the Web api..more here https://www.figma.com/developers/api#files-endpoints | |
// Ideally, you don't hit this api every time the plugin runs, but maybe use figma.clientStorage | |
// to store the keys for a set amount of time, then refresh on expiration | |
let result = await fetch('https://api.figma.com/v1/files/08U6xAT28gUfHkx2l2kUhc', { | |
method: 'GET', | |
headers: { | |
'X-Figma-Token': '236259-788a3c64-e9b2-4ca2-851b-193954b2ad6d' |