Re: [community-group] Split units and values in type definitions (#121)

@romainmenke said:

> My main concern is that regexp will be used or that we will see everyone writing custom parsers for these. 

I agree with this concern. As written, I think the spec will need to define the grammar for each string field. 

For example, dimensions are currently limited to `px` and `rem`. I think this implies parsing with CSS logic to [consume numeric tokens][1] and for [converting strings to numbers][2]. The same applies to [durations][3], where the spec choses `ms`, but leaves open the ability to define other units later. 

If we separate the number and units, we can fall back on JSON's number parsing. For example: `$"value": {"number": -1.345e-2, "unit": "rem"}` versus  `"$value": "-1.345e-2rem"`. 

[1]: https://www.w3.org/TR/css-syntax-3/#consume-numeric-token
[2]: https://www.w3.org/TR/css-syntax-3/#convert-string-to-number
[3]: https://tr.designtokens.org/format/#duration

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


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

Received on Thursday, 21 July 2022 16:33:05 UTC