figma-plugin icon indicating copy to clipboard operation
figma-plugin copied to clipboard

Support types at a group level

Open six7 opened this issue 2 years ago • 0 comments

The W3C Spec outlines inheritance for types at a group level. Meaning, the following JSON produces tokens of type color:

Ability to define types at a group-level

{
  "fg": {
    "type": "color",
    "default": {
      "value": "{colors.black}",
    },
    "muted": {
      "value": "{colors.gray.700}",
    },
    "subtle": {
      "value": "{colors.gray.500}",
    }
  }
}

I could then make individual overrides further down the line

Individual types override inherited type

{
  "fg": {
    "type": "color",
    "default": {
      "value": "{colors.black}",
    },
    "muted": {
      "value": "{colors.gray.700}",
    },
    "subtle": {
      "value": "{colors.gray.500}",
    },
    "large": {
      "value": "12",
      "type": "dimension"
    },
  }
}

Editing tokens that have no self-defined type

Editing such a token in the UI should not introduce a type property as long as the type was inherited. Meaning, if for the above example, I edited fg.default - the output should not include a type: color on the token fg.default, but rather it should stay in the group level.

If a token has a self-defined type, then we keep it there.

Obviously in the future the syntax would be $type and $value, but we should support that behavior of defining types a level above as well.

six7 avatar Apr 08 '22 07:04 six7