Re: [community-group] Computed Token Values (#81)

Computed values is something that's been asked for a number of times, so I'd certainly agree that it deserves consideration. I would also agree that it's too much for the initial, MVP spec. I can imagine there's a fair bit of complexity when you get into the weeds of it - for instance, if we had a `tint` function, our spec would also need to specify a detailed algorithm of how to do that in order to ensure that it's implemented consistently across different tools and interoperability of design token files is preserved.

Also, where do you draw the line? I can imagine use-cases for some arithmetic, so it might be tempting to allow `+`, `-`, `/` and `*`, but if you keep going down that road, would you end up creating a sort of programming language? Maybe that's what the community (eventually) needs, but I imagine that will be significantly more work to specify and implement than the static format we have so far.

My hope is that, in the meantime, tools will fill that gap. Perhaps someone will make a token pre-processor tool (e.g. something along the lines of what SASS is to CSS)? Just because today's tools tend to either extract tokens from elsewhere (e.g. visual design tools), or translate tokens into other languages (e.g. StyleDictionary and Theo) doesn't mean there couldn't one day be tools that read a token file, manipulate it in someway and then write out a different token file. ;-)

-----

>It looks like this concept is already underway in the dimension's suggestion to use rem. Isn't that really setting the value relative to an arbitrary master unit that only has value in the Web?

Perhaps. I never really thought of it that way. To me `rem` (and other relative units in CSS) are "just" units for length values, but unlike absolute ones like `px`, they happen to relative to something in the user's settings. To put it another way, there are 2 distinct concepts there and `1rem` is _not_ the same thing as `16px`. I therefore don't think of `rem` as some kind of arithmetic shorthand for 16x a `px` value.

It's also worth noting that the concept of default-font-size-relative length values is _not_ unique to the web. Android has it too, they just have a different name of it: `sp` and happen to have defined it as 1/16 of the default font size. In other words, `16sp` in Android is the _exact_ equivalent of `1rem` in CSS. For our format we could have gone with either of those or made up our own thing, but decided to borrow from CSS and go with `rem` as the unit for default-font-size-relative length values.


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


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

Received on Monday, 13 December 2021 17:09:33 UTC