Giter VIP home page Giter VIP logo

figma-api-exporter's Introduction

Figma API Exporter

Allows you to export assets from Figma files automatically and use it in your project.

Features:

  • download all components as SVGs from Figma file or Frame

Examples

const figmaApiExporter = require('figma-api-exporter').default;

const exporter = figmaApiExporter(YOUR_FIGMA_API_TOKEN);

exporter
  .getSvgs({
    fileId: YOUR_FIGMA_FILE_ID,
    canvas: 'Icons',
  })
  .then(svgsData =>
    exporter.downloadSvgs({
      saveDirectory: './svgsFiles',
      svgsData: svgsData.svgs,
      lastModified: svgsData.lastModified,
    })
  );

API

getSvgs

Function which fetches urls of component exports as svgs.

Arguments:

  • fileId (required) (string) - id of figma files you want to extract svgs from
  • canvas (optional) (string|function) - filter exported components by Page name, you can use a custom filter function with additional information about page
  • component (optional) (string|function) - filter by exported components by Component name, you can use a custom filter function with additional information about component

downloadSvgs

Function which downloads svg files to your directory. It checks Figma File modification date and component ids to find out if your local copy is up to date before downloading everything. You can replace this function with your own script.

Arguments:

  • saveDirectory (required) (string) - path to save svg files
  • svgsData (required) (array) - '.svgs' values returned from .getSvgs()
  • lastModified (required) (string) - .lastModified value returned from .getSvgs(), used to check if Figma file was modified and it should continue downloading
  • clearDirectory (optional) (boolean) (defaults to: false) - change to true if you want to clear the saveDirectory before downloading files, it comes handy when you want to delete old icons, which don't exist in Figma anymore

figma-api-exporter's People

Contributors

fallaciousreasoning avatar slawomirkolodziej avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.