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

[Question] Is there a way to have a value for a token that will also have nested values? #716

Closed
michaelwarren1106 opened this issue Oct 14, 2021 · 4 comments

Comments

@michaelwarren1106
Copy link

michaelwarren1106 commented Oct 14, 2021

What I'd really like to be able to do if possible is set a "default" prop that wont result in an addition to the token name but still allows to created nested variations in the same file/config.

Lets say I have config like the following:

color: {
   text: {
      body: {
         DEFAULT: { value: 'green'},
         on: {
            dark: { value: 'blue' },
            'dark-accent': { value: 'pink' }
         }
      }
   }
}

It would be really cool if the names that end up getting created are something like:

color-text-body: 'green'             // instead of 'color-text-body-default'
color-text-body-on-dark: 'blue'
color-text-body-on-dark-accent: 'pink'

Is there any way to accomplish this kind of config?

Thanks!

@michaelwarren1106
Copy link
Author

nevermind, I've found the previous issues that mention this, and I second the 4.0 feature requests :)

@dbanksdesign
Copy link
Member

You can do this if you changed 'DEFAULT' to a special or space character like '@' or '_':

color: {
   text: {
      body: {
         _: { value: 'green'},
         on: {
            dark: { value: 'blue' },
            'dark-accent': { value: 'pink' }
         }
      }
   }
}

@michaelwarren1106
Copy link
Author

oh cool! so it'll just get "ignored" when translated through the various transforms?

@dbanksdesign
Copy link
Member

It won't get ignored, but the way the name transforms work is they use a string formatting method like in the change-case package which trims starting and trailing characters like that, so "color-red-" becomes "colorRed" or "color_red" etc.

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