tokens-bruecke / figma-plugin

TokensBrücke is a Figma plugin that converts Figma variables into design-tokens JSON.
MIT License
46 stars 8 forks source link

Feature suggestion: Option to omit collection names as top-level groups #21

Open james-nash opened 7 months ago

james-nash commented 7 months ago

I see that Tokens Brücke wraps tokens in top-level groups based on the Figma variable collection name or type of style (e.g. "Typography").

In my case, I don't need those top-level names so an option to omit them and just place tokens from all collections into a single top-level group would be useful. References would of course need to be updated accordingly too.

I guess there may be cases where there's a clash - e.g. multiple variable collections contain variables with the exact same path. Perhaps Tokens Brücke just keep the last one it encounters and display a warning to let users know there was a clash. Or it could be treated as an error. I don't really have a strong preference either way.

dev-nicolaos commented 7 months ago

What pain is having the top level collection groups present in the structure causing? If the idea is just allowing consumers to type one fewer word when referencing a token, I'm not sure that its worth implementing. Here is my reasoning:

james-nash commented 6 months ago

What pain is having the top level collection groups present in the structure causing?

Not a huge amount, to be honest. In my case I'm using Cobalt UI to generate CSS custom properties from the DTCG file that Tokens Brücke exports out of Figma. By default, those top-level groups get included in the names, so I get stuff like:

:root {
  --collectionName-groupName-nestedGroupName-varName: #123456;
}

However, when designers select color vars in Figma, the collection name is not shown. They just see something like: "groupName/nestedGroupName" followed by a list of variable names. E.g.:

image (those variables are all in a collection called "Theme", but that's not visible in the variable picker - at least for colors. The collection names do seem to show up for other types)

In order to better align what our designers and devs see, we therefore want to strip off the collection name in the CSS, so that developers would get something like:

  --groupName-nestedGroupName-varName: #123456;

  /* e.g. */
  --color-background-brand-subtlest-default: #654321;

We've already configured Cobalt to do that (as you had suggested).

However, it just got me thinking it might be nice if it could all just work without needing to do that custom config. Hence the feature suggestion.

Happy for this to be closed though since it's quite niche and probably doesn't justify the effort needed to implement this.

mryechkin commented 5 months ago

Happy for this to be closed though since it's quite niche and probably doesn't justify the effort needed to implement this.

On the contrary, I would love to see this feature be implemented. I don't agree with the sentiment that this could result in bad user experience - in fact it's absence is what's making that user experience worse for me personally, because now I have to write my own custom transformer instead of using off-the-shelf ones that Style Dictionary already provides (which is all I need).

I see something like this as an "advanced" feature, and perhaps it should come with a warning to the user - if there are collisions, then that's on the user, not the plugin.

Anyway, just my opinion. I have no horse in this race, just something I immediately noticed when checking out this plugin. It's a great tool otherwise, and if I didn't already have my own code for exporting variables, I would most likely use it instead.