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

> However, if they could just pick a single file, which then imports whatever other files it needs in the correct order, they could be blissfully unaware.

Couldn’t agree more. I’m strongly in favor of the “entry file” approach where a single file **contains all information needed about all the tokens**. This is a pattern mirrored by JSONSchema/OpenAPI, and even JS modules themselves.

As you (and others) pointed out, requiring multiple files with no information on how they relate requires some higher-level metadata that I don’t think is necessary (i.e. it becomes “the entry file” in another sense, which could just be `tokens.json` to begin with).

### Remote aliases

I’m sure this has been mentioned in some other thread already, but I’d love to be able to reference both local and remote files, because I think hosting tokens from a server/API will be very common. It could be done similarly to JSONSchema’s `$ref` property, where the `#` is a character delimiting the URL from the key:

```json
{
  "inline": {
    "$type": "color",
    "$value": "#0033ff"
  },
  "local": {
    "$type": "color",
    "$value": "{file://./colors.json#color.red}"
  },
  "remote":{
    "$type": "color",
    "$value": "{https://myapi.com/v1/tokens#color.green}"
  }
}
```

I’m not too attached to the `file://` protocol or anything; was just proposing some universal reserved prefix that designates the alias is remote. We could even revisit the alias syntax too, I suppose, but I’m not trying to open a can of worms; just advocate for remote file aliasing and that’s all.

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


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

Received on Saturday, 30 March 2024 04:51:11 UTC