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

Allow useRefValue on some tokens, but not on others #17

Closed
mihkeleidast opened this issue Jul 14, 2022 · 2 comments · Fixed by #18
Closed

Allow useRefValue on some tokens, but not on others #17

mihkeleidast opened this issue Jul 14, 2022 · 2 comments · Fixed by #18

Comments

@mihkeleidast
Copy link
Contributor

I'm trying to work around this Figma Tokens issue: tokens-studio/figma-plugin#706

Our shadow tokens are defined as follows:

{
  "shadow": {
    "core": {
      "2": {
        "value": {
          "x": "0",
          "y": "1",
          "blur": "2",
          "spread": "0",
          "color": "{color.core.black.8}",
          "type": "dropShadow"
        }
      },
      "4": {
        "value": {
          "x": "0",
          "y": "2",
          "blur": "4",
          "spread": "0",
          "color": "{color.core.black.8}",
          "type": "dropShadow"
        }
      },
      "8": {
        "value": {
          "x": "0",
          "y": "4",
          "blur": "8",
          "spread": "0",
          "color": "{color.core.black.8}",
          "type": "dropShadow"
        }
      }
    },
    "elevation": {
      "small": {
        "value": ["{shadow.core.4}", "{shadow.core.2}"]
      },
      "medium": {
        "value": ["{shadow.core.8}", "{shadow.core.2}"]
      }
    }
  }
}

Our elevation shadows stack the different core shadows and we'd like to not have to duplicate those definitions. We would like to use useRefValue, so the token relationships would be visible in Figma Tokens as well. This is impossible currently due to how our tokens are defined and the FT issue I linked above.

Is there an easy way of adding some sort of filtering to useRefValue, so that the specific shadow.elevation.small.value would not use references, but everything else still would?

@jorenbroekema
Copy link
Contributor

I see, yeah I guess we can make a little something to work around that problem, I propose a boolean metadata flag that you can put in your token (as a sibling to the value prop) to flag it was "ignore this one for useRefValue function".

#18

I think that should allow you to work around the problem then?

Let me know!

@mihkeleidast
Copy link
Contributor Author

Ooh that seems nice! This is definitely a better workaround than not using references at all, but it does lose the internal color reference currently. If this is more difficult to solve, I understand, does not matter too much.

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 a pull request may close this issue.

2 participants