Closed Imable closed 5 months ago
This pull request is automatically being deployed by Amplify Hosting (learn more).
Access this pull request here: https://pr-1244.d16eby4ekpss5y.amplifyapp.com
This pull request is automatically being deployed by Amplify Hosting (learn more).
Access this pull request here: https://pr-1244.d1ouz7xofr5p4l.amplifyapp.com
Hey, thanks for raising this, I made some minor adjustments to simplify it a little and I also adjusted your test to test with a DTCG use case of nested object-values (border -> strokeStyle), your test example is a bit more custom and technically not compliant with DTCG because color values aren't supposed to be object-values (as of now).
That said, I did also run your test locally, ensuring your use case is actually fixed. It does pass with my adjustments, with one small change:
Background: {
Surface: {
Background: {
value: '#ffffff', // <-- {Gray.0.Background} in my test because it can remain a ref, due to resolved value being a string value
I found an edge case as well with the strokeStyle test because it has a multi-value dimension (Array type), and I was doing typeof 'object'
checks so it would erroneously expand array values, now it checks whether the value is a plain object which fixes that bug.
I also added a changeset ensuring it will be in next release.
Awesome @jorenbroekema ✨ The more general test case is a lot more suitable too. Much appreciated!
Thanks for contributing :)!
Description of changes
My organization structures design tokens such that design tokens are dynamically linked with a color from our color palette and its foreground color. This requires recursive expansion of composite tokens, which until now was marked
// TODO
in code.I reused the
expandTokensRecurse
function to recursively expand the expanded tokens of a composite token. If the composite token only contains leafs (no composite token), no work is done.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.