-
Notifications
You must be signed in to change notification settings - Fork 567
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
Output References does not work with interpolated values #589
Comments
a config option should be provided by style-dictionary for users to replace referenced value directly. I also mentioned this problem here with detailed example: |
@uptonking I think this fix (#590) which is in the latest release candidate should handle your use case in #565 without a custom format. We updated {
"component": {
"btn": {
"h": { "value": "10" },
"s": { "value": "12%" },
"l": { "value": "12%" },
"hsl": {
"value": "hsl({component.btn.h.value}, {component.btn.s.value}, {component.btn.l.value})"
}
}
}
} With those tokens and this configuration: platforms: {
css: {
transformGroup: `css`,
files: [{
destination: `build/variables2.css`,
format: `css/variables`,
options: {
outputReferences: true
}
}]
}
} You should get this output: :root {
--component-btn-l: 12%;
--component-btn-s: 12%;
--component-btn-h: 10;
--component-btn-hsl: hsl(var(--component-btn-h), var(--component-btn-s), var(--component-btn-l));
} We did change |
@dbanksdesign i hope u can provide another utility function named
although i can write one function, but this usecase(replace reference) is so frequent that official api from style-dictionary should be better.
{
"comp": {
"btn": {
"h": { "value": "10" },
"s": { "value": "12%" },
"l": { "value": "12%" },
"hsl": {
"value": "hsl({comp.btn.h.value}, {comp.btn.s.value}, {comp.btn.l.value})"
},
"box-shadow-color": {
"value": "{comp.btn.hsl.value}"
},
"box-shadow": {
"value": "0 0.125rem 0 {comp.btn.box-shadow-color.value}",
"replaceRefs": "all"
}
}
} |
Based on the comments in #428 the current implementation of outputReferences does not handle interpolated values, like
calc({breakpoint.sm.value} / {breakpoint.xs.value})
because thegetReference
method returns a single token (the first reference it finds).The text was updated successfully, but these errors were encountered: