Re: [community-group] Pre-defined composite type for refering color modifications (e.g. rgba) (#88)

Hello 👋 Thanks very much for all the hard work you've placed into this spec, and specifically to @c1rrus for sharing at the Into Design Systems conf earlier today! 

I want to pick up on [his comment above](https://github.com/design-tokens/community-group/issues/88#issuecomment-1073374383) about generalising the approach to handle transformation of any type of value, not just colours.

I think that would be amazing, and would support how we're currently working. In our internal token graph representation, we support intermediate transform nodes between token references in much the same way that is being proposed here, although our syntax is a bit...verbose:

```json
{
  "opacity": {
    "half": {
      "value": 0.5
    },
  },
  "color": {
    "red": {
      "value": "#F00"
    },
  },
  "system": {
    "color": {
      "errorMuted": {
        "value": {
          "ref": "color.red",
          "transforms": [
            {
              "type": "alpha",
              "args": {
                "alpha": {
                  "ref": "opacity.half"
                }
              }
            }
          ]
        }
      }
    }
  }
}
```

"alpha" here is just a function we registered with some named, typed arguments and a return type so we can validate the connections between nodes. I imagine there are lots of super useful out-of-the-box transformations that everyone would find useful, but the ability to register arbitrary custom transform functions in the parsing/resolution API would also be super useful. 

One difference that I think could be important between your proposed schema and the one I present here is that, in the example above, the `transforms` are children of (rather than sibling to) the token's `value` entry. In this way it's clear, to me at least, that if I create a reference to the `errorMuted` token's value, I'm not just referencing its color (`color.red` or `#F00`) but its post-transformation value (`rgba(255 0 0 / 0.5)`).

Thanks very much again! Looking forward to following this project

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


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

Received on Tuesday, 24 May 2022 17:24:36 UTC