# How it works 🧰

![](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-MXC5JLJC6YaULQbvb2-%2F-MXHx6oGR97qdrSbbcbD%2FTokens2021Workflow.png?alt=media\&token=60169f7b-8400-4e32-a5f4-253a47875541)

**TLDR;** *Stratos Tokens App* reads the **raw design file** (no plugins) and **generates a design token file** (JSON-format). This file can then be either stored directly in your codebase or uploaded to repositories like *NPMjs* to be consumed by any codebase on any platform. And it’s **1:1 with your design file!**

You visually represent your **Design Tokens** in a design tool, [Sketch](https://www.sketch.com) and [Figma](https://www.figma.com/) are currently supported and we have macOS and Windows versions of our app.

![](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-MX1tRKNaUEG9iYNNIuB%2F-MX1uVL_3wd4yvI_QOaJ%2Ftokens-2021-sketch.png?alt=media\&token=9a620b78-ef44-4941-8a97-28b2729a92b4)

The **Stratos Tokens App** reads your design file (without plugins, yupp, just like that) and generates a file with a JSON structure containing your design data. Then you either save the design data file (Design Tokens) or upload it to a repository like *NPMjs*.

![Generated JSON-structure in Stratos Tokens App](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-M5zgDVnkpGDc7mNyRU3%2F-M5zgWOK8qlG7RKDptid%2FSka%CC%88rmklipp%202020-04-28%2009.30.24.png?alt=media\&token=6c31c957-45d5-4d4d-98d4-b27032844a5b)

{% hint style="success" %}
The structure of the output JSON is a direct reflection of the structure in your design document.

🤖👉 ***It’s up to you to create your own structure.***
{% endhint %}

Please note that above is just an **example** of how to structure your design tokens & theming. It’s up to you to create your own structure.

## About Style Dictionary

We support [Style Dictionary](https://amzn.github.io/style-dictionary/#/) markup which is a great build system for outputting design tokens to a wide range of different formats. **Support does not mean you can set this up however you want.** You will need to follow Style Dictionary's structure and naming conventions for the auto-translation to do its magic. \
A great article to get you started understanding Style Dictionary is this one.

{% embed url="<https://sketch2react.io/blog/lets-get-practical-with-design-tokens-part-1/>" %}

## How to create design tokens

Basically you use **shapes, lines, layer groups & text nodes** to output design token data. Here's a few great things to know 🤖👇

1. Design token names must be wrapped in **{ }** – including your **design token artboards**
2. The structure of nested Groups (Sidebar = Sketch, Layers Panel = Figma) in the design document defines the structure of the output JSON data
3. **Rectangles** represent a **color value** based of the rectangle’s fill value
4. Rectangles without a fill results in **border formatting**
5. **Lines represent width,** perfect for defining **breakpoints**, **spacing & padding**
6. Text layers represent **text formatting**
7. **Text layers with values within { }** are evaluated. Perfect for defining things like **font families, transitions & animation timing**
8. Text nodes with values within **{{ }}** are considered as Style Dictionary references / variables to be able to reuse values.&#x20;
9. Text layers with names that matches a CSS property will have only that CSS property’s value (as opposed to plain Text layers which will contain all CSS properties; see bullet 6 above)

## Getting started with Sketch & Figma

### For Sketch

1. Start **Sketch app** and **Create a New document**
2. Create **one artboard**, the size does not matter
3. Give your artboard a simple name, **lower case only, no blank spaces between words** e.g {great-artboard-name}
4. Save your Sketch file to your HD
5. Drag and drop that Sketch file onto our app like in the video below&#x20;
6. You are now ready to start creating design tokens straight from inside Sketch app

{% embed url="<https://youtu.be/usPnN_VBc6s>" %}

### For Figma

![](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-MdMeOezvHGU1E29Byx6%2F-MdMf6h7hN_8HVW5UFcL%2Ffigma-stratos-tokens.png?alt=media\&token=b77fe6b4-21db-4f47-a0d5-f3114b504ced)

### Get your Figma Access Token

1. Go to your **Figma Account Settings**
2. Scroll down to the bit where it says **Personal access tokens**
3. Create a **new personal access token**
4. **Copy** the access token to notes or something similar

### In Stratos Tokens 2021

1. Go to **Create New Project** and select Figma

![](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-MdMeOezvHGU1E29Byx6%2F-MdMfHb3kzHx77RMWtNm%2Ffigma-start-here.png?alt=media\&token=45c5b0a2-d22c-4497-88dd-68d1d248c0d3)

2\. Paste your newly created Figma access token, no worries you only **need to do this once**, and it can be revoked if needed, more on that later.

![](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-MdMeOezvHGU1E29Byx6%2F-MdMfS_bwAmLaNkUSC3E%2Ffigma-access-token.png?alt=media\&token=83386d82-1163-41d6-a7da-6f6e579dd717)

1. Jump back to Figma and **create a new file**
2. Copy the URL of that Figma file&#x20;

![](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-MdMeOezvHGU1E29Byx6%2F-MdMfgYWiLM0VWc6GrUI%2Ffigma-copy-url.png?alt=media\&token=2286902b-2619-418f-885c-8efd7672be73)

3\. Paste the Figma file URL in our app 👉 **Figma project url**

![](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-MdMeOezvHGU1E29Byx6%2F-MdMfprPZpETC1BJFdtx%2Ffigma-paste-url.png?alt=media\&token=0238c337-7d18-4fed-89c3-2146328fb77f)

Now we are ready to get going! Press **Create Figma project**&#x20;

## Important thing about Figma files

Figma files work differently than Sketch files in the sense that Figma doesn’t offer so called *hot-reloading*. Every time you do changes inside Figma you will need to press the **little reload icon** to update the **design token tree**.

![To update the design token tree you will need to press this one](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-MdMeOezvHGU1E29Byx6%2F-MdMfxoBwox34IpSxkML%2Ffigma-refresh.png?alt=media\&token=20f41f56-85df-4d19-a707-1a4f39217006)

In a future update, we’ll introduce time-saving shortcuts for this and other semi annoying things. Who doesn’t want extra seconds in life?

### When using Auto Layout

If you're using the awesome Auto Layout function in Figma make sure not to break the naming chain or you will break the design token output in Stratos Tokens.&#x20;

{% hint style="info" %}
Design token names must be wrapped in **{ }** – including your **design token artboards**
{% endhint %}

#### Do Auto Layout like this👇

![Make sure to never ever break the {designtoken} curly brackets chain or it will stop working](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-MdMi7Sy5nRtrn3H4eOY%2F-MdN0-K3H0NvxQcz_Yy3%2FCleanShot%202021-06-29%20at%2015.42.20.gif?alt=media\&token=19ae8f43-cfdd-4d82-9405-18294d63c5e4)

## So, now what?

Now you need to learn **how our app and design token framework works**, what rules you need to follow, how you can set up things, if you’re going to follow our built-in Style Dictionary support or not. We give you the choice.

A great starting point is reading [this article](https://sketch2react.io/blog/the-different-levels-of-design-token-designing/). If you’re curious about learning how to setup for Style Dictionary we suggest you read [this article](https://sketch2react.io/blog/lets-get-practical-with-design-tokens-part-1/).

## NPM project? Oooh, tell me more…

Ok, sure. There are a few steps, but stay with us, it’s worth it. In the example below our new **design tokens NPM package** is named *stratos-designtokens-demo*. You can name yours whatever you like.👍😄

If you don’t have the time/patience to read through all the steps; here’s the final example package install command:

```
npm install — save stratos-designtokens-demo
```

![It’s a big button, you can’t miss it. 😺👍](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-M5ziGyTn0big8WdYcHJ%2F-M5zigMUkcJSzvZdE5wL%2FSka%CC%88rmklipp%202020-04-28%2009.39.41.png?alt=media\&token=49b3d4b3-f6fb-4adf-af2d-6c12c1444d3d)

### Downloading

1. On the *Download* tab in *Stratos Tokens App*, expand the *Design tokens NPM project* and hit the *Download NPM* button
2. Store the project anywhere you like

![Your downloaded NPM project’s package.json](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-M-R40ieu24vcxWdDxnZ%2F-M-R8BC2G8zP4u7oRm9t%2F1*qeHTJBACMtze_RXvh8hmmg.png?alt=media\&token=7f8d9ca9-3f0b-4eec-ab23-f849a9949401)

### Naming your NPM project

1. Open the file *package.json* in your **downloaded NPM project’s folder** using your favorite code editor
2. Enter a name on line 2 (this will be the name of the NPM package)

![](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-M-R40ieu24vcxWdDxnZ%2F-M-R8T8rPOEVVsl9i0Wl%2F1*x30-64XMlUgMx23oDWc_jA.png?alt=media\&token=01e8e52f-f14f-4bae-8103-5e804336a86f)

### Uploading & publishing

1. Open *Terminal App*
2. Go to your **downloaded NPM project’s folder** (we named ours *npmDTDemo*)
3. If this is your *first time uploading a package* to *NPMjs* you need to *login*
4. Enter *npm login* and enter your credentials (you need an account at [www.npmjs.com](https://www.npmjs.com/))
5. Enter *npm install* (a bunch of texts will flash by, no worries, this is ok)
6. Enter *npm run build* (more text will flash by, this is also ok)
7. Enter *npm publish* (even more ok text)

![](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-M-R40ieu24vcxWdDxnZ%2F-M-R9KxcklC8braOv8AV%2F1*R9B9Xz5Y8_bFlBDwWgWJMA.png?alt=media\&token=333f3643-a64c-4dbc-a211-afd9d67f186c)

Your design tokens are now available for any codebase on any platform! And **it’s 1:1 with your Design tool’s design document!**

**Feel free to download and test the design tokens example here:**

```
npm install --save stratos-designtokens-demo
```

### Example usage <a href="#dbf2" id="dbf2"></a>

#### React

![](https://230886557-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LL-qYWTohHkbVxTapce%2F-M-RA37hxoydvZMqBCBC%2F-M-RASMHLFvlMRJF2KHi%2F1*LHpat6rkwO6xTly2Zg0ruA.png?alt=media\&token=b281b083-5f52-4bcc-a1ae-21db87a51d40)

You can of course use this for other frameworks and platforms as well  (i.e. React native, Vue.js, Angular...). And with a little help from our built-in Style Dictionary support you can also use your tokens for Android, Swift… 🤖💪
