• Stars
    star
    173
  • Rank 219,590 (Top 5 %)
  • Language
    JavaScript
  • Created over 2 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Set of design tokens and a custom properties parser for prototyping

Design Tokens CLI

A design-tokens-format-adhering token transformation CLI (Command Line Interface).

Supports

  • Converting from design tokens in the standard JSON format...
  • ...to CSS (custom properties)
  • ...to Sass (scss) variables
  • ...to ES modules
  • ...to JSON (flattened to name/value pairs)
  • (Chained) token reference resolution
  • Reference resolution between separate tokens files in one transform
  • Reference resolution between separate tokens between separate transforms
  • Composite tokens ($values as objects)
  • *.tokens.json and *.tokens file types
  • Concatenation of separate token files under a single name

Getting started

Installation

Install the CLI globally using npm:

npm i -g design-tokens-cli

Configuration

Transformations are defined using a master config file. Here is a configuration with just one transform:

{
  "transforms": [
    {
      "from": "origin/tokens",
      "to": [
        {
          "as": "scss",
          "to": "destination/scss"
        },
        {
          "as": "css",
          "to": "destination/css"
        },
        {
          "as": "mjs",
          "to": "destination/js"
        }      
      ]
    }
  ]
}

Formats

The to array for each transformation lists the formats you want and their respective output folders. The as property must be the file extension for the output format. Both mjs and js output ES modules.

Running the transforms

Either you explicitly define the path to the config fileโ€ฆ

designTokens transform ./path/to/my-config.json

โ€ฆor you leave that argument out and the CLI will look for a tokens.config.json file anywhere in the current working directory:

designTokens transform

File names and groups

By convention, the file name for each tokens file found in from represents the top level "group" name for those tokens. In practice, this means converting /origin/tokens/color-greyscale.tokens.json will result in a set of tokens each prefixed with color-greyscale-. For js/mjs transformations the file would look something like the following, with color-greyscale converted into camel case:

export const colorGreyscale = {
  'color-black': '#000000',
  'color-blanche': '#ffffff',
}

globalPrefix

You can prefix all tokens with a common string using the top-level globalPrefix property in your config file. Using...

"globalPrefix": "token-"

...color-brand-light becomes token--color-brand-light.

Concatenation

If the transform has a name property, multiple files found in the from origin will be concatenated into a single output file of that name. Take the following example:

{
  "transforms": [
    {
      "name": "layout",
      "from": "origin/tokens",
      "to": [
        {
          "as": "css",
          "to": "destination/css"
        }   
      ]
    }
  ]
}

Where there are breakpoints.tokens.json and sizes.tokens.json files in /origin/tokens, their tokens will be placed in the same /destination/css/layout.tokens.css file. Without the name, separate breakpoints.tokens.css and sizes.tokens.css files would be made.

More Repositories

1

inclusive-design-checklist

Aims to be the biggest checklist of inclusive design considerations ever
JavaScript
2,713
star
2

fukol-grids

CSS
1,468
star
3

REVENGE.CSS

A CSS bookmarklet that puts pink error boxes (with messages in comic sans) everywhere you write bad HTML.
CSS
828
star
4

forceFeed

JavaScript
518
star
5

bruck

A prototyping system built with web components and the Houdini Paint API
JavaScript
511
star
6

watched-box

JavaScript
327
star
7

Community-Icon-Font

To create a collaborative font using SVG
196
star
8

inclusive-menu-button

A keyboard and screen reader accessible ARIA menu button implementation.
JavaScript
191
star
9

cel-animation

A Sass @mixin for creating traditional frame-based animations, especially with SVG
CSS
155
star
10

beadz-drum-machine

A quantum, polymetric drum machine.
Vue
141
star
11

on-demand-live-region

JavaScript
128
star
12

ga11ery

Eleventy theme for showcasing photography and web comics
HTML
97
star
13

cress

JavaScript
83
star
14

readabilityCheckerCLI

A node CLI for checking how readable content is. Accepts a URL or HTML file.
JavaScript
70
star
15

xiao

A tiny, accessible, browser-driven single-page routing system.
JavaScript
56
star
16

react-sortable-table-demo

See the article here: https://inclusive-components.design/data-tables
JavaScript
40
star
17

css-scopulation-enterprise-max-ai

JavaScript
29
star
18

react-theme-switch

JavaScript
27
star
19

Inclusive-Components

Resources for the inclusive components blog (inclusive-components.design)
26
star
20

css-error-property-style

18
star
21

wai-aria-web-component

A "disclosure" (show/hide) web component using ARIA and built with Polymer
CSS
13
star
22

inclusive-inline-editable

JavaScript
9
star
23

buttonlike

A jQuery plugin for making clickable elements more accessible
JavaScript
8
star
24

typical-theme-wordpress

A responsive, resolution independent Wordpress theme with microdata support
CSS
8
star
25

AMA

Ask me anything
6
star
26

Squib-Font

A free font licensed under the Open Font License
6
star
27

heydonworks

HeydonWorks Wordpress theme
CSS
3
star
28

Accessible-Designer-Examples

Examples of creative, accessible design concepts.
HTML
3
star
29

ga11ery-michael

HTML
2
star
30

ga11ery-example

HTML
2
star
31

niace-stories-app

The alpha application for NIACE.
JavaScript
1
star
32

Redfoir

Freedom of Information Timeline Project
JavaScript
1
star