- From: James Nash via GitHub <sysbot+gh@w3.org>
- Date: Mon, 13 Sep 2021 22:28:04 +0000
- To: public-design-tokens-log@w3.org
It may be worth pointing out that in the current draft spec, the `type` property itself _is_ optional. _But_, if you omit it, the type of that token will be inferred as follows: >If the type property is absent, tools MUST treat values as one of the basic JSON types and not attempt to infer any other type from the value. So, a tool that supports this format is required to interpret things as follows: ```jsonc { "token with type": { "value": "#ff0000", "type": "color" // This is a color token becuase we've set the type }, "token without type": { "value": "#00ff00" // This is a string token because no type // property is present } } ``` In other words, every token in the file does have an unambiguous type (which, as others have already pointed out, is important for token files to be interoperable between different kinds of tools). However, the basic JSON types (string, number, boolean, etc.) probably aren't all that useful in the context of a design system (except perhaps numbers, which could be used for line-heights, aspect ratios, as inputs to modular scales, etc.). In practice I therefore expect most tokens will include a `type` property in order to declare which of the DTCG types they are (color, dimension, font name, etc.). For manually authored token files, typing out `"type": "..."` lots of times may get tedious. However, I think the idea we've been discussing in the DTCG format team of allowing the `type` property on groups would alleviate that. This discussion thread has made me more convinced that we should add it to the spec. The way it would work is that a token's type is determined as follows: 1. If the token has a `type` property, then the token is of that type. 2. Otherwise, step up the parent groups until you find the nearest one with a `type` property and use that. 3. Otherwise, if you reach the root group and no `type` property was encountered, then the type of the token is the JSON type of its value. So folks wanting to have files that only contain one kind of token (e.g. `colors.tokens.json`) could easily do so by just adding `"type": "color"` to the top-level. Hopefully that won't be too onerous. :-) -- GitHub Notification of comment by c1rrus Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/63#issuecomment-918629940 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 13 September 2021 22:28:06 UTC