[community-group] Can alias tokens reference tokens in another file? (#166)

TravisSpomer has just created a new issue for https://github.com/design-tokens/community-group:

== Can alias tokens reference tokens in another file? ==
Theming (#2) is definitely still a big unresolved issue, but let's say for now you have three token files all in this format: `global.json`, `light.json`, and `dark.json`.

#### global.json
```json
{ "black": { "$type": "color", "$value": "#000000" },
  "white": { "$type": "color", "$value": "#ffffff" } }
```

#### light.json
```json
{ "foreground": { "$type": "color", "$value": "{black}" } }
```

#### dark.json
```json
{ "foreground": { "$type": "color", "$value": "{white}" } }
```

You combine them with something like this:

```bash
theoretical-token-tool --in global.json --in light.json --out light.css
theoretical-token-tool --in global.json --in dark.json --out dark.css
```

On their own, `light.json` and `dark.json` are useless; they require `global.json` to make sense. My open-ended question is: are `light.json` and `dark.json` *invalid* DTCG-format token files that should not be accepted by any tool because their references can't be resolved on their own? Or are they still *valid*, but just can't be *used* without `global.json`?

I've been assuming all this time that all three files are valid, but I didn't see anything in the spec that says either way.

* **If they're valid:** The spec should explicitly say that it's valid to have a token file that references tokens that don't exist in that file.
* **If they're not valid:** One of the following will happen:
  1. Tools like `theoretical-token-tool` will decide to accept those invalid files anyway, which will end up hurting interoperability
  2. Or people who need multiple themes will have to put all of their themes in a single file and give a prefix like `light.` or `dark.` to all of their themed tokens, and then strip that prefix later when exporting to another format like CSS
  3. Or people who need multiple themes have to include all of the tokens from `global.json` in both `light.json` and `dark.json`

I'm not sure if we have to solve theming for v1 of this spec, but it seems like we do at least have to define this. All of those options have downsides, and if the spec doesn't specify the behavior, I think we'll get several downsides all at once as each tool interprets things a little differently.

Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/166 using your GitHub account


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

Received on Tuesday, 30 August 2022 22:34:36 UTC