How to use figma-api - 1 common examples

To help you get started, we’ve selected a few figma-api examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bufferapp / ui / scripts / generateIconComponents.js View on Github external
const indentString = require('indent-string');

const writeFileAsync = promisify(fs.writeFile);

const iconCachePath = path.join(__dirname, '../config/cachedIconData.json');
const pathToIconComponents = path.join(__dirname, '../src/components/Icon');
const pathToIconExamples = path.join(__dirname, '../src/documentation/examples/Icon');

const figmaIconFileId = 'D9T6BuWxbTVKhlDU8faZSQ9G';
const figmaIconFileUrl = `https://www.figma.com/file/${figmaIconFileId}/`;

const iconsToIgnore = [
  'icon-grid', // ignore this since it's just the grid background for the icons file
];

const figma = new Figma.Api({
  personalAccessToken: process.env.FIGMA_ACCESS_TOKEN,
});

function saveIconCache(lastModified, icons) {
  const data = {
    lastModified,
    icons,
  };
  fs.writeFileSync(iconCachePath, JSON.stringify(data, null, 2));
}

function getIconCache() {
  try {
    const cacheFile = fs.readFileSync(iconCachePath).toString();
    return JSON.parse(cacheFile);
  } catch (error) {

figma-api

Figma js typed api

MIT
Latest version published 1 year ago

Package Health Score

48 / 100
Full package analysis

Popular figma-api functions