prefix-by

This parser helps you prefix the name of your collections, groups and tokens from your SDTF token tree.

Interface

interface parser {
  name: 'prefix-by';
  options: ({
    all: string
  } | 
  {
    group?: string;
    collection?: string;
    token?: string;
  }) & { applyTo?: SDTFQuery }
}

Options

ParameterRequiredTypeDefaultDescription

all

false

string

Select all collections, groups and tokens in your SDTF token graph.

group

false

string

Select all groups in your SDTF token graph.

collection

false

string

Select all collections in your SDTF token graph.

token

false

string

Select all tokens in your SDTF token graph.

applyTo

false

| { collection: string | true }
| { group: string | true }
| { token: string | true }
| SDTFQuery

The selection where to apply the transformation. collection, group, token take a Regex string or true to select anything of the kind. An SDTFQuery can be used for advance use cases.

Basic usage: Prefix color tokens

{
  "spacing": {
    "1": {
      "$type": "dimension",
      "$value": {
        "default": {
          "value": 4,
          "unit": "px"
        }
      }
    }
  },
  "colors": {
    "black": {
      "$type": "color",
      "$value": {
        "default": {
          "model": "hex",
          "hex": "#000000",
          "alpha": 1
        }
      }
    }
  }
}

Last updated