-
Notifications
You must be signed in to change notification settings - Fork 569
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
Incorrect/unexpected output for $dimension
token types when using DTCG format spec
#1398
Comments
I think the
In v5, we will likely stop supporting outdated versions of the DTCG spec (color type will get an update in the spec soon as well). |
This probably could be picked up by outside contributors as well just FYI, it shouldn't be too difficult from my estimation, so I added good first issue label |
@jorenbroekema for clarification, when you say "find a way to do this in a non-breaking manner" do you mean both {
"size": {
"$type": "dimension",
"border": {
"width": {
"$value": "1px"
"$description": "Default border width."
}
}
}
} and {
"size": {
"$type": "dimension",
"border": {
"width": {
"$value": {
"value": 1,
"unit": "px"
},
"$description": "Default border width."
}
}
}
} from the examples should produce --pgn-size-border-width: 1px; /* Default border width. */ or do you mean that there should also be a way to produce --pgn-size-border-width-value: 1; /* Default border width. */
--pgn-size-border-width-unit: 0px; /* Default border width. */ from {
"size": {
"$type": "dimension",
"border": {
"width": {
"$value": {
"value": 1,
"unit": "px"
},
"$description": "Default border width."
}
}
}
} |
The former: --pgn-size-border-width: 1px; /* Default border width. */ The latter can be produced as well already, if you use |
I started looking into this a bit today and hit a bit of a snag. My plan was to:
but it wasn't clear to me where to add a test that verifies generated css. I found https://github.com/amzn/style-dictionary/blob/main/__integration__/css.test.js and saw
but adding a new json file to https://github.com/amzn/style-dictionary/tree/main/__integration__/tokens/size seems like it touches more tests than I was hoping to. Any advice that could point me in the right direction (docs I'm missing/PRs doing adding similar tests to reference) would be greatly appreciated! |
I imagine we would handle this in a built-in transform hook, that transforms the object type to the string type, and apply that to all of the transformGroups as a way of ensuring automatic compatibility for all platforms. In my opinion, it should be added at the end of the array, because the object-format is easier to work with for other dimension transforms. We may need to update some of the dimension transforms accordingly, to also be able to handle object-type dimension tokens, e.g. the transforms that add units to unitless tokens, or those that do conversions such as px to rem or vice versa. We'll probably need to touch quite a few test files:
|
According to the DTCG format spec, the
$dimension
token type (source) should have a$value
that:From the DTCG spec example:
When trying this syntax for
$dimension
tokens in style-dictionary v4, we're seeing the following output:Token definition:
Token output in CSS variables
(Includes a
pgn
prefix).I believe the expected CSS variables output should be:
Our current workaround is to define the token with a
$value
that combines thevalue
/unit
together, e.g.:It seems like style-dictionary's support for composite tokens (per the DTCG format spec) is causing
$dimension
tokens to output multiple variables (i.e., splitting the value from the unit) vs. outputting a single CSS variable combining the configuredvalue
/unit
.Is this by design or is there a potential bug when trying to adopt the DTCG spec for
$dimension
tokens? Thanks!The text was updated successfully, but these errors were encountered: