Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for exporting colors from variables definitions in a JSON #228

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aduuub
Copy link

@aduuub aduuub commented Dec 21, 2023

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'

@alexey1312
Copy link
Contributor

It might be worth adding API support as well?

@markst
Copy link

markst commented Mar 21, 2024

radicool!

@AllDmeat
Copy link
Contributor

Any plans to merge this PR?

@subdan
Copy link
Collaborator

subdan commented Apr 22, 2024

Any plans to merge this PR?

FigmaExport already supports exporting colors from variables. See #236

Do you want to import variables from JSON file?

@AllDmeat
Copy link
Contributor

FigmaExport already supports exporting colors from variables. See #236

Great, missed that one. thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants