Re:Design Token-Based UI Architecture
by spankalee on Tuesday December 17, 2024 @11:32PM
(#42448136)
Why does the format use $-prefixed keys? That's pretty weird as far as JSON schemas go.
[ Parent
| on HN ]
The reserved prefix $ answers the question: "how can we let people name, structure, and nest their tokens however they want, while future proofing the spec?". More on that rationale: https://tr.designtokens.org/format/#character-restrictions
As for the "pretty weird" aspect — it's definitely uncommon but it's been seen before: the $ prefix is also used by the JSON Reference ($ref): https://www.ietf.org/archive/id/draft-pbryan-zyp-json-ref-01... — and just in case, we ran this syntax past Ben Hutton (inventor of JSON Schema) to ensure we weren't doing anything silly.
Re:Design Token-Based UI Architecture
by spankalee on Wednesday December 18, 2024 @12:15AM
(#42448286)
You can usually do this by only being additive with the spec, and by never mixing user-defined keys and spec-defined keys in the same object.
I've only ever seen $ used before with meta properties that work across all schemas like the $ref you mentioned and $schema.
There are multiple ways to solve this, we've explored a few and we found that clearly differentiating user inputs from the spec keys was the right way to go for this use-case and our audience.
That said, there definitely are other valid ways to solve it.