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

gatsby-source-figma

v1.1.2

Published

Gatsby plugin for using Figma files as a data source.

Downloads

26

Readme

gatsby-source-figma

PRs Welcome npm

Gatsby plugin for using Figma documents as a data source.

Screenshot

Installation

yarn add gatsby-source-figma

Usage

// In your gatsby-config.js

plugins: [
  {
    resolve: `gatsby-source-figma`,
    options: {
      // For files:
      fileId: `FIGMA_FILE_ID`,
      // For images:
      nodeIds: [`FIGMA_NODE_IDS`],
      // optional for nodeIds: A number between 0.01 and 4, the image scaling factor
      scale: 1,
      // optional: A string enum for the image output format, can be jpg, png, svg, or pdf
      format: 'png'
      // For projects:
      projectId: `FIGMA_PROJECT_ID`,
      // Get an access token from Figma Account Settings.
      accessToken: `YOUR_FIGMA_ACCESS_TOKEN`,
    },
  },
],

For all requests, you must have an accessToken. You can create an access token inside your Figma settings.

To access a file, also pass a fileId.

To get screenshots, also pass in a fileId, nodeIds. Additionally, you can pass in scale (number) and/or format (png, jpg, svg, pdf), but they're not required.

To get a project, pass in a projectId.

Querying

Files

Make sure that fileId and accessToken are set inside gatsby-config.js.

query StyleguideQuery {
  figmaDocument {
    name
    lastModified
    thumbnailUrl
    pages {
      name
      children {
        name
      }
    }
  }
}

Images (Artboards, also known as nodes)

Make sure that fileId, nodeIds, and accessToken are set inside gatsby-config.js. You can also set scale and format.

The node Id and file key can be parsed from any Figma node url: (https://www.figma.com/file/:key/:title?node-id=:id).

query ImageQuery {
  allFigmaImage {
    nodes {
      id
      image
    }
  }
}

Projects

Make sure that projectId and accessToken are set inside gatsby-config.js. Using this method, you can now query components, frames, instances, and more via graphql filters.

// All Figma Documents

query ProjectQuery {
  allFigmaDocument {
    edges {
      node {
        name
        pages {
          name
        }
      }
    }
  }
}
// Specific Figma Component

query ProjectComponentQuery {
  figmaComponent(name: {eq: "MyComponent"}) {
    instances {
      name
      rectangles {
        name
      }
      texts {
        name
      }
    }
  }
}
// Figma Frames that start with "Button"

query ProjectFrameQuery {
  allFigmaFrame(filter: {name: {regex: "/Button/"}}) {
    edges {
      node {
        name
      }
    }
  }
}

Use the built-in GraphiQL tool (http://localhost:8000/___graphql) to get an idea of what you can query.

Todo

  • [x] Query files.
  • [ ] Query multiple files.
  • [x] Query one or multiple file images.
  • [x] Query projects.
  • [ ] Query file comments.

Authors