figma2flutter icon indicating copy to clipboard operation
figma2flutter copied to clipboard

[FEATURE REQUEST] Support filtering out token-sets (such as those "treated as source")

Open kvenn opened this issue 1 year ago • 4 comments

:speech_balloon: Description

If I mark a token-set as "source", it doesn't allow me to access those variables in Figma. Ideally it would work the same in the code.

If this is controversial, it would be great if there was a setting passed to the generator (or a config file) that allowed you to ignore certain token-sets. Or ignore source token-sets.

:question: Link to specification or documentation (if available)

Tokens studio docs

Details

themes/semantic-light references colors in core, but they shouldn't be accessible in the code (to prevent people from using colors directly instead of through the semantic theme token set).

In $themes.json there is this:

    "selectedTokenSets": {
      "global": "enabled",
      "core": "source",
      "theme/semantic-light": "enabled"
    },

image

kvenn avatar Jun 12 '24 01:06 kvenn

Style Dictionary has some generic approaches to how they handle it. Flutter impl.

https://v4.styledictionary.com/examples/splitting-output-files/ Looks like using "filters" is how they recommend doing it. https://v4.styledictionary.com/reference/hooks/formats/#filtering-tokens

kvenn avatar Jun 12 '24 18:06 kvenn

The linked docs require a Figma login.

freemansoft avatar Jun 12 '24 21:06 freemansoft

Updated!

kvenn avatar Jun 17 '24 15:06 kvenn

I opened a PR specific to omitting "core" tokens https://github.com/mark-nicepants/figma2flutter/pull/34. It could easily be modified to accept a list of paths for token sets to omit if that need arrises.

apackin avatar Jun 17 '24 22:06 apackin