design-tokens / community-group

This is the official DTCG repository for the design tokens specification.
https://tr.designtokens.org
Other
1.56k stars 63 forks source link

How to define negative zero in a design tokens file #184

Closed romainmenke closed 1 year ago

romainmenke commented 2 years ago

-0 vs. 0 is useful in calculations.

But JSON.stringify(-0) removes the sign : 0 I think the specification needs to adopt specific serialisation and parsing steps for edge cases likes these.

Tools will need to implement custom JSON serialisers and parsers if this is to be done correctly.

PavelLaptev commented 2 years ago

@romainmenke can you provide an example for -0 usage?

romainmenke commented 2 years ago

calc(1 / -0)

c1rrus commented 2 years ago

I'm really curious now. I've never come across the concept of negative zero before. What would be a practical application of calc(1 / -0) in a UI / deisgn system? And what would be the result of that calculation? Infinity? Negative infinity?

In any case, I suppose this could be a limitation of our choice to build on top of JSON, so at a minimum we might want to call that out in the spec.

romainmenke commented 2 years ago

What would be a practical application of calc(1 / -0) in a UI / deisgn system

I think that is the wrong way to look at this :) The current direction/trend of design tokens is to be a subset of different platform capabilities.

This is just one aspect where the design tokens file format will be able to do less than one of the target platforms.

When teams decide to adopt design tokens they should be aware of all the limitations that are signing up for.

at a minimum we might want to call that out in the spec.

That would be great, but it doesn't scale well, there are so many aspects where design tokens just can't match the capabilities of individual platforms.

Maybe a general notice is better?

jeromefarnum commented 2 years ago

If no meaningful example of how -0 is useful for designing and building products, and why it should be captured in design tokens, can be given then it seems, to me, there isn’t much risk in not including it in the spec.

romainmenke commented 2 years ago

there isn’t much risk in not including it in the spec.

I agree.

kevinmpowell commented 1 year ago

@romainmenke any objections to closing this one?

romainmenke commented 1 year ago

Nope :)

I only left it open in case @c1rrus wanted to add a note to the specification about certain platform specifics like this one that can not be represented.