@covalent/tokens 0.0.0-COVALENT

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # Covalent Style Dictionary
2
+
3
+ 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:
4
+
5
+ ```bash
6
+ style-dictionary build
7
+ ```
8
+
9
+ You should see something like this output:
10
+
11
+ ```
12
+ json
13
+ ⚠️ build/json/variables.json
14
+
15
+ scss
16
+ ✔︎ build/scss/_variables.scss
17
+
18
+ css
19
+ ✔︎ build/css/variables.css
20
+
21
+ js
22
+ ✔︎ build/js/variables.js
23
+ ```
24
+
25
+ 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:
26
+
27
+ ```
28
+ ├── README.md
29
+ ├── config.json
30
+ ├── tokens/
31
+ │ ├── color/
32
+ │ ├── base.json
33
+ │ ├── surface.json
34
+ │ ├── text.json
35
+ │ ├── palettes/
36
+ │ ├── material.json
37
+ │ ├── teradata.json
38
+ │ ├── typography/
39
+ │ ├── typography.json
40
+ ├── build/
41
+ │ ├── json/
42
+ │ ├── variables.json
43
+ │ ├── scss/
44
+ │ ├── _variables.scss
45
+ │ ├── css/
46
+ │ ├── variables.scss
47
+ │ ├── js/
48
+ │ ├── variables.js
49
+ ```
50
+
51
+ 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:
52
+
53
+ **SCSS**
54
+
55
+ ```scss
56
+ // _variables.scss
57
+ $light-primary: #007373 !default;
58
+ $light-secondary: #007373 !default;
59
+ $light-error: #b11d00 !default;
60
+ $light-positive: #0a7e07 !default;
61
+ $light-caution: #ff8f00 !default;
62
+ $light-negative: #b11d00 !default;
63
+ $light-on-primary: white !default;
64
+ $light-on-secondary: white !default;
65
+ $light-on-background: rgba(0, 0, 0, 0.87) !default;
66
+ $light-on-surface: rgba(0, 0, 0, 0.87) !default;
67
+ $light-on-error: white !default;
68
+ $light-divider: rgba(0, 0, 0, 0.12) !default;
69
+ $light-background: #f5f5f5 !default;
70
+ $light-surface: white !default;
71
+ ```
72
+
73
+ Pretty nifty! This shows a few things happening:
74
+
75
+ 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.
76
+ 1. The build system resolves references to other design tokens. `{size.font.medium.value}` gets resolved properly.
77
+ 1. The build system handles references to token values in other files as well as you can see in `tokens/color/font.json`.
78
+
79
+ 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.
80
+
81
+ **Huzzah!**
82
+
83
+ Now go forth and create! Take a look at all the built-in [transforms](https://amzn.github.io/style-dictionary/#/transforms?id=pre-defined-transforms) and [formats](https://amzn.github.io/style-dictionary/#/formats?id=pre-defined-formats).
package/config.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "source": ["libs/tokens/src/**/*.json"],
3
+ "platforms": {
4
+ "json": {
5
+ "transformGroup": "assets",
6
+ "prefix": "cv",
7
+ "buildPath": "dist/libs/tokens/",
8
+ "files": [
9
+ {
10
+ "destination": "index.json",
11
+ "format": "json"
12
+ }
13
+ ]
14
+ },
15
+ "scss": {
16
+ "transformGroup": "scss",
17
+ "buildPath": "dist/libs/tokens/",
18
+ "files": [
19
+ {
20
+ "destination": "_index.scss",
21
+ "format": "scss/map-deep"
22
+ }
23
+ ]
24
+ },
25
+ "css": {
26
+ "transformGroup": "css",
27
+ "prefix": "cv",
28
+ "buildPath": "dist/libs/tokens/",
29
+ "files": [
30
+ {
31
+ "destination": "index.css",
32
+ "format": "css/variables"
33
+ }
34
+ ]
35
+ },
36
+ "js": {
37
+ "transformGroup": "js",
38
+ "transforms": [
39
+ "attribute/cti",
40
+ "name/pascal",
41
+ "size/rem",
42
+ "color/css"
43
+ ],
44
+ "prefix": "cv",
45
+ "buildPath": "dist/libs/tokens/",
46
+ "files": [
47
+ {
48
+ "destination": "index.js",
49
+ "format": "javascript/es6"
50
+ },
51
+ {
52
+ "destination": "index.d.ts",
53
+ "format": "typescript/es6-declarations"
54
+ }
55
+ ]
56
+ }
57
+ }
58
+ }
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@covalent/tokens",
3
+ "version": "0.0.0-COVALENT",
4
+ "description": "Design tokens for covalent design system",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/teradata/covalent.git"
8
+ },
9
+ "bugs": {
10
+ "url": "https://github.com/teradata/covalent/issues"
11
+ },
12
+ "license": "MIT",
13
+ "author": "Teradata UX",
14
+ "exports": {
15
+ ".": {
16
+ "sass": "./_index.scss",
17
+ "style": "./index.css",
18
+ "types": "./index.d.ts",
19
+ "default": "./index.js"
20
+ },
21
+ "./index.css": {
22
+ "default": "./index.css"
23
+ }
24
+ }
25
+ }
package/project.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "tokens",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "libs/tokens/src",
5
+ "projectType": "library",
6
+ "targets": {
7
+ "build": {
8
+ "executor": "nx:run-commands",
9
+ "outputs": ["{workspaceRoot}/dist/libs/tokens"],
10
+ "options": {
11
+ "commands": [
12
+ "./node_modules/.bin/style-dictionary build -c libs/tokens/config.json",
13
+ "cp libs/tokens/package.json dist/libs/tokens"
14
+ ],
15
+ "parallel": false
16
+ },
17
+ "configurations": {
18
+ "watch": {
19
+ "commands": [
20
+ "./node_modules/.bin/style-dictionary build -c libs/tokens/config.json",
21
+ "npx chokidar-cli \"libs/tokens/src/**\" -c \"npx style-dictionary build -c libs/tokens/config.json\""
22
+ ]
23
+ }
24
+ }
25
+ }
26
+ },
27
+ "tags": []
28
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "light": {
3
+ "code-snippet-color": { "value": "#383a42", "type": "color" },
4
+ "code-snippet-comment": { "value": "#6C6C6C", "type": "color" },
5
+ "code-snippet-keyword": { "value": "#A626A4", "type": "color" },
6
+ "code-snippet-selector": { "value": "#AD0F00", "type": "color" },
7
+ "code-snippet-literal": { "value": "#17749B", "type": "color" },
8
+ "code-snippet-string": { "value": "#0A7C08", "type": "color" },
9
+ "code-snippet-variable": { "value": "#8E6102", "type": "color" },
10
+ "code-snippet-title": { "value": "#004FFD", "type": "color" },
11
+ "code-snippet-class": { "value": "#6A6C02", "type": "color" }
12
+ },
13
+ "dark": {
14
+ "code-snippet-color": { "value": "#abb2bf", "type": "color" },
15
+ "code-snippet-comment": { "value": "#5c6370", "type": "color" },
16
+ "code-snippet-keyword": { "value": "#c678dd", "type": "color" },
17
+ "code-snippet-selector": { "value": "#e06c75", "type": "color" },
18
+ "code-snippet-literal": { "value": "#56b6c2", "type": "color" },
19
+ "code-snippet-string": { "value": "#98c379", "type": "color" },
20
+ "code-snippet-variable": { "value": "#d19a66", "type": "color" },
21
+ "code-snippet-title": { "value": "#61aeee", "type": "color" },
22
+ "code-snippet-class": { "value": "#e6c07b", "type": "color" }
23
+ }
24
+ }