GithubHelp home page GithubHelp logo

javierarce / figma-extractor Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 0.0 98 KB

Export all the frames of a Figma file

License: MIT License

JavaScript 100.00%
figma export figma-api figma-export node-module npm-package node

figma-extractor's Introduction

figma-extractor

Node package that exports all the frames of a Figma file to different files.

Installation

yarn add figma-extractor

or

npm install figma-extractor

How to use it

const Extractor = require('figma-extractor')

let extractor = new Extractor(FIGMA_TOKEN, FIGMA_FILE)

extractor.extract().then((files) => {
  console.log(files) 
}).catch((e) => {
  console.error(e)
})

Result

By default Figma Extractor will export SVG files to the current directory. The extract command will return the list of exported files in this format:

[
  { "filename": "Frame 1.svg", "page_id": "4:3", "page":"Page 1" },
  { "filename": "Frame 2.svg", "page_id": "4:3", "page":"Page 1" }, 
  { "filename": "Frame 3.svg", "page_id": "4:3", "page":"Page 1" }, 
  { "filename": "Frame 4.svg", "page_id": "8:4", "page":"Page 2" }
]

Customizing the export

const Extractor = require('figma-extractor')

let options = { 
  format: 'svg',                // file type (from the Figma API)
  svg_include_id: true,         // from the Figma API
  pageID: '123:0',              // specify a page
  append_frame_id: true,        // appends the frame id to the filename
  append_page_name: true,       // appends the page name to the filename
  use_pages_as_folders: true,   // create subdirectories with the name of the page
  dont_overwrite: true,         // don't overwrite existing files with the same name
  get_background_color: false,  // get the background color of the page in hexidecimal format
  get_comments: true            // get unresolved comments
}

const extractor = new Extractor(FIGMA_TOKEN, FIGMA_FILE, OPTIONS)

extractor.extract(IMAGE_PATH).then((files) => {
  console.log(files)
})

let destination = 'my_beautiful_designs'

let extractor = new Extractor(FIGMA_TOKEN, FIGMA_FILE, options)

extractor.extract(destination).then((files) => {
  console.log(files) 
}).catch((e) => {
  console.error(e)
})

figma-extractor's People

Contributors

javierarce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

figma-extractor's Issues

Combined designs are saved as one

Hi,
First of all, great package, keep up with the great work. ๐Ÿ‘

I tried to export multiple designs from Figma file, but I noticed that some elements are saved as one, even though sometimes I want to separate them. The root cause is that some elements are created within the same frame.

Is there a way to download each element from the selected frame separately?

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.