GithubHelp home page GithubHelp logo

jxnblk / figma-theme Goto Github PK

View Code? Open in Web Editor NEW
136.0 4.0 26.0 12 KB

Generate development-ready theme JSON files from Figma Styles

JavaScript 100.00%
figma figma-api figma-js theme styles styled-system css-in-js design-systems tokens

figma-theme's Introduction

figma-theme

Generate development-ready theme JSON files from Figma Styles

npm i figma-theme

Getting Started

  1. Install figma-theme as a dev dependency in your project
  2. Get a personal access token for the Figma API
  3. Create a .env file with your access token
  • FIGMA_TOKEN=<personal-access-token>
  • Alternatively add an environment variable for FIGMA_TOKEN
  1. Add an npm run script: figma-theme <figma-file-id>
  2. Run the script to create a theme.json file based on Figma Styles

Options

Options can be passed as CLI flags or included in a figma-theme object in your package.json

  • --out-dir: output directory (default current working directory)
  • --metadata: include additional metadata from the Figma API

figma-theme's People

Contributors

jxnblk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

figma-theme's Issues

Doesn't extract styles from Figma Components

This is based on my very limited testing…

Take this file in Figma, just a box with the Style 'Red' applied:
screenshot 2018-07-09 17 04 52

The script output is like so:

{
  "colors": {
    "Red": "#eb5757"
  },
  "textStyles": {},
  "fonts": [],
  "fontSizes": [],
  "fontWeights": [],
  "lineHeights": []
}

However, if you convert it to a Figma Component:
screenshot 2018-07-09 17 05 55

And re-run the script, the style disappears:

{
  "colors": {},
  "textStyles": {},
  "fonts": [],
  "fontSizes": [],
  "fontWeights": [],
  "lineHeights": []
}

cant create output

Awesome work!

seems that its not aligned to latest schema
its failing when i run it, here is the stack trace

TypeError: Cannot read property 'value' of undefined
at textStyles.map.map.style (index.js:103:17)
at Array.map ()
at module.exports (index.js:97:6)
at figma.file.then.res (cli.js:91:33)
at
at process._tickCallback (internal/process/next_tick.js:188:7)
TypeError: Cannot read property 'status' of undefined
at figma.file.then.catch.err (cli.js:107:24)
at
at process._tickCallback (internal/process/next_tick.js:188:7)

cant get line height values in pixels

Hi

I'm using your code in order to get the theme from figma.
i have noticed that the output json styles for line height extract it in percentage which is not convertable to pixels

can you adapt your code to extract the styles for line heights in pixels ?
(opened PR)
Thanks
Ori

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.