-
Notifications
You must be signed in to change notification settings - Fork 30
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
128: Save expanded tokens to separate property #178
Conversation
|
Hm I think I would prefer to make keeping the original object that's expanded as an opt-in, so: {
"foo": {
"value": {
"fontSize": "16px",
"fontFamily": "Arial",
"fontWeight": "Bold",
"lineHeight": "1"
},
"type": "typography"
}
} becomes: {
"foo": {
"fontSize": {
"value": "16px",
"type": "fontSizes"
},
"fontFamily": {
"value": "Arial",
"type": "fontFamilies"
},
"fontWeight": {
"value": "Bold",
"type": "fontWeights"
},
"lineHeight": {
"value": "1",
"type": "lineHeights"
}
"__sd_transforms_placeholder__": {
"value": {
"fontSize": "16px",
"fontFamily": "Arial",
"fontWeight": "Bold",
"lineHeight": "1"
},
"type": "typography"
}
}
} I'm thinking you might need that :root {
--foo-font-size: 16px;
--foo-font-family: Arial;
--foo-font-weight: 700;
--foo-line-height: 1;
--foo: 700 16px/1 Arial;
} |
I hear - that does end up with a cleaner object model, everything wrapped together nicely.
I'm getting dizzy 😵 😆 |
That's actually a really good question and I'm not sure at the moment about whether I added an integration test for that use case. If it turns out there's no clear path for this, then perhaps it makes sense that when expanding composite tokens, the original should always be kept intact for references. Then, it will not be an option, it'll be the default, after all, people could then filter those tokens out with StyleDictionary formats -> filters. Either way, since you've spent some effort into this, I will make it a priority to dive into this topic as well and come up with a proper solution. The solution isn't that obvious so I want to start with some test cases and outline what the preferred behavior should be (including your case with referencing a composite token), and see if I can adjust the implementation code to align with the preferred behavior. |
This PR kinda got lost a bit because it ended up being a tad more complicated than I foresaw when I first created the issue #128 , I added a comment that explains the issue and a potential way to solve it, let me know if you still want to work on this PR |
Will resolve #128
What do you think of this solution?
We move over the expanded tokens to a separate property, keeping the original composite token, which is output as before.
If you agree, a simple name transformer can be added to remove the added text from the name.