-
Notifications
You must be signed in to change notification settings - Fork 63
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
Use CSS as a transfer format instead of JSON. #185
Comments
But this means every tool that wants to transform tokens needs to write parsing logic. Also output may not be css but xml for android or other files e.g. for swift. This means css properties need to be parsed into a json like shape to re-structure to other languages. |
For CSS as a language : For the specific schema :
The same is true for JSON.
The same is also true for JSON. All other programming languages need to parse to their equivalent. I definitely do not mean that CSS is a more common data format. But the CSSWG has done so much work to create ways to record visual/style information in a file. Not building on top of that seems like a waste. Declaring design tokens is something that can be done in CSS and I think it is worth further exploring the benefits of such an approach. |
What I meant to say is that JSON is a standard that has ready to use parsers in nearly all languages.
I was / am not aware of that. So there are css to property parsers? One would need to turn |
There is definitely a tradeoff here. They are both better in different aspects. Using JSON as a format has benefits because the format is simpler and has wide support for parsers/serialisers. CSS would be easier because the specification work for all the needed value types has already been done. Working together with the CSS tooling community would also have benefits for the design token tooling community.
How each value needs to be parsed is well defined in CSS. https://drafts.css-houdini.org/css-typed-om/#stylevalue-objects
The interfaces described in CSS Typed OM can be interesting. These allow you to create a tool with roughly this outline :
|
@romainmenke
Easy implementation and usage is the key here. |
Can you give concrete examples of something that isn't possible to express in CSS syntax?
If the argument is that an intermediary tool is doing the heavy lifting then the same would be true when using CSS as a file format. An intermediary tool around JSON could be replaced by an intermediary tool around CSS.
I don't follow this statement and don't understand what you mean with this.
I don't expect design tokens to adopt the whole of CSS.
The web does not benefit from this approach. We would only use the CSS syntax and value definitions to get a head start for a transfer file format. CSS at it's core is just a data format to communicate visual/style information to another program. That it has been used mostly in browsers should not be a reason not to use it for other things. |
One of the core principles of design tokens is that they are platform agnostic because they MUST be usable in differnt implementation/design. A single design tokens must support other platforms too, that's why they have to be raw data and then transformed for the supported platforms. Eg. {
"space-8": {
"$type": "space",
"$value": 8
}
} On iOS may become Since CSS is already a domain-specific (or platform-specific), and so is one output language, more precisely the one for web-based implementations (but there are many supported formats on web), it cannot be the initial format for tokens then, the same way design tokens unlikey hold css-specific values like |
I think you misunderstood what I meant with this proposal :) I do not mean to encode design tokens as CSS that would work in a browser. I meant to use CSS as a basis for a storage format. /* file: brand.tokens.css */
@token shadow-token {
box-shadow: 8 8 24 #00000088;
} This is syntactically correct CSS and uses existing specifications for parsing, serializing. It however does nothing in a browser. In a way this is a counter point to :
There seems to be resistance to making the specification lean and easy to consume in software. This proposal embraces the reasons behind that :
|
I know this change will never happen. Many issues that are being raised here are the result of inventing yet another way to encode style/visual data. This work was already done for CSS by the CSSWG. CSS isn't widely seen as something that can be used outside the browser, but it can and doing so can have benefits. |
It would make sense, i agree, but i see this as "evolution" of a standard. It may be an alternative syntax (like json vs. yaml) but at current state i think we should focus on having one standard at least. |
Absolutely :) |
We've reviewed this issue. There's some good points here, but we're sticking with JSON as the Design Tokens format for now. |
Thank you for reading and evaluating this idea :) |
Because I can't help but wonder if JSON was picked only because it is the go-to format to communicate data between programs. I want to make sure this choice was the right one.
A lot of the work being done here in the DTCG has been done before by the CSSWG.
With CSS we already have a way to communicate style information in a structured, machine readable manner.
There is also a very large and healthy community around it.
There are parsers and serialisers in many programming languages.
Instead of inventing something new and trying to force it to work in JSON I propose we just use CSS.
could be :
Groups can be done in multiple ways :
Custom properties already exist :
Starting out with support for everything in the CSS specification will be impossible.
But a small subset can be defined and can be expanded over time.
It allows the DTCG to focus on these aspects :
@token
at ruleThe text was updated successfully, but these errors were encountered: