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

Aliasing with layered shadow support #250

Open nclsndr opened 2 months ago

nclsndr commented 2 months ago

I just noticed an issue with #246

The spec does not describe how aliasing should be supported along the introduction of the optional array-based value.

Let's take

{
  "simpleShadow": {
    "$type": "shadow",
    "$value": {
      "color": "#000000",
      "offsetX": "1px",
      "offsetY": "1px",
      "blur": "2px",
      "spread": "4px"
    }
  },
  "layeredShadow": {
    "$type": "shadow",
    "$value": [
      {
        "color": "#000000",
        "offsetX": "1px",
        "offsetY": "1px",
        "blur": "2px",
        "spread": "4px"
      },
      {
        "color": "#CCCCCC",
        "offsetX": "2px",
        "offsetY": "2px",
        "blur": "6px",
        "spread": "6px"
      }
    ]
  }
}

Following the current aliasing rules, I guess we allow:

{
  "referenceToSimpleShadow": {
    "$value": "{simpleShadow}"
  },
  "referenceToLayeredShadow": {
    "$value": "{layeredShadow}"
  }
}

But, do we intend to allow "partial aliasing" within the array value 👇 ?

  "layeredShadow": {
    "$type": "shadow",
    "$value": [
      "{simpleShadow}",
      {
        "color": "#CCCCCC",
        "offsetX": "2px",
        "offsetY": "2px",
        "blur": "6px",
        "spread": "6px"
      }
    ]
  }

I dunno to what extend this feature might be appealing for users, opinions here?

Yet, the current state of having the "shadow" type allowing both object and array based values makes the adoption of the feature almost impossible due to inconsistent spread/merge behaviours required to compute. I described a solution addressing this in #239 - here and here

I guess that also relates to #241 - where it feels we'd need some simple rules we apply accros types with similar requirements.