Re: [community-group] How to do tokens that share a name with a group (#97)

@c1rrus thanks for the clarification! I see the use case and I also want to see if we can accommodate it if possible.

The hard part for me is that the thing (say, `color.accent`) should be formatted and behave like a token when it's used as a token, and be formatted and behave like a group when it's used as a group.

So, say we were working with `color.accent` as a token. The spec currently defines a token as an object with a "value" property, so we should expect `color.accent` to have a `value`. So far, none of the examples we've explored meet this expectation!

Next, we work with `color.accent` as a group - say, put its children into their own css file when translating to css. This is an easier case since there's no real format requirements for a group - but since any object can be a token _or_ a group, the parser will essentially have to ask "are there any items in this object that aren't reserved words?" — iteratively! — before concluding that it's safe to move back up the tree.

Thinking through this now, I see how some of the things we've discussed resolve the bulk of the issue. Especially `_default` (or something like that) — `_default` should be a regular old token with a `value` (as you've shown).

I do think that these cases outline one argument for why groups should have `"_type": "group"` — if they didn't, a parser would have to do some extra work to figure out how to work with the object or token. It isn't a world-ending requirement, and it's definitely a tradeoff either way. I'm going to open my group formatting issue so we can explore further.

-- 
GitHub Notification of comment by ilikescience
Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/97#issuecomment-1015489187 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 18 January 2022 14:52:45 UTC