-
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
Remove JSON derived types from the specification #120
Comments
I've been making certain assumptions about how tools could / should handle certain scenarios. I'll detail them below for discussion. Whether we accept these or something else, I do agree that these kinds of things should be made explicit in the spec. 1. Tools don't necessarily need to use every type of token value. It is acceptable for tools to just ignore types that are not relevant to themFor example, when importing a design tokens file into a colour palette editing tool, I'd argue that it's quite reasonable for that tool to pluck out only the color tokens and present those to its users. Any other type of token could just be ignored. (It might however make sense to require tools that can import and export design token files to at least preserve any tokens they don't use themselves - see discussion in #157) Note that for this to work it is necessary for every tool to implement the type resolution algorithm defined in the spec. However once that has been done (presumably while parsing the imported file), the tool can then choose to operate on whatever subset of tokens are relevant to it. Therefore, if we retain the basic JSON types like 2. The list of types supported by the spec will grow over timeAs time goes by, I'm sure new use-cases for design tokens will arise and that is likely to necessitate more types being added to our spec. I think your CSS For example, a translation tool that wants to export them as CSS code could then output the corresponding CSS keywords without quotes. 3. The basic JSON types can be useful for extensibilityI'd argue that the However, used together with The value of {
"token name": {
"$type": "myFancyType", // <-- not allowed!
"$value": ...
}
} However, you can do something like this: {
"token name": {
"$type": "...", // <-- whichever type is the "closest" to what you need
"$value": ... , // <-- value that is valid for the chosen type
"$extensions": {
// Tell your tool to interpret this token's value in a special way
"com.your-tool.custom-type": "myFancyType"
}
}
} Now the "closest" type you pick here could technically be any of the spec's types - one of the more DS-oriented ones like While I hope that using extensions & the JSON types in this way to create new, proprietary token types will be relatively rare (I'm certainly not trying to advocate for every tool to go and invent lots of proprietary types!), I do think it's useful to retain this option. As I mentioned earlier, this may enable "cowpaths" to emerge which future spec iterations can "pave". And, one of the DTCG principles is "Focused, yet extensible" :-) If you agree with my assumptions above, then I'd argue we should keep the
And, aside from all of that, I think we should consider adding something like a |
If tools can ignore any type they wish, then why wouldn't they also ignore non-standard Tooling that I'm currently building relies on custom token |
I think that the biggest concern there would be this:
That's a bit contrived though. And if you named your non-standard On the topic of this issue: for what it's worth, I was definitely against the JSON primitive types being allowed as valid token types before reading James's post today, but I have successfully been converted to the pro-primitive-types side with that |
I don't really understand the arguments for the JSON derived types. To me this argument looks like this :
Not doing the work and hoping that the type system of the carrier format (JSON) perfectly aligns with this specification is just not a good idea in my opinion. The main difference is that unknown/unexpected things become invalid things. It might sound weird that errors are desirable but it is much better to have a hard error that allows ignoring a token. see : https://www.w3.org/TR/css-syntax-3/#error-handling The specification discourages using https://tr.designtokens.org/format/#extensions
I think this was the right call and it is a mistake to suddenly suggest the opposite in this issue. That does not mean that implementors can not experiment with non-standard types. Implementers can do a spec+ approach like Sass or go for vendor prefixes.
It is the opposite that needs solving :) What is something with type
What is something with type
How do we express what is left? |
Branching the text-alignment/CSS Keyword concerns into a separate issue for further discussion: #177 Keeping this issue focused on keeping/removing the JSON types from the specification. |
After reviewing this issue, the editors decided to keep JSON derived types in the specification. Why
JSON derived types enable teams and tools to create proprietary types, which can help inform future spec iterations and we do expect more types to be needed in the future. |
@ChucKN0risK This is really unexpected. This specification exists to remove interop issues between tools. This is in direct conflict with :
If teams or tools need to store and communicate bits of information that are not part of this specification they can use
It can be as simple as a reference to the JSON specification and |
If type prototyping is a concern it would be more interesting to have something like this : {
"$value": [{"anything": "you need"}],
"$type": "com.toolprovider.custom-type"
} Any tool that doesn't recognise this type will leave it as-is. This creates a conflict free mechanic/space for experimentation. |
@kevinmpowell @ChucKN0risK @c1rrus This question was also unanswered :
|
Whether the format allows custom Pros of using JSON primitive types and
Pros of using a custom
The way I see it, the better of the two solutions thus depends on how important that "custom composite token types right in the token file" scenario is to you. I'm not sold on the importance of that—I'm struggling to come up with a scenario where you'd want to be able to store a composite token in the JSON but wouldn't need your tools to understand anything about those tokens other than their schema. In all of those cases, it seems like a custom If we can say that custom |
Recently, I was thinking about how HTML remains forward compatible with attribute and element names, and I wonder if it would be helpful to take a page from their book and do something like the following. Specific to $type
Related
|
I don't think the specification needs another convention to indicate that something is custom and I also don't think that that solves this issue. The specification already defines a good naming format for extensions that can be reused to indicate that a type is user/tool defined. this could be : What are the practical benefits of having a schema for user/tool defined typed? Both aspects don't really have anything to do with the point of this issue. After @ChucKN0risK stated that the purpose is to allow custom types I think they are vastly more problematic.
User/tool defined types should be clearly marked as such, they should not be a side effect of vagueness in the specification. That again leaves JSON derived types without any purpose, which means they should be removed from the specification. |
Thanks all for the additional comments. The editors have re-reviewed this issue and come to the conclusion that, yes, we should remove the JSON types after all! :-)
I'll leave this issue open until we've made and merged a PR that updates the spec accordingly. Footnotes
|
FYI: another use for |
I've just opened a PR to make the required changes: #201 :-) @CITguy it retains the It'll need to be approved by other editors before it can be merged. But you're all very welcome to take a look and add review comments. Thanks! |
Thank you everyone! |
https://design-tokens.github.io/community-group/format/#types
This part of the specification assumes that implementers will have an inherent understanding of certain types and how to handle them.
This implicit typing will lead to interop issues.
It's better to have exact definitions for each type supported in the schema.
An obvious example is
String
.When converting a value to CSS it is ambiguous if it should become an ident token or a string token.
or
You also can't do this in the tokens file :
Because that dictates how strings work in any consuming context.
The text was updated successfully, but these errors were encountered: