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-build

v0.0.2-0

Published

figma-build is a script that fetches your figma theme styles and outputs them in various formats

Downloads

3

Readme

Figma build project

  • This package fetches figma styles, parses them into front-end readable formats and outputs them into various formats css, css-variables, commonjs, json, etc.

Usage

Through npx

pnpx figma-build theme --accessToken <YOUR_FIGMA_ACCESS_TOKEN> --fileId <YOUR_FIGMA_FILE_ID> --outputFormat esm

Or yarn dlx

yarn dlx figma-build...

If no outputFormat specified the styles would be built as theme.json

As a global script

  • pnpm install figma-build -g
  • yarn global add figma-build

Arguments

"command"

The first ever argument you need to pass is what kind feature from figma you're looking for, currently we're only supporting theme, but components and images are in the workings.

Usage: figma-build theme

--acessToken

This if your figma's access token, you can obtain it when in browising file screen -> your profile -> settings -> account -> Personal access tokens.

The script will not work without it.

Usage: figma-build theme --accessToken <TOKEN>

--fileId

This is your figma's document id or rather file id. When you open your figma document you can find your file id in the url of that file

In this URL https://www.figma.com/file/P2oVdik0Q0pUoIxRIzaMjK/API_STUFF?t=Izh75bvDR8rlV1Yq-0 the file would be P2oVdik0Q0pUoIxRIzaMjK

Usage: figma-build theme --accessToken <TOKEN> --fileId <FILE_ID>

--outputFormat

Enum of [json | stdout | esm | commonjs | css | css-variables | sass | scss ]

Specify the format of the parsed figma theme:

  • stdout will write theme styles in json format to your console
  • json will write theme styles in json format to .json file
  • esm will write theme styles in json format to a .js file as an ecmascript module, so you could import those styles further.
  • commonjs will write theme styles in json format to a .js file as an commonjs module, so you could require those styles further, mostly used with node.
  • css will write theme styles in css format as each of the styles being its own classname.
  • css-variables will write theme styles in css format each of the styles being its own css variable

Usage: figma-build theme --accessToken <TOKEN> --fileId <FILE_ID> --outputFormat esm

--filename

Specify the output filename, by default its theme.json

--outputPath

Path to where file would be written in.

Contributing

  1. Obtain accessToken from your figma settings -> account.

  2. Set this accessToken as an argument in pnpm dev script inside package.json

    1. Make sure not to commit or expose your accessToken, for that you can create already git-ignored Makefile, and pass you secrets there:
    dev:
        pnpm dev --accessToken <YOUR_FIGMA_ACCESS_TOKEN> --fileId <YOUR_FIGMA_FILE_ID>
  3. Find out file from which you want to get those styles from

    • In this URL https://www.figma.com/file/P2oVdik0Q0pUoIxRIzaMjK/API_STUFF?t=Izh75bvDR8rlV1Yq-0 the file would be P2oVdik0Q0pUoIxRIzaMjK

Roadmap

  • Cover everything with tests
  • Finish theme parsing
  • Consider different style theme names (eg theme.name, theme/name, themeName)
  • Finish all other format outputs.
  • Rewrite esm and commonjs to a proper solution.
  • Consider outputting not only theme styles, but components as well