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

If all one cares about is the exported token's name, you could still achieve that pretty easily in the export process! Tokens are already necessarily getting renamed when exporting to code, to turn `.` into `-`, to change case, or so on. So you could just have a rule in your export that anything named `"_"` or `base` or `default` or whatever gets dropped when exporting to SCSS.

`color.accent.default` = `#dd0000` → `$color-accent: #dd0000;`
`color.accent.light` = `#ff2222` → `$color-accent-light: #ff2222;`
`color.accent.dark` = `#aa0000` → `$color-accent-dark: #aa0000;`

One scenario that's somewhat important to me _for the future_ is group aliasing. For example:

```json
{
  "neutralcontrol": {
    "foreground": {
      "type": "color",
      "rest": { "value": "{...}" },
      "hover": { "value": "{...}" },
      "pressed": { "value": "{...}" },
      "disabled": { "value": "{...}" }
    },
    "background": {
      "type": "color",
      "rest": { "value": "{...}" },
      "hover": { "value": "{...}" },
      "pressed": { "value": "{...}" },
      "disabled": { "value": "{...}" }
    }
  },
  "button":
  {
    "text": {
      "color": { "value": "{neutralcontrol.foreground}" }
    },
    "base": {
      "color": { "value": "{neutralcontrol.background}" }
    }
  }
}
```

(In that example, `button` has 8 tokens that just reference existing sets of colors that were designed to go together, so no accidentally mixing and matching incompatible sets. `button.text.color.rest` = `neutralcontrol.foreground.rest`, `button.base.color.disabled` = `neutralcolor.background.disabled`, and so on.)

It's not possible with today's spec, but I want to try to make sure it's possible _someday_. If `neutralcolor.foreground` could have a value _and_ be a group, then `{neutralcolor.foreground}` becomes ambiguous. It's not a total blocker, but that's one reason I'm in favor of tokens and groups not being allowed to share a name.

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


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

Received on Thursday, 13 January 2022 19:54:28 UTC