-
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
The $ property name prefix should be unnecessary with a well-structured schema #225
Comments
Your observations on the Design Token Schema standard are insightful. Drawing from the W3C Design Tokens standard you provided:
However, I do resonate with your points about the inherent complexity introduced by the Thanks for sparking this conversation! It's discussions like these that help the community grow and refine its understanding. |
I understand the goals you have for using the prefix, but the prefix really isn't necessary to reach them:
I think the style of schema I'm advocating here is by far the more common and plain way to design a JSON schema. Again, I've never seen a schema like this one where all the keys are prefixed and I immediately found it exceedingly odd. I was thinking there had to be an exceptional reason for it, but the reason you give are all not actually problems with the more common JSON schema design. |
I can agree with @justinfagnani
{
"value": {
"description": "This is an example of a group containing a nested group",
"tokens": {
"subgroup_of_tokens": {
"token_1_name": {
"type": "color",
"value": "#aabbcc"
},
"token_2_name": {
"type": "color",
"value": "#ddeeff"
}
}
}
}
}
It's good to add |
I'll mention that I appreciate the |
@ddamato wouldn't this be true of any JSON file format? Why don't they all use prefixes? |
Maybe because they aren't often authored by hand? Hard to speak on behalf of others. Like I said, I think your points are otherwise solid. |
I've always kind of assumed that "looks like existing popular token JSON formats" was an unspoken goal of this format. This is how Amazon's Style Dictionary and the Tokens Studio plugin for Figma do things (or at least did last time I looked), so that's what we started with. A reserved prefix character (To clarify, that's my response to "why is this file format so weird." I would have personally preferred something like a |
There shouldn't be a set of reserved words anyway, because you shouldn't ever mix user-defined keys with schema-defined keys. And you should only need key/value objects with user-defined keys in specific places, like a group of tokens. |
I saw a few arguments pro "hand-editing" or "manual" editing/searching. |
That's true, perhaps I'm thinking in terms of the file being overwhelming in some instances. Where if someone new needed to visit this, I could tell them: you don't need to edit anything except for entries that begin with |
I was looking into this format recently and I came away quite confused why the
$
prefix was required everywhere. The rationale pointed to in the format spec (https://design-tokens.github.io/community-group/format/#additional-group-properties) indicates that it's to differentiate between group properties and the tokens within a group.How this is usually handled in JSON is that the key/value maps are separated from the data structurally - they don't mix in a single object. For groups, all the child tokens would be in a sub-object called
children
ortokens
, and so could never clash with group properties likedescription
.So a group would look like:
Many, many JSON schemas have both defined properties and open-ended key/value maps and work just fine without prefixing every defined property name in the schema. This spec is the first I've ever seen that does it, and I think it harms the human readability of the documents. It also makes programatic handling of groups more difficult, because to get child tokens you need to filter on a group name prefix instead of just getting the keys of the
children
property.The text was updated successfully, but these errors were encountered: