-
Notifications
You must be signed in to change notification settings - Fork 63
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
Can alias tokens reference tokens in another file? #166
Comments
Thanks for raising this. I completely agree that this is something the spec needs to be more explicit about. I think this relates closely to the discussion in #123 - i.e. should the spec be explicit about how multiple token files are processed and their contents are merged. For example, what happens if As I proposed there, I wonder whether we ought to also think about some kind of include or import mechanism. While we'd still need to figure out exactly how those included files are processed and merged, it could provide a more convenient experience for end users. Specifying muliple files in a specific order for a CLI like your In both cases, the people would also need to understand which files to pick and in which order. 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 Remote aliasesI’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 {
"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 |
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
, anddark.json
.global.json
light.json
dark.json
You combine them with something like this:
On their own,
light.json
anddark.json
are useless; they requireglobal.json
to make sense. My open-ended question is: arelight.json
anddark.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 withoutglobal.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.
theoretical-token-tool
will decide to accept those invalid files anyway, which will end up hurting interoperabilitylight.
ordark.
to all of their themed tokens, and then strip that prefix later when exporting to another format like CSSglobal.json
in bothlight.json
anddark.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.
The text was updated successfully, but these errors were encountered: