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

I haven't written a translator, so admittedly I'm not the best judge of computational complexity. That said ...

So far as I can tell in the current spec, for single-value (ie not composite) tokens, the `$value` of the token will always be:
1. A hex code, which is a string that always starts with a `#` followed by 3,4,6, or 8 alphanumeric characters 0-9,a-f, A-F.
2. A unitless value, which can be:
    a. A string that starts with a non-numeric character and contains any numeric- or non-numeric character afterwards (ie, a string like `"bold"`)
    b. A string that starts with numeric characters and contains only numeric characters and/or a single decimal (ie a string that can be cast into a float or int, like `"500"`)
3. A value + unit, which is a string that starts with numeric characters and/or a single decimal, followed by any number of alphabetic characters. (ie `"200ms"`)

In the case of 3, it seems pretty straightforward to split the string on the first non-numeric character, resulting in the value and unit.

The parser will need to use a regular expression to handle these cases, but it seems computationally cheap. To me, it's a good tradeoff for the better ergonomics of writing/editing.

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


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

Received on Sunday, 4 December 2022 21:17:08 UTC