Skip to content
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

Is the root node of a token tree a standard group? #249

Open
nclsndr opened this issue Sep 10, 2024 · 4 comments
Open

Is the root node of a token tree a standard group? #249

nclsndr opened this issue Sep 10, 2024 · 4 comments

Comments

@nclsndr
Copy link

nclsndr commented Sep 10, 2024

I couldn't find this detail in the current spec: Do we consider the root node of a token tree a standard group?
Said differently, can I have $description and/or $extensions at the root level? 👇

{
  "$description": "Tokens from brand A",
  "color": {
    "$type": "color",
    "$value": "#ff0000"
  }
}

It seems giving the root node the group definition opens opportunity to store global metadata. But becomes harder to work with, anytime there're more than 1 tokens file to handle.

Is there a decision about this already?

@nclsndr
Copy link
Author

nclsndr commented Sep 11, 2024

The same question goes with $type

Do we allow?

{
  "$type": "color",
  "aColor": {
    "$value": "#ff0000"
  }
}

@drwpow
Copy link
Contributor

drwpow commented Sep 11, 2024

This isn’t explicit, you’re right, but the root node is a group node. Any node that isn’t a token node (contains $value) is a group node. So any properties allowed on group are allowed at the root, and will cascade as such.

There have been some proposals to add root properties (such as $name to name the file, or even a $schema to point to a JSON schema), which would change this, but none are part of the spec currently.

Out of convention, though, most people don’t place anything in the root because there’s rarely any properties that make sense to apply to all tokens ($description, $type), but there’s nothing explicitly preventing this. Both of your examples are valid.

Technically, too, the root node could be a token if it contained $value. While that’s technically valid, it’s impractical, because no one has a practical use for a design system with only one token.

@nclsndr
Copy link
Author

nclsndr commented Sep 17, 2024

Thx @drwpow for the clear answer 👍

@nclsndr
Copy link
Author

nclsndr commented Oct 1, 2024

I was looking into the spec to slide in this bit of information. But I find myself not knowing where it would fit? Anyone with opinion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants