figma-export icon indicating copy to clipboard operation
figma-export copied to clipboard

Add support for exporting colors from variables definitions in a JSON

Open aduuub opened this issue 1 year ago • 5 comments

Our design team uses variables (which has been described as the new way of doing things- see the screenshot). It's a way of structuring your colours to use with a variable name with a "light" and "dark" scheme.

It would be great to be able to use this tool with them instead of Figma styles and although it's new, it's the way Figma is apparently going in and to me makes more sense having a single colour e.g. BackgroundDefault instead of BackgroundDefault_light

image

The API for this is still in beta and is for enterprise customers only. In the short-term, you can use a Figma plugin Variables to JSON to download the variables as JSON and specify a path to the file in the config. Each variable should have a "light" state, but can also include "dark", "lightHC", "darkHC" too.

If you want to provide the JSON yourself, the variables should be in the following format. It supports reading from hex and rgba along with traversing through the folder structures.

{
    "app-tokens": {
        "light": {
            "background-default": {
                "value": "rgba(255, 255, 255, 1)"
            },
            "background-secondary": {
                "value": "#e7134b"
            }
        },
        "dark": {
            "background-default": {
                "value": "rgba(255, 255, 255, 1)"
            },
            "background-secondary": {
                "value": "#e7134b"
            }
        }
    }
}

To use this should specify the following properties in the colors common config

useVariablesFromFileInstead: true variableFilePath: 'path-to-styles.json' variableGroupName: 'app-tokens-or-token-group-name'

aduuub avatar Dec 21 '23 00:12 aduuub

It might be worth adding API support as well?

alexey1312 avatar Feb 01 '24 04:02 alexey1312

radicool!

markst avatar Mar 21 '24 04:03 markst

Any plans to merge this PR?

AllDmeat avatar Apr 22 '24 09:04 AllDmeat

Any plans to merge this PR?

FigmaExport already supports exporting colors from variables. See https://github.com/RedMadRobot/figma-export/pull/236

Do you want to import variables from JSON file?

subdan avatar Apr 22 '24 16:04 subdan

FigmaExport already supports exporting colors from variables. See https://github.com/RedMadRobot/figma-export/pull/236

Great, missed that one. thx

AllDmeat avatar Apr 23 '24 06:04 AllDmeat