0.7.1 • Published 7 months ago

@pluralsight/design-tokens v0.7.1

Weekly downloads
-
License
Apache 2.0
Repository
github
Last release
7 months ago

Basic Style Dictionary

This example code is bare-bones to show you what this framework can do. If you have the style-dictionary module installed globally, you can cd into this directory and run:

style-dictionary build

You should see something like this output:

Copying starter files...

Source style dictionary starter files created!

Running `style-dictionary build` for the first time to generate build artifacts.


scss
✔︎  build/scss/_variables.scss

android
✔︎  build/android/font_dimens.xml
✔︎  build/android/colors.xml

compose
✔︎ build/compose/StyleDictionaryColor.kt
✔︎ build/compose/StyleDictionarySize.kt

ios
✔︎  build/ios/StyleDictionaryColor.h
✔︎  build/ios/StyleDictionaryColor.m
✔︎  build/ios/StyleDictionarySize.h
✔︎  build/ios/StyleDictionarySize.m

ios-swift
✔︎  build/ios-swift/StyleDictionary.swift

ios-swift-separate-enums
✔︎  build/ios-swift/StyleDictionaryColor.swift
✔︎  build/ios-swift/StyleDictionarySize.swift

Good for you! You have now built your first style dictionary! Moving on, take a look at what we have built. This should have created a build directory and it should look like this:

├── README.md
├── config.json
├── tokens/
│   ├── color/
│       ├── base.json
│       ├── font.json
│   ├── size/
│       ├── font.json
├── build/
│   ├── android/
│      ├── font_dimens.xml
│      ├── colors.xml
│   ├── compose/
│      ├── StyleDictionaryColor.kt
│      ├── StyleDictionarySize.kt
│   ├── scss/
│      ├── _variables.scss
│   ├── ios/
│      ├── StyleDictionaryColor.h
│      ├── StyleDictionaryColor.m
│      ├── StyleDictionarySize.h
│      ├── StyleDictionarySize.m
│   ├── ios-swift/
│      ├── StyleDictionary.swift
│      ├── StyleDictionaryColor.swift
│      ├── StyleDictionarySize.swift

If you open config.json you will see there are 5 platforms defined: scss, android, compose, ios, and ios-swift. Each platform has a transformGroup, buildPath, and files. The buildPath and files of the platform should match up to the files what were built. The files built should look like these:

Android

<!-- font_dimens.xml -->
<resources>
  <dimen name="size_font_small">12.00sp</dimen>
  <dimen name="size_font_medium">16.00sp</dimen>
  <dimen name="size_font_large">32.00sp</dimen>
  <dimen name="size_font_base">16.00sp</dimen>
</resources>

<!-- colors.xml -->
<resources>
  <color name="color_base_gray_light">#ffcccccc</color>
  <color name="color_base_gray_medium">#ff999999</color>
  <color name="color_base_gray_dark">#ff111111</color>
  <color name="color_base_red">#ffff0000</color>
  <color name="color_base_green">#ff00ff00</color>
  <color name="color_font_base">#ffff0000</color>
  <color name="color_font_secondary">#ff00ff00</color>
  <color name="color_font_tertiary">#ffcccccc</color>
</resources>

Compose

object StyleDictionaryColor {
  val colorBaseGrayDark = Color(0xff111111)
  val colorBaseGrayLight = Color(0xffcccccc)
  val colorBaseGrayMedium = Color(0xff999999)
  val colorBaseGreen = Color(0xff00ff00)
  val colorBaseRed = Color(0xffff0000)
  val colorFontBase = Color(0xffff0000)
  val colorFontSecondary = Color(0xff00ff00)
  val colorFontTertiary = Color(0xffcccccc)
}

object StyleDictionarySize {
  /** the base size of the font */
  val sizeFontBase = 16.00.sp
  /** the large size of the font */
  val sizeFontLarge = 32.00.sp
  /** the medium size of the font */
  val sizeFontMedium = 16.00.sp
  /** the small size of the font */
  val sizeFontSmall = 12.00.sp
}

SCSS

// variables.scss
$color-base-gray-light: #cccccc;
$color-base-gray-medium: #999999;
$color-base-gray-dark: #111111;
$color-base-red: #ff0000;
$color-base-green: #00ff00;
$color-font-base: #ff0000;
$color-font-secondary: #00ff00;
$color-font-tertiary: #cccccc;
$size-font-small: 0.75rem;
$size-font-medium: 1rem;
$size-font-large: 2rem;
$size-font-base: 1rem;

iOS

#import "StyleDictionaryColor.h"

@implementation StyleDictionaryColor

+ (UIColor *)color:(StyleDictionaryColorName)colorEnum{
  return [[self values] objectAtIndex:colorEnum];
}

+ (NSArray *)values {
  static NSArray* colorArray;
  static dispatch_once_t onceToken;

  dispatch_once(&onceToken, ^{
    colorArray = @[
[UIColor colorWithRed:0.800f green:0.800f blue:0.800f alpha:1.000f],
[UIColor colorWithRed:0.600f green:0.600f blue:0.600f alpha:1.000f],
[UIColor colorWithRed:0.067f green:0.067f blue:0.067f alpha:1.000f],
[UIColor colorWithRed:1.000f green:0.000f blue:0.000f alpha:1.000f],
[UIColor colorWithRed:0.000f green:1.000f blue:0.000f alpha:1.000f],
[UIColor colorWithRed:1.000f green:0.000f blue:0.000f alpha:1.000f],
[UIColor colorWithRed:0.000f green:1.000f blue:0.000f alpha:1.000f],
[UIColor colorWithRed:0.800f green:0.800f blue:0.800f alpha:1.000f]
    ];
  });

  return colorArray;
}

@end

Pretty nifty! This shows a few things happening:

  1. The build system does a deep merge of all the token JSON files defined in the source attribute of config.json. This allows you to split up the token JSON files however you want. There are 2 JSON files with color as the top level key, but they get merged properly.
  2. The build system resolves references to other design tokens. {size.font.medium.value} gets resolved properly.
  3. The build system handles references to token values in other files as well as you can see in tokens/color/font.json.

Now let's make a change and see how that affects things. Open up tokens/color/base.json and change "#111111" to "#000000". After you make that change, save the file and re-run the build command style-dictionary build. Open up the build files and take a look.

Huzzah!

Now go forth and create! Take a look at all the built-in transforms and formats.

0.6.1-next-385e61

9 months ago

0.7.1-next-62ec43

7 months ago

0.7.1-next-7f6929

8 months ago

0.7.1

8 months ago

0.7.1-next-136907

7 months ago

0.6.1-next-547e9f

8 months ago

0.7.1-next-a8cc29

7 months ago

0.7.1-next-52400d

8 months ago

0.5.1-next-0eb3ae

10 months ago

0.7.1-next-2d68d6

7 months ago

0.7.1-next-a010ab

7 months ago

0.5.1

10 months ago

0.7.1-next-f8e537

8 months ago

0.5.1-next-32a057

9 months ago

0.7.1-next-a777b1

8 months ago

0.7.1-next-1a8d63

8 months ago

0.7.1-next-4b7146

7 months ago

0.6.1-next-919826

9 months ago

0.5.1-next-763ddf

10 months ago

0.6.1-next-4f84f2

8 months ago

0.6.1-next-5a1e18

9 months ago

0.6.1-next-e36d88

8 months ago

0.6.1-next-5740f0

9 months ago

0.7.1-next-a10f9a

8 months ago

0.4.1-next-67a233

10 months ago

0.5.1-next-74eedd

10 months ago

0.5.1-next-4e3d66

9 months ago

0.7.1-next-7da648

8 months ago

0.7.1-next-0a917f

7 months ago

0.7.1-next-da7eb3

8 months ago

0.7.1-next-6d72ae

7 months ago

0.7.1-next-825755

8 months ago

0.7.1-next-5f9f4f

8 months ago

0.7.1-next-2130df

7 months ago

0.6.1-next-b96db8

9 months ago

0.5.1-next-136a94

10 months ago

0.5.1-next-788be7

10 months ago

0.7.1-next-2931b9

8 months ago

0.6.1-next-8465ee

9 months ago

0.6.1-next-643138

9 months ago

0.5.1-next-d483af

9 months ago

0.7.1-next-3bc036

7 months ago

0.6.1-next-5649aa

9 months ago

0.7.1-next-0e5a05

8 months ago

0.5.1-next-72536b

10 months ago

0.7.1-next-b2ae0c

7 months ago

0.7.1-next-819421

8 months ago

0.5.1-next-62e11d

9 months ago

0.5.1-next-0a833a

10 months ago

0.7.1-next-e85531

7 months ago

0.7.1-next-115ddf

8 months ago

0.7.1-next-150099

8 months ago

0.5.1-next-58d6cb

10 months ago

0.5.1-next-a5377b

9 months ago

0.5.1-next-ee5658

10 months ago

0.6.1

9 months ago

0.6.1-next-6ee468

9 months ago

0.5.1-next-ffaccf

9 months ago

0.5.1-next-e10ec8

9 months ago

0.5.1-next-5e0cb9

10 months ago

0.6.1-next-3603ec

9 months ago

0.6.1-next-578a4a

9 months ago

0.6.1-next-edebd4

8 months ago

0.7.1-next-4f62e0

8 months ago

0.7.1-next-c2095b

7 months ago

0.7.1-next-5cd04a

7 months ago

0.5.1-next-a38413

10 months ago

0.7.1-next-2fd432

8 months ago

0.7.1-next-df1163

7 months ago

0.6.1-next-22841d

8 months ago

0.4.1-next-44c684

10 months ago

0.6.1-next-60e2cb

9 months ago

0.7.1-next-e23308

8 months ago

0.7.1-next-4b8c98

7 months ago

0.6.1-next-86f61e

9 months ago

0.5.1-next-4b1e55

9 months ago

0.7.1-next-507170

8 months ago

0.6.1-next-afc1b3

9 months ago

0.7.1-next-e3fb66

8 months ago

0.5.1-next-35209e

9 months ago

0.7.1-next-5bfa88

7 months ago

0.6.1-next-1d9f97

9 months ago

0.5.1-next-86c316

10 months ago

0.7.1-next-ee4a69

7 months ago

0.6.1-next-7f9360

8 months ago

0.7.1-next-6085c0

7 months ago

0.6.1-next-47655f

8 months ago

0.7.1-next-2d2789

7 months ago

0.6.1-next-06e5c5

9 months ago

0.4.1-next-5b6d95

10 months ago

0.7.1-next-747c95

7 months ago

0.7.1-next-edf688

8 months ago

0.7.1-next-aeada9

8 months ago

0.4.1-next-9850da

10 months ago

0.5.1-next-8fd277

9 months ago

0.5.1-next-1c759e

10 months ago

0.5.1-next-fc1c41

10 months ago

0.5.1-next-ce5d91

10 months ago

0.7.1-next-ca66d7

8 months ago

0.5.1-next-c12d99

9 months ago

0.6.1-next-66c002

8 months ago

0.5.1-next-522f2c

10 months ago

0.4.1-next-04c34b

12 months ago

0.4.1-next-24502c

11 months ago

0.4.1-next-9e4bcc

11 months ago

0.4.1-next-fc2dc9

12 months ago

0.4.1-next-046a83

11 months ago

0.4.1-next-c287d6

11 months ago

0.4.1-next-522ce8

12 months ago

0.4.1-next-6c5d68

12 months ago

0.4.1-next-f7e658

12 months ago

0.4.1-next-c835ab

12 months ago

0.4.1-next-1ae4ce

12 months ago

0.4.1-next-41fd41

11 months ago

0.4.1-next-8fa40f

12 months ago

0.4.1-next-23f96a

12 months ago

0.4.1-next-776a6a

11 months ago

0.4.1-next-1a8c98

11 months ago

0.4.1-next-58d853

12 months ago

0.4.1-next-559fee

12 months ago

0.4.1-next-9695a7

11 months ago

0.4.1-next-e21ba4

12 months ago

0.4.1-next-069547

12 months ago

0.4.1-next-bdf825

12 months ago

0.4.1-next-e37e5a

12 months ago

0.4.1-next-f09736

12 months ago

0.4.1-next-a2229b

11 months ago

0.4.1-next-2f50a7

12 months ago

0.4.1-next-4e05b6

12 months ago

0.4.1-next-6944d0

11 months ago

0.4.1-next-3cc012

12 months ago

0.4.1-next-9e0f1d

12 months ago

0.4.1-next-bac1ac

11 months ago

0.4.1-next-359ae1

12 months ago

0.4.1-next-cdca71

11 months ago

0.4.1-next-0fc005

11 months ago

0.4.1-next-7b83ff

11 months ago

0.4.1-next-a028e4

12 months ago

0.4.1-next-2afb32

12 months ago

0.4.1-next-88e032

12 months ago

0.4.1-next-41309a

12 months ago

0.4.1-next-6025a6

12 months ago

0.4.1-next-4db90e

12 months ago

0.4.1-next-6d3889

11 months ago

0.4.1-next-00a4b2

11 months ago

0.4.1-next-cc747a

11 months ago

0.4.1-next-4c3577

12 months ago

0.4.1-next-4695fe

11 months ago

0.4.1-next-c42fcb

11 months ago

0.4.1-next-71b00b

11 months ago

0.4.1-next-abe8b0

12 months ago

0.4.1-next-70a38a

12 months ago

0.4.1-next-3f96a9

12 months ago

0.4.1-next-c7d5af

12 months ago

0.4.1-next-ed702d

12 months ago

0.4.1-next-0ece28

12 months ago

0.4.1-next-680cbf

11 months ago

0.4.1-next-46314d

12 months ago

0.4.1-next-a5fad8

12 months ago

0.4.1-next-a011aa

11 months ago

0.4.1-next-94b967

12 months ago

0.4.1-next-490988

12 months ago

0.4.1-next-4362dd

12 months ago

0.4.1-next-e22561

12 months ago

0.4.1-next-27b2a0

11 months ago

0.4.1-next-65cb1e

12 months ago

0.4.1-next-41dd31

12 months ago

0.4.1-next-592f2b

12 months ago

0.4.1-next-77b98c

11 months ago

0.4.1-next-c463b0

12 months ago

0.4.1-next-027386

12 months ago

0.4.1-next-6d4328

12 months ago

0.4.1-next-26a6da

11 months ago

0.4.1-next-d91598

11 months ago

0.4.1-next-842340

12 months ago

0.4.1-next-df08b8

11 months ago

0.4.1-next-62ea0f

12 months ago

0.4.1-next-f75ea6

12 months ago

0.4.1-next-bc5bac

11 months ago

0.4.1-next-5c5f01

12 months ago

0.4.1-next-113eec

12 months ago

0.4.1-next-eba916

12 months ago

0.4.1-next-2a48e5

12 months ago

0.4.1-next-926e28

11 months ago

0.4.1-next-b3c10f

12 months ago

0.4.1-next-db7d92

12 months ago

0.4.1-next-61e490

12 months ago

0.4.1-next-a14761

12 months ago

0.4.1-next-29fa08

12 months ago

0.4.1-next-95bfc6

12 months ago

0.4.1-next-884f5d

12 months ago

0.4.1-next-974062

11 months ago

0.4.1-next-ca4f8e

11 months ago

0.4.1-next-2e00f1

12 months ago

0.4.1-next-6d2805

12 months ago

0.4.1-next-f5cbfc

12 months ago

0.4.1-next-0b826f

11 months ago

0.4.1-next-b75471

12 months ago

0.4.1-next-560b4f

11 months ago

0.4.1-next-04bd1c

12 months ago

0.4.1-next-451717

11 months ago

0.4.1-next-4cd5c6

12 months ago

0.4.1-next-f4801d

11 months ago

0.4.1-next-6eea5c

12 months ago

0.4.1-next-2a74e7

12 months ago

0.4.1-next-db97ce

12 months ago

0.4.1-next-a46b65

12 months ago

0.4.1-next-54781d

12 months ago

0.4.1-next-a5a28b

12 months ago

0.4.1-next-0536c3

11 months ago

0.4.1-next-9022e9

12 months ago

0.4.1-next-3b6f76

11 months ago

0.4.1-next-e195e7

12 months ago

0.4.1-next-019c24

12 months ago

0.4.1-next-e734b7

12 months ago

0.4.1-next-37eb49

12 months ago

0.4.1-next-87eb09

12 months ago

0.4.1-next-58ca97

12 months ago

0.4.1-next-3bc0e2

12 months ago

0.4.1-next-65c44b

11 months ago

0.4.1-next-431c05

12 months ago

0.4.1-next-df41d6

12 months ago

0.4.1-next-05550b

11 months ago

0.4.1-next-77f6fa

12 months ago

0.4.1-next-bd2e6b

12 months ago

0.4.1-next-e7ef77

11 months ago

0.4.1-next-3d8738

12 months ago

0.3.1-rc-042461

1 year ago

0.3.1-rc-14c248

1 year ago

0.3.1-rc-c34830

1 year ago

0.3.1-rc-e85674

1 year ago

0.3.1-rc-7153c2

1 year ago

0.3.1-rc-af8786

1 year ago

0.3.1-rc-99a22c

1 year ago

0.3.1-rc-8e80db

1 year ago

0.3.1-rc-9521d0

1 year ago

0.3.1-rc-da0a15

1 year ago

0.3.1-rc-117a85

1 year ago

0.3.1-rc-6d93cf

1 year ago

0.3.1-rc-a91737

1 year ago

0.3.1-rc-c3e4e9

1 year ago

0.3.1-rc-ba2764

1 year ago

0.3.1-rc-13af66

1 year ago

0.3.1-rc-df7bef

1 year ago

0.3.1-rc-288816

1 year ago

0.3.1-rc-64b19b

1 year ago

0.3.1-rc-fccd30

1 year ago

0.3.1-rc-9e0aa2

1 year ago

0.3.1-rc-b45bb3

1 year ago

0.3.1-rc-30a38f

1 year ago

0.3.1-rc-48f618

1 year ago

0.3.1-rc-bac751

1 year ago

0.3.1-rc-0656fe

1 year ago

0.3.1-rc-e553a7

1 year ago

0.3.1-rc-ef6416

1 year ago

0.3.1-rc-f7bb52

1 year ago

0.3.1-rc-545353

1 year ago

0.3.1-rc-2bd552

1 year ago

0.3.1-rc-0bcae4

1 year ago

0.3.1-rc-e1d43a

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.1-rc-dd35c5

1 year ago

0.3.1-rc-4a84d4

1 year ago

0.3.1-rc-3c4884

1 year ago

0.3.1-rc-f4a8bd

1 year ago

0.3.1-rc-95ba8c

1 year ago

0.3.1-rc-4c2f08

1 year ago

0.3.1-rc-5d4a4f

1 year ago

0.3.1-rc-473756

1 year ago

0.3.1-rc-4bcd4c

1 year ago

0.3.1-rc-02e7a3

1 year ago

0.3.1-rc-ab41a0

1 year ago

0.3.1-rc-35be59

1 year ago

0.3.1-rc-8a2ff6

1 year ago

0.3.1-rc-a2ce2b

1 year ago

0.3.1-rc-28613c

1 year ago

0.3.1-rc-948c11

1 year ago

0.3.1-rc-5bd39c

1 year ago

0.3.1-rc-56f7cb

1 year ago

0.3.1-rc-f5690e

1 year ago

0.3.1-rc-a35044

1 year ago

0.3.1-rc-f5f5a2

1 year ago

0.3.1-rc-9fb7d3

1 year ago

0.3.1-rc-0d6de3

1 year ago

0.3.1-rc-ee4043

1 year ago

0.3.1-rc-8339fd

1 year ago

0.3.1-rc-75ad37

1 year ago

0.3.1-rc-7579c2

1 year ago

0.3.1-rc-c705ab

1 year ago

0.3.1-rc-e4b9de

1 year ago

0.3.1-rc-0b9521

1 year ago

0.3.1-rc-1fd94e

1 year ago

0.3.1-rc-ee4d2d

1 year ago

0.3.1-rc-9062f7

1 year ago

0.3.1-rc-c4c09d

1 year ago

0.3.1-rc-287148

1 year ago

0.3.1-rc-91f6af

1 year ago

0.3.1-rc-86fd8f

1 year ago

0.3.1-rc-500917

1 year ago

0.3.1-rc-99f02a

1 year ago

0.3.1-rc-b09b1f

1 year ago

0.3.1-rc-6ec900

1 year ago

0.3.1-rc-0e43e1

1 year ago

0.3.1-rc-7ca313

1 year ago

0.3.1-rc-4b211e

1 year ago

0.3.1-rc-533c20

1 year ago

0.3.1-rc-e53b7d

1 year ago

0.3.1-rc-c805e2

1 year ago

0.3.1-rc-99bbb3

1 year ago

0.3.1-rc-9cbfb8

1 year ago

0.3.1-rc-e2d6cf

1 year ago

0.3.1-rc-58df9e

1 year ago

0.3.1-rc-b738c0

1 year ago

0.3.1-rc-fa01ff

1 year ago

0.3.1-rc-5a0174

1 year ago

0.3.1-rc-b13dac

1 year ago

0.3.1-rc-34b764

1 year ago

0.3.1-rc-4cee61

1 year ago

0.3.1-rc-268ec3

1 year ago

0.3.1-rc-157f60

1 year ago

0.3.1-rc-ccedfa

1 year ago

0.3.1-rc-8fbb74

1 year ago

0.3.1-rc-305cb7

1 year ago

0.3.1-rc-bbe17b

1 year ago

0.3.1-rc-e9c110

1 year ago

0.3.1-rc-631946

1 year ago

0.3.1-rc-845f54

1 year ago

0.3.1-rc-79f535

1 year ago

0.3.1-rc-4195f5

1 year ago

0.3.1-rc-9c5659

1 year ago

0.3.1-rc-59730b

1 year ago

0.3.1-rc-0efea4

1 year ago

0.3.1-rc-99930f

1 year ago

0.3.1-rc-dbee1e

1 year ago

0.3.1-rc-2c0ec3

1 year ago

0.3.1-rc-827525

1 year ago

0.3.1-rc-6b6633

1 year ago

0.3.1-rc-7df556

1 year ago

0.3.1-rc-321435

1 year ago

0.3.1-rc-e607a6

1 year ago

0.3.1-rc-a74f14

1 year ago

0.3.1-rc-fdc73f

1 year ago

0.3.1-rc-f94ff6

1 year ago

0.3.1-rc-bca150

1 year ago

0.3.1-rc-a6ad11

1 year ago

0.3.1-rc-f63297

1 year ago

0.3.1-rc-719a86

1 year ago

0.3.1-rc-124083

1 year ago

0.3.1-rc-33cc5a

1 year ago

0.3.1-rc-401938

1 year ago

0.3.1-rc-8a8fbf

1 year ago

0.3.1-rc-d602f9

1 year ago

0.3.1-rc-d0e756

1 year ago

0.3.1-rc-26ff70

1 year ago

0.3.1-rc-c080ad

1 year ago

0.3.1-rc-ecae9a

1 year ago

0.3.1-rc-e1e548

1 year ago

0.3.1-rc-68da83

1 year ago

0.3.1-rc-30dfeb

1 year ago

0.3.1-rc-eecff5

1 year ago

0.2.0-rc-9b2f6a

1 year ago

0.3.1-rc-e74b9e

1 year ago

0.2.0-rc-1983a8

1 year ago

0.3.1-rc-421dd0

1 year ago

0.2.0-rc-974fd7

1 year ago

0.2.0-rc-2cc34e

1 year ago

0.2.0-rc-d9f115

1 year ago

0.2.0-rc-dc3912

1 year ago

0.2.0-rc-ceea91

1 year ago

0.3.1

1 year ago

0.3.1-rc-c94a05

1 year ago

0.3.1-rc-b5e643

1 year ago

0.1.3

1 year ago

0.3.1-rc-37706b

1 year ago

0.2.0-rc-028d80

1 year ago

0.2.0-rc-8f3913

1 year ago

0.3.1-rc-f36f08

1 year ago

0.2.0-rc-1fc600

1 year ago

0.3.1-rc-043800

1 year ago

0.3.1-rc-569991

1 year ago

0.2.0-rc-86c8ea

1 year ago

0.2.0-rc-61d98c

1 year ago

0.2.0

1 year ago

0.1.2

2 years ago

0.1.0

2 years ago

0.0.0

2 years ago