13.7.1 • Published 5 months ago

@maggioli-design-system/design-tokens v13.7.1

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

@maggioli-design-system/design-tokens

Generates design tokens for colors and other type of agnostic tokens targeted on specific plaforms, like web, Dart, Android or iOS formats.

This library is based on Adobe Leonardo and Amazon Style Dictionary.

Installation

Install the component via npm by running the following command:

npm i @maggioli-design-system/design-tokens

This package works also with yarn:

yarn add @maggioli-design-system/design-tokens

Generate Custom Palette

you can generate custom palettes via cli command, it takes a configuration file to create palettes

Usage

npx magma-design-tokens

Options

OptionAliasDescription
--config [configFile]-cPath to configuration file if not respect default naming
--outDir [dirPath]-dPath destination for generated palettes
--generate [platform]-gOutput format for palette, choose one or more between css, tailwind, dart
--export-tokens-texport palette as JSON design tokens format
--outTokensDir [tokensDir]Directory path for JSON tokens, required if --export-tokens is presents

Configuration file

You can include configuration in a configuration file or a field in package.json named magma-design-tokens

Naming convention

Naming standard for configuration file:

  • .magma-design-tokensrc.json
  • .magma-design-tokensrc.js
  • .magma-design-tokensrc.cjs
  • .magma-design-tokensrc.mjs
  • .config/magma-design-tokensrc
  • .config/magma-design-tokensrc.json
  • .config/magma-design-tokensrc.js
  • .config/magma-design-tokensrc.cjs
  • .config/magma-design-tokensrc.mjs
  • magma-design-tokens.config.js
  • magma-design-tokens.config.cjs
  • .magma-design-tokens.config.mjs

If you change configuration file name you need to set with --config option

Configuration

Basic config

{
  "colors": [
    { "color": "#94a3b8", "name": "tone.slate" },
    { "color": "#EA3464", "name": "label.amaranth" }
  ]
}

You can export different color in different output file defining export field

{
  "colors": [
    { "color": "#94a3b8", "name": "tone.slate", "export": ["tones"] },
    { "color": "#EA3464", "name": "label.amaranth", "export": ["label"] }
  ]
}

You can choose the ratio with which to generate the color scale with ratios field

{
  "colors": [
    { "color": "#94a3b8", "name": "tone.slate", "ratios": "tone" },
    { "color": "#EA3464", "name": "label.amaranth", "ratios": "v1" }
  ]
}

NOTE: there are four different ratios as follow value contrast

{
  "v1": [
      1.05, 1.1, 1.17, 1.24, 1.32, 1.41, 1.51, 1.65, 1.9, 2.25, 2.7, 3.3,
      4, 4.8, 5.75, 7, 8.5, 10.3, 12.45, 15
    ],
  "v2": [1.09, 1.22, 1.42, 1.82, 2.57, 3.71, 5.13, 6.71, 8.75, 10.29],
  "default": [1.09, 1.22, 1.42, 1.82, 3.29, 5.13, 6.71, 8.45, 10.29, 17.22],
  "tone": [1.05, 1.1, 1.24, 1.47, 2.54, 4.83, 7.56, 10.31, 14.68, 16]
}

Cli example

  • takes ./color.js as configuration file
npx design-tokens --config ./color.js
  • export palette only on css format
npx design-tokens --generate css
  • export palette on css and tailwind format
npx design-tokens --generate 'css, tailwind'
13.7.1

5 months ago

13.7.0

8 months ago

13.5.0

11 months ago

13.6.0

8 months ago

13.6.1

8 months ago

13.4.0

11 months ago

13.3.1

1 year ago

13.3.0

1 year ago

13.2.0

1 year ago

13.0.0

1 year ago

12.0.1

2 years ago

12.0.0

2 years ago

10.7.0

2 years ago

11.0.0

2 years ago

11.0.1

2 years ago

10.6.0

2 years ago

10.6.1

2 years ago

10.6.2

2 years ago

10.5.0

3 years ago

10.2.0

3 years ago

10.4.0

3 years ago

10.0.0

3 years ago

9.0.0

3 years ago

8.0.0

3 years ago

7.0.0

3 years ago

6.4.1

4 years ago

6.4.0

4 years ago

5.0.5

4 years ago

5.0.3

4 years ago

5.0.2

4 years ago

5.0.0

4 years ago

6.1.0

4 years ago

6.0.0

4 years ago

6.1.1

4 years ago

4.2.1

4 years ago

4.2.0

4 years ago

4.1.0

4 years ago

4.0.1

4 years ago

4.0.2

4 years ago

4.0.0

4 years ago

3.0.0

4 years ago

2.6.0

4 years ago

2.5.1

4 years ago

2.5.0

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.2

4 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.3.0

5 years ago

1.2.2

5 years ago