Re: [community-group] Legacy color (#137)

Also, a few notes amended to [@kaelig’s updated proposal](https://github.com/design-tokens/community-group/issues/137#issuecomment-2116168184):

## Channel definition

It’s been raised “what are the channel values and how are they defined?” For example, is `"colorSpace": "srgb", "channels": [64, 0, 128]` valid? For clarity, we’ll use the same definitions as [CSS Color Module 4](https://www.w3.org/TR/css-color-4/)’s `color()` function, which [defines colorspaces and values in §10](https://www.w3.org/TR/css-color-4/#predefined), such as `srgb` channels being `red`, `blue`, `green` in that order, and accepting only `[0, 1]` values.

The only clarification we’d make is that **percentages wouldn’t be supported**, since there is no percentage type (yet). Just normalize to `1` (`0%` = `0`, `100%` = `1`).

## Aliasing

Also a question of “what is aliasable” is inevitable, and we’d like to propose **Any sub-value is aliasable if it resolves to a valid $type.**. For example:

#### ✅ Valid: Entire `$value`

This is supported today, of course

```json
{
  "action": {
    "$value": "{color.blue.500}"
  }
}
```

#### ✅  Valid: Aliasing part of a value is valid only if it aliases a valid existing $type

This is consistent with current docs for $type:

> If the token’s value is a reference, then its type is the resolved type of the token being referenced.

In other words, this seems allowed by current usage of spec.

Further, referencing _within_ `"channels"` should be allowed because even though there is no array of number types, individual values are all $type: number as well. Just as though [gradient tokens’ stops](https://design-tokens.github.io/community-group/format/#gradient) aren’t a $type in and of themselves, they are allowed to alias color and number tokens.

```json
{
  "action": {
    "$type": "color",
    "$value": {
      "colorSpace": "oklch",
      "channels": ["{lightness.70}", 0.153, 246.18],
      "alpha": "{alpha.100}",
      "hex": "#3ca5f7"
    }
  }
}
```

#### ❌ Invalid: Aliasing part of a value that is not a valid $type

Since there is no valid types that `"colorSpace"` or `"channels"` could resolve to, they’re invalid. Further, since string types are not supported, and colors are now objects, technically `"hex"` could not resolve to a valid $type, either.

```json
{
  "action": {
    "$type": "color",
    "$value": {
      "colorSpace": "{colorSpace.oklch}",
      "channels": "{channels.color.blue.500}",
      "alpha": 1,
      "hex": "{color.blue.500}"
    }
  }
}
```

#### ❌ Invalid: Partially aliasing just a part of another $type: color’s value

This is another proposal entirely: https://github.com/design-tokens/community-group/issues/148

```json
{
  "action": {
    "$type": "color",
    "$value": {
      "colorSpace": "oklch",
      "channels": [0.7, 0.153, 246.18],
      "alpha": 1,
      "hex": "{color.blue.500.$value.hex}"
    }
  }
}
```

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


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

Received on Thursday, 13 June 2024 20:56:26 UTC