Skip to content

Latest commit

 

History

History
76 lines (53 loc) · 2.37 KB

README.md

File metadata and controls

76 lines (53 loc) · 2.37 KB

Codemagic build status

What's design-tokens?

design-tokens is a command line tool to translate design tokens into Swift source code. This package follows the Design Tokens Format specifications by the Design Tokens Community Group for the translation.

Install

Compile sources

To compile the binary, run the following command in the directory of the cloned repository:

swift build -c release design-tokens --show-bin-path

The command will output the path of the built binary.

Alternatively, you can run the tool directly without exporting a binary.

swift run -c release design-tokens

Configuration

The tool must be configured via a configuration manifest JSON file to run, and generate an output.

Usage

The command line tool provides two commands to initialize a configuration manifest, and to generate output for the specified design token files.

init

Scaffolds a configuration manifest file with default parameters. To scaffold a configuration, the path to the input design token file is required.

design-tokens init -i design-tokens.json

generate

Generates the output as configured in the configuration manifest.

design-tokens generate

Output

The command line tool generates source code as the resulting output of the design tokens translation. The format of the output can be customized on a per-token basis.

Example

{
  "input": "design-tokens.json",
  "colors": {
    "formats": [
      "SwiftUI",
      "UIKit"
    ],
    "output": "Output/Colors/"
  },
  "dimensions": {
    "output": "Output/Dimensions/"
  }
}

Using the manifest above, the generate command will generate SwiftUI, and UIKit source code for the color tokens in the Output/Colors/ directory. It will also generate source code (default) for the dimension tokens in the Output/Dimensions/ directory.