Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@cobalt-ui/core

terrazzoapp4.7kMIT1.12.0TypeScript support: included

Parser/validator for the Design Tokens Community Group (DTCG) standard.

design tokens, design tokens community group, design tokens format module, dtcg, cli, w3c design tokens, design system, typescript, sass, css, style tokens, style system, linting, lint

readme

@cobalt-ui/core

Parser/validator for the Design Tokens Community Group (DTCG) standard.

For the CLI, use @cobalt-ui/cli.

Install

npm install @cobalt-ui/core

Usage

Parse a tokens.json file into a JS object

import co from "@cobalt-ui/core";

const designTokens = {
  color: {
    red:   {$type: "color", $value: "#e34850"},
    green: {$type: "color", $value: "#2d9d78"},
    blue:  {$type: "color", $value: "#2680eb"},
  },
};

const {errors, warnings, result} = co.parse(designTokens);
Name Type Description
result Token[] Flattened array of all parsed tokens in the schema (this may be incomplete if errors present)
errors string[] | undefined If present, unrecoverable errors were encountered (you should probably throw with these messages).
warnings string[] | undefined If present, the parser found schema issues that are likely undesirable, but the schema is still usable (you should probably show the user).

changelog

@cobalt-ui/core

1.12.0

Minor Changes

  • #352 Thanks @drwpow! - Remove APCA contrast algorithm

1.11.3

Patch Changes

  • Aliases don’t need $types

1.11.2

Patch Changes

1.11.1

Patch Changes

1.11.0

Minor Changes

Patch Changes

1.10.2

Patch Changes

1.10.1

Patch Changes

1.10.0

Minor Changes

Patch Changes

1.9.0

Minor Changes

Patch Changes

1.8.1

Patch Changes

1.8.0

Minor Changes

Patch Changes

1.7.3

Patch Changes

1.7.2

Patch Changes

1.7.0

Minor Changes

Patch Changes

1.6.1

Patch Changes

1.6.0

Minor Changes

  • #119 1a76946 Thanks @drwpow! - Breaking change: don’t automatically convert colors to hex

1.5.0

Minor Changes

1.4.3

Patch Changes

1.4.0

Minor Changes

1.3.1

Patch Changes

  • #61 949481f Thanks @drwpow! - Replace better-color-tools with culori for faster, more accurate color operations

1.3.0

Minor Changes

1.2.0

Minor Changes

1.1.3

Patch Changes

1.1.2

Patch Changes

1.1.1

Patch Changes

1.1.0

Minor Changes

  • #30 482f5cd Thanks @drwpow! - Deprecate Figma sync CLI and core functionality (in favor of Tokens Studio support)

  • #30 482f5cd Thanks @drwpow! - Add Tokens Studio support

Patch Changes

1.0.0

1.0 Release! 🎉 While the only significant change from 0.x to 1.x is the changing of a few font types, this is more of a symbolic release than an actual semver one. The original plan was to wait to release 1.0 when the W3C Design Token spec was finalized. But who knows when that will be? And so this just marks a journey into building a more stable design token foundation, wherever the current spec is at.

Proper semver will still be respected, so while some spec changes are non-breaking, any breaking change from now on will get proper major bumps for everything.

Minor Changes

  • 526777f: Add fontFamily, fontWeight, fontName, and number types, remove font type

Patch Changes

0.7.4

Patch Changes

  • 91ff661: Update better-color-tools

0.7.3

Patch Changes

0.7.2

Patch Changes

  • Update svgo to v3

0.7.1

Patch Changes

  • 9edc9d9: Fix token._original.$extensions.modes shallow clone bug
  • Updated dependencies [9edc9d9]

0.7.0

Minor Changes

  • e50c864: Add strokeStyle and border support in plugins, improve validation in core

0.6.4

Patch Changes

  • Bump @cobalt-ui/utils version

0.6.3

Patch Changes

  • e0a2176: Fix type exports

0.6.2

Patch Changes

0.6.1

Patch Changes

  • ed21d56: Bump deps, add config type to docs
  • Updated dependencies [a2a9d62]
  • Updated dependencies [ed21d56]

0.6.0

Minor Changes

  • 07bc365: Update to Feb 2022 version of the Design Tokens format

0.5.0

Minor Changes

  • 61a7892: Add ability to load JSON from npm package

0.4.0

Minor Changes

  • 8845084: Use kebab-case properties for typography tokens, allow all CSS properties

Patch Changes

  • Fix token value 0

0.3.4

Patch Changes

  • c69a62e: Fix nested group bug

0.3.3

Patch Changes

  • 8f5025d: Update package description

0.3.2

Patch Changes

  • Bump deps

0.3.1

Patch Changes

  • 1170d8b: Improve value normalization for duration, dimension, and transition token types

0.3.0

Minor Changes

  • 8d05fe8: Add Figma sync, make some breaking API changes

Patch Changes

0.2.0

Minor Changes

  • 26bfb4c: Convert to JSON, follow design tokens spec

Patch Changes

0.1.0

Minor Changes

  • 5748e72: Use JSON to align with the Design Tokens W3C spec

Patch Changes