-
Notifications
You must be signed in to change notification settings - Fork 7
Description
First off, let me quickly say thank you for making this lovely tool. It's great to see new kinds of design token tools appear and, as one of the editors on the DTCG format, I'm also very excited to see tools that support the (draft) DTCG format! 😄
That being said, the output in the "W3C" tab1 does not currently conform to the current DTCG draft specification. Specifically:
- There is no
spacingtype, you should outputdimensiontokens instead. - Values for the
durationtype must be in milliseconds, so"3s"should be converted to"3000ms". Also, the spec does not support the valuepaused(if you feel it should, you're welcome to propose that in a new issue). - There is no
easingtype, you should outputcubicBeziertokens instead. Note thatcubicBeziervalues need to be plain JSON arrays, so"cubic-bezier(0.12, 0, 0.39, 0)"should be converted to[0.12, 0, 0.39, 0].- If you want to combine cubic bezier and duration, you can use the
transitiontype.
- If you want to combine cubic bezier and duration, you can use the
- There is no
radiustype, you should outputdimensionhere as well.- Since
dimensionvalues can only bepxorrem, the DTCG format doesn't currently have a proper way to represent % values (it probably should though!). You could fall back to using thestringtype for now, but be aware that type will be removed soon (another reason to add a proper type for percentage values to the spec! 😅).
- Since
- There is no
opacitytype. The current draft does permit anumbertype, which you could use for now. Just likestringabove, that will be removed soon too. However, I see quite a few other tools supporting opacity tokens, so we'll need to add something to the spec to support those. Feedback and ideas welcome! - The values of the
shadowtokens aren't valid - they need to follow the structure defined in the shadow type section.- Right now, the
shadowtype does not support multiple shadows. Hower, support for that has been proposed and I think it's likely that we'll update the spec to support that. Until then you could potentially split each shadow into a separate token and maybe append a number to the name or something like that (hacky, I know - but that's the best we can do right now).
- Right now, the
- There is no
mediaQuerytype, you should outputdimensiontokens there too. - The values for
fontFamilytokens are probably not quite right. Right now you're outputting the whole font stack as a single string. Syntactically that's valid, but according to the spec tools should interpret that as a single font family name (so you're saying there is 1 font and it is called"Palatino Linotype, serif"). Since these appear to be font stacks, they should be converted into arrays like["Palation Linotype", "serif"]. See thefontFamilytype chapter for details. - There are no
fontSizeorletterSpacingtypes, you should outputdimensiontokens there too. - There is no
lineHeighttype, you should outputnumberordimensiontokens there instead (with the caveat that thenumbertype will be going away soon).
Finally, you probably shouldn't add the tokens groups. The current output is like this:
However, the name tokens has no special meaning in the spec. So this is interpreted as: There is a group called "Color", which contains a nested group called "tokens", which contains a design token called "background-body". Since tools that convert to code would typically use the path to a token, the corresponding CSS output should be something like --color-tokens-background-body: #233043. That probably wasn't your intent. The solution is to just remove those intermediate tokens groups.
Putting it all together, the corrected "W3C" (DTCG) output should look something like this:
{
"Color": {
"$type": "color",
"background-body": {
"$value": "#233042"
},
"primary-body": {
"$value": "#354156"
}
},
"Spacing": {
"$type": "dimension",
"small": {
"$value": "4px"
},
"medium": {
"$value": "8px"
}
},
"Duration": {
"$type": "duration",
"slow": {
"$value": "3000ms"
},
"fast": {
"$value": "500ms"
}
},
"Easing": {
"$type": "cubicBezier",
"easeInSine": {
"$value": [0.12, 0, 0.39, 0]
}
},
"Radius": {
"$type": "dimension",
"circle": {
"$type": "string",
"$value": "50%"
},
"large": {
"$value": "8px"
},
"small": {
"$value": "2px"
}
},
"Opacity": {
"$type": "number",
"opacity-25": {
"$value": 0.25
},
"opacity-50": {
"$value": 0.5
}
},
"Shadow": {
"$type": "shadow",
"level-1_1": {
"$value": {
" color": "#00000024",
"offsetX": "0px",
"offsetY": "1px",
"blur": "1px",
"spread": "0px"
}
},
"level-1_2": {
"$value": {
"color": "#0000001F",
"offsetX": "0px",
"offsetY": "2px",
"blur": "1px",
"spread": "-1px"
}
},
"level-1_3": {
"$value": {
"color": "#00000033",
"offsetX": "0px",
"offsetY": "1px",
"blur": "3px",
"spread": "0px"
}
}
},
"Media Query": {
"$type": "dimension",
"max-width-mobile": {
"$value": "600px"
}
},
"Font Family": {
"$type": "fontFamily",
"body": {
"$value": ["Arial", "Helvetica", "sans-serif"]
}
},
"Font Size": {
"$type": "dimension",
"caption": {
"$value": "12px"
}
},
"Letter Spacing": {
"$type": "dimension",
"dense": {
"$value": "-1px"
}
},
"Line Height": {
"$type": "number",
"heading": {
"$value": "1.25"
}
}
}In principle, I'd be willing to submit PR(s) to fix these things. However, I'm pretty busy at the moment so probably won't have time to contribute fixes anytime soon. I therefore hope you don't mind me raising this issue to at least list out the issues in case someone else would like to try and fix them.
Footnotes
-
Btw, we would be grateful if you could relabel that to something like "DTCG". While the DTCG is a W3C community group, we are not a W3C working group and our technical reports are not on a W3C standards track. More info here: https://www.designtokens.org/press-kit/ ↩
{ "Color": { "$type": "color", "tokens": { "background-body": { "$value": "#233042" }, // more tokens... } }, // other groups... }