npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

figma-assets-exporter

v1.2.2

Published

Create figma assets like icons, svg, images just by providing a fileId and the node where your components live.

Downloads

8

Readme

Figma Assets Exporter

This is a fork of figma-assets-generator. There were bugs that needed fixing urgently, so I released under a new name. Meanwhile, this fork has evolved further and new features were introduced.

Creates assets (SVG, JPG, PNG) from a figma document (e.g. a "Icons" page in one of your files) and places them locally in a folder.

Usage

Ideal use: create a script in your package.json and run the script whenever you need, however you could also run this programmatically.

Installation

npm install --save-dev figma-assets-exporter

or

yarn add -D figma-assets-exporter

Use as npm script

Provide a figma-assets-exporter.json file with the following configuration:

{
  "personalAccessToken": "YOUR_ACCESS_TOKEN",  // required: your figma access token (you can provide this as FIGMA_TOKEN in a .env file)
  "fileId": "YOUR_FILE_IDE", // required: file id where your icons document is stored
  "documentId": "123:456", // required: node of your icons document, e.g. "453:8089"
  "fileExtension": "svg", // optional: ["svg", "jpg", "png", "pdf"], default: svg
  "output": "assets/icons/svg" // optional: folder (relative path from working directory) where icons will be saved to, defaults to "assets",
  "scale": "1" // optional, values between 0.05 and 4 are possible, default: 1
  "createSubdirectories": false // optional: if true, a Figma component name "Icons/Actions/ChevronLeft" would result in a folder structure. Else slashes will be replaced with underscores.
}

Run

npx figma-assets-exporter

on the command line, or via node_modules/.bin/figma_assets_exporter

or create a new entry in package.json under scripts:

"figma-generate": "figma-assets-exporter"

Use within your *.js files

Include figma-assets-exporter in your project, provide required options and call getFigmaAssets(options) whenever you want to pull and create icons.

const { getFigmaAssets } = require("figma-assets-exporter")

const options = {
  personalAccessToken: "5316-049f89713-0134-46b5-b426-22d1251cbc6",  // required: your figma access token (you can provide this as FIGMA_TOKEN in a .env file)
  fileId: "gAMN5xYfhC2BTVKnht3PAk43", // required: file id where your icons document is stored
  documentId: "453:8089", // required: node of your icons document, e.g. "453:8089"
  fileExtension: "svg", // optional: ["svg", "jpg", "png"], default: svg
  output: "assets" // optional: folder where icons will be saved to, defaults to "icons" (cannot have subdirectories, see #17)
  createSubdirectories: false // optional: if true, a Figma component name "Icons/Actions/ChevronLeft" would result in a folder structure. Else slashes will be replaced with underscores. Defaults to false.
}

getFigmaAssets(options)

How do I get fileId and documentId ?

To get the fileId you need to open the document in your browser, the fileId is indicated in the address bar:

https://www.figma.com/file/KiFw6W2QjnKqhA4hoWsrhQ/Untitled?node-id=0%3A123

The part after /file/ would be the fileId (in this example KiFw6W2QjnKqhA4hoWsrhQ) and the documentId would be the part after node-id= (in this example 0%3A123 - however %3A is just HTML Encoding for : so the document id would be 0:123

Caveats

Replaces / and . in component names with _ unless createSubdirectories is set to true (in that case it creates the actual folder structure in the target folder).