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

How to turn off the global? #33

Open
AndySobol opened this issue Dec 28, 2022 · 1 comment
Open

How to turn off the global? #33

AndySobol opened this issue Dec 28, 2022 · 1 comment

Comments

@AndySobol
Copy link

AndySobol commented Dec 28, 2022

Hi!
I have a problem, it used to work properly. Updated package configuration to 4 versions and in vain. These files are automtaically assigned to the global group that prevents me from working. There is no time to convert json files. So that’s how to turn off this automatic function of inserting the global group?

UPD: Solved the issue of setting in config file) Excuse me

@jorenbroekema
Copy link
Contributor

jorenbroekema commented Dec 28, 2022

When this repo was made, tokens studio (formerly figma tokens plugin) was creating something called "tokensets", not entirely sure if they still use this but basically the topmost "key" of the tokens object would be the tokenset name, so for example take these two files in style-dictionary tokens:

core-colors.json:

{
  "core": {
    "color": {
      "grey": {
        "50": {
          "value": "#000000",
          "type": "color",
        },
        "100": {
          "value": "#222222",
          "type": "color",
        }
      }
    }
  }
}

semantic-colors.json:

{
  "color": {
    "primary": {
      "base": {
        "type": "color",
        "value": "{core.color.grey.50}"
      }
    }
  }
}

These two would be converted to:

figma-tokens.json:

{
  "global": {
    "core": {
      "color": {
        "grey": {
          "50": {
            "value": "#000000",
            "type": "color",
          },
          "100": {
            "value": "#222222",
            "type": "color",
          }
        }
      }
    },
    "color": {
      "primary": {
        "base": {
          "type": "color",
          "value": "{core.color.grey.50}"
        }
      }
    }
  }
}

So both the color primary semantic tokens and the core color palette will get combined into 1 object, with a "global" parent key, which is the name of the "tokenset" in the plugin. I have to insert this "global" key by default, otherwise by default your conversion would not result in a working JSON for the figma plugin, because it would think that there are two "tokensets": color and core, and the reference core.color.grey.50 would then no longer work.

You can however customize the tokenset names, explained in the readme under Features, first one in the list.

Hopefully this makes sense :)

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

No branches or pull requests

2 participants