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-icon-getter

v0.0.2

Published

A simple solution to get component set icons from Figma

Downloads

4

Readme

Figma Icon Getter

This is a CLI and TypeScript library to fetch icons from Figma using their REST API.

Benefits

  • Automate icon workflow from Figma to production.
  • Sync repository with a single Figma file.
  • Use component sets in Figma, making it easier for designers to configure options.

Design Setup

  1. Create a new Figma file and notate the file ID.

icons-01

  1. Create a new icons. Make sure to flatten the paths to a single layer.

icons-02

  1. Create a component set.

icons-03

  1. Add properties to the component, e.g. variant = filled | outlined and size = 16 | 24

icons-04

  1. Generate a personal access token.

[!NOTE] Make sure that the token has access to your icon file

icons-05

CLI usage

[!NOTE] Requires a recent version of Node.js.

Run the following command to download icons from Figma:

FIGMA_PAT=<access token> npx figma-icon-getter --file <file key> --out <output directory>

Explanation:

  • FIGMA_PAT=<access token>: Replace <access token> with the Figma personal access token generated in the Design Setup section above.
  • --file <file key>: Replace <file key> with the file key appearing in the URL of the Figma file. For example, given a URL of https://www.figma.com/design/mfiglkk3bXQwetaRsftZQz/Icon-Playground?node-id=0-1&t=RDa9Ma6rkxW492eB-0, the file key is mfiglkk3bXQwetaRsftZQz.
  • --out <output directory>: Replace <output directory> with the path to the directory where you want to download the icon SVG files.

[!TIP] If you need to convert the downloaded icon SVG files to React icon components, we recommend SVGR.

API

Installation

npm install figma-icon-getter

Usage

You can use the getFigmaIcons function to conveniently download icon SVGs:

import { getFigmaIcons } from "figma-icon-getter";

const icons = await getFigmaIcons({
  figmaAccessToken: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  fileKey: "mfiglkk3bXQwetaRsftZQz",
});

console.log(icons);

/* example output
[
  {
    "name": "Acorn",
    "properties": {
      "variant": "outlined",
      "size": "16"
    },
    "svg": "<svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\">...</svg>\n"
  }
]
*/

Parameters

  • figmaAccessToken: The Figma personal access token generated in the Design Setup section above
  • fileKey: The file key appearing in the URL of the Figma file. For example, given a URL of https://www.figma.com/design/mfiglkk3bXQwetaRsftZQz/Icon-Playground?node-id=0-1&t=RDa9Ma6rkxW492eB-0, the file key is mfiglkk3bXQwetaRsftZQz.

Return value

Promise<
  {
    name: string;
    properties: Record<string, string>;
    svg: string;
  }[]
>;
  • name: The name of the icon, derived from the component set that the icon component belongs to
  • properties: A record containing the component properties defined in Figma
  • svg: The icon SVG data

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss any changes.