Open nclsndr opened 2 months ago
What struck me was the level of repetition we all suffer from.
Iām just asserting my opinion here, but I think ideally this is how Open Source works? Having more implementations, and more options, only benefit users.
Take YAML, for instance. It has a central specification defined of how it should work. But the group that wrote that specification arenāt responsible for porting it into every programming language; thatās done by hundreds (if not thousands) of individual developers. The end result is, yes, thereās a lot of ārepetition.āĀ But each individual implementation works extremely well for the users itās serving.
I always view this as a feature, not a bug. Anyone being able to create their own library and open source it is always a great thing. And the community is always benefitted by more open source projects, not fewer. OSS is a lot of work! And thereās a real resource cost to trying to centralize implementation and put the burden on the standards committee, rather than distributing the load across developers, with many people being able to do part of the lifting.
But that may just be my viewpointāI just donāt see GitHub projects ācompetingā with one another. I all view it under the same umbrella of collaboration and mutual sharing. That is, as long as itās open-licensed and thereās not money/profit involved š
Taking this step back, I feel like we would all benefit from a npm package that would host the types and the most implementation-agnostic definitions.
I do agree with this though! Though maybe not an npm package, since that only benefits JS/TS tooling (and Iāve seen Rust, Go, and Python DTCG tools, to name a few).
Iād love to personally see an official JSONSchema implementation, hosted by the committee. I think thatās a good balance of:
IIRC there are some current barriers to this working fully with the current design, but this may be achievable in the near future? But I havenāt looked into it in a while, admittedly.
Thanks for the inputs @drwpow
Having more implementations, and more options, only benefit users.
Completely agree. What I miss as a DTF tool developer is a source of truth in code, I could read and would speed me up understand the changes in the spec without reading the "human" version. Having the defs through a package manager is cherry on the cake.
Though maybe not an npm package, since that only benefits JS/TS tooling
My first thought was to have a repo per language, JS/TS was my starting point.
Iād love to personally see an official JSONSchema implementation
That's exactly my next step into the library, I'll explore it along the week.
@drwpow, update on the JSON Schema investigation with this PR
On the bright side: I managed to get descent JSON Schemas for each type and their values. It passes with aliasing for top level and nested refs.
On the downside, I don't envision a way to generate the JSON Schema for the whole tree. The issue is quite simple: we don't have a discriminator - like $type if it was required - while traversing the token tree. Hence, it becomes easy to produce false positives.
So, I feel like the JSON Schema is a step for the bare definitions. Then, each language will still need to build up the validation business rules for:
border.color
points to a color tokenIs a shared test suite something that could help?
Each test could consist of:
Then tools could run their implementation against the test suite and check the result of parsing against the expected representation that matches their domain.
For all things web we have the web platform tests.
For my own work on CSS tooling I also try to publish and maintain shared tests so that other packages can more easily have correct implementations. (e.g. https://github.com/romainmenke/css-tokenizer-tests)
Such shared tests reduce the amount of work that each project needs to do and makes it easier to have interop.
Is a shared test suite something that could help?
That would definitely help. I was thinking about a seed at first, but the benefit was quite small. Structured the way you propose would produce way more value for users. I'll think about it moving forward, any help is welcomed.
I didn't know about the Web Platform Tests initiative! Thanks for sharing. Even though the design tokens are pretty far from being native browser features, it still gives inspiration.
Lately, I reviewed and benchmarked many of the OSS solutions for working with DTF tokens (Tokens Studio, Cobalt/Terrazzo, Design Token Validator from Anima,...). Side note: I focused on web tech, JS and TS.
What struck me was the level of repetition we all suffer from. 100% of any lib that parses DTF tokens needs to start by defining cumbersome types and primitives. Then parse and implement some sort of visitor pattern for both the tokens and their aliases. I can tell you we almost all have made mistakes interpreting some decisions or missing an update from the spec at some point š.
Taking this step back, I feel like we would all benefit from a npm package that would host the types and the most implementation-agnostic definitions. I wrote the package design-token-format-module in late 2022, by that time it was not clear where it could be used and what type of APIs it could offer. With the last version, targeting the Live Draft spec, I tried to focus on the most non-debatable piece for anyone to pick from.
Questions for library/tool authors:
Question for DTCG committee: Would it make sense for the design-tokens organization on GitHub to host some repositories with the code implementing the spec for different languages / platforms? If so, I'd be happy to transfer the npm namespace to the community.