Design Token Compatibility #87
Replies: 8 comments 18 replies
-
related #21 currently, for better or worse, the props source is JS and the CSS files are generated. only time will tell if that was the right path. was easier for me to import js from js and then write a css file. but i bet there's easier ways. |
Beta Was this translation helpful? Give feedback.
-
Gotcha. Ok, this is probably a longer term idea and possibly one better solved by combining a few tools (or waiting to see what sprouts up)...thanks for hearing my idea. Feel free to close it out (I know too many issues / discussions can distract haha) I don't see a way for me to close it |
Beta Was this translation helpful? Give feedback.
-
Maybe this is closer to what you were thinking? https://www.knapsack.cloud/figma-designsystem I think there's even a design token standard.. I didn't really check to see how compliant I was.. might help with this interop story you're mentioning? |
Beta Was this translation helpful? Give feedback.
-
I listen to their podcast and have been aware of Knapsack but have never actually seen it or know how it works exactly. But from what I understand, yah, this is the sort of setup where design tools and code start to synchronize. I saw another tool like this emerging that I cannot remember the name of. But, I was more referring to the community for design tokens themselves: I joined as a fly on the wall but haven't really kept up so much but it looks like it's still early in terms of an actual officially blessed design tokens standard but here are some resources: https://design-tokens.github.io/community-group/format/#file-format And here's a pretty good example of JSON being transformed to sass variables: To my mind, it seems likely they'll go with JSON, will use IdeaSo in terms of OP, it might be nice if the
Above would be the conceptual ideal I'm thinking of. But it also contributes some potentially breaking API issues for OP since it's opted for flatter less verbose names (which I totally can relate to in terms of readability): :where(html) {
--lime-0: #f4fce3;
--lime-1: #e9fac8;
...
} So if you literally took every key of JSON from {
"op": {
"color": {
"lime-0": {
"value": "#f4fce3"
},
"lime-1": {
"value": "#e9fac8"
}
},
"typeface": {
"whatever-we-call-typography": {
"value": "Comic Sans MS"
},
}
}
} you'd get Now, and this gets into the weeds in terms of whether it would conform to this upcoming design token standard interoperability wise , but, you could seed the crawler with start points e..g ("I'd like these categories built": FlawsWould 3rd party parsers have the same interpretation from the JSON alone and produce the same meaningful results on the other end? Probably not. I'd say this is a risky approach in terms of maintaining potential interoperability. These "start points" would also add complexity of the code itself with little gains… Better waySo, because the standard isn't finalized, and also https://design-tokens.github.io/community-group/format/#export-tools clearly shows every key getting transformed literally into the sass variable name e.g. {
"lime-0": {
"value": "#f4fce3"
},
"lime-1": {
"value": "#e9fac8"
}
} So instead of the one export const Red = {...}
export const Lime = {
'--lime-0': '#f4fce3',
...
} I think these each color would become its own separate file I think this will scale with the standard and emerging tooling (unless they completely change their direction drastically of course!), and, the file names themselves do fine in acting as a form of categorization for the time being; e.g. Misc JSON propertiesIt seems in order to make this helpful, we'd want to sprinkle in things like https://design-tokens.github.io/community-group/format/#dimension for things like
I think you were referring to Knapsack. But are you looking for help and/or interested in this for OP? If so I could possibly help with disclaimer that I'll likely not be the fastest in terms of turn around with a job, family, and my own OS library to contend with but willing to give it a stab. ApproachHonestly, I would try to leverage the create props looping approach you already have and only make it good enough to work as a stand in. I'm 99% sure, a big player will make an extremely robust and better tool for this if they haven't already. So the goal would be to have a parity result in terms of a final I suppose the If you're fine with this disclaimer I can give it a go in my spare cycled :-) Lmk |
Beta Was this translation helpful? Give feedback.
-
Having second thoughts after contemplating this -- I think some sort of AST approach is going to scale better then the approach I listed above which would likely be fraught with bugs. Unfortunately, AST's are a bit out of my wheelhouse and not something I have bandwidth to sign up for learning and implementing myself. That said, there are folks "out there" that probably already have some experience transpiiling with Acorn / Babel or maybe there's an npm package resource like https://github.com/vtrushin/json-to-ast (I saw several json to ast parsers), and they'd probably be able to pull this sort of thing off. Above said, I do think longer term, having OP use standards based design tokens will have benefits. I just don't know how to recommend implementing it practically at this point. I've asked the design token community if such tooling is evolving in-the-open and if it's available or if there's a list. We'll see what they say. |
Beta Was this translation helpful? Give feedback.
-
I also had this idea of adding Design Token designs to component-level props. I just posted an issues on this. #93 |
Beta Was this translation helpful? Give feedback.
-
Nice, I'm mostly hearing "it'd be sweet if there was json to use." Which totally! We're making css files, why not make json files with very similar loops. I'm all for outputting json, it'll serve from the CDN nicely too. are there multiple json formats to try and conform to? |
Beta Was this translation helpful? Give feedback.
-
Shipped in |
Beta Was this translation helpful? Give feedback.
-
I can see a world where design tokens that meet the spec can be used and then transformed into the OP .js definitions. But, I see the other way around too; that is, you can work in css custom properties which feel more natural for most FE devs (I think), but then generate design tokens.
The benefit would be interoperability. Perhaps there's tooling that could eventually sync with FIgma or Sketch so your updates on both sides synchronize.
Beta Was this translation helpful? Give feedback.
All reactions