@aleph-alpha/config-css 0.7.0

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/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@aleph-alpha/config-css",
3
+ "license": "Apache-2.0",
4
+ "version": "0.7.0",
5
+ "main": "dist/index.js",
6
+ "typings": "dist/index.d.ts",
7
+ "prettier": "@aleph-alpha/prettier-config-frontend",
8
+ "type": "module",
9
+ "author": "Aleph Alpha GmbH",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://gitlab.aleph-alpha.de/engineering/frontend-hub"
13
+ },
14
+ "typedocOptions": {
15
+ "entryPoints": [
16
+ "./src/index.ts"
17
+ ]
18
+ },
19
+ "dependencies": {
20
+ "@tokens-studio/sd-transforms": "1.2.9",
21
+ "token-transformer": "0.0.33",
22
+ "unocss": "^0.61.3",
23
+ "unocss-preset-animations": "1.1.1",
24
+ "unocss-preset-theme": "0.14.1"
25
+ },
26
+ "devDependencies": {
27
+ "style-dictionary": "^4.0.1",
28
+ "vite-plugin-dts": "^4.0.0"
29
+ },
30
+ "scripts": {
31
+ "transform:global": "npx token-transformer ./tokens.json ./transformed-tokens/global.json global,\"Spark Border Radius/Mode 1\",\"Spark Spacings/Mode 1\" \"Spark Colors/Light mode/primitives\" --throwErrorWhenNotResolved",
32
+ "transform:dark-mode": "npx token-transformer ./tokens.json ./transformed-tokens/dark-mode.json \"Spark Colors/Dark mode\" --throwErrorWhenNotResolved",
33
+ "transform:light-mode": "npx token-transformer ./tokens.json ./transformed-tokens/light-mode.json \"Spark Colors/Light mode\" --throwErrorWhenNotResolved",
34
+ "transform:all": "pnpm run transform:global && pnpm run transform:dark-mode && pnpm run transform:light-mode",
35
+ "build:sd": "node ./sd.config.js",
36
+ "build:uno": "vite build",
37
+ "build": "pnpm run transform:all && pnpm run build:sd && pnpm run build:uno"
38
+ }
39
+ }
package/project.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "config-css-preset",
3
+ "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/config-css-preset/src",
5
+ "projectType": "library",
6
+ "targets": {
7
+ "test": {
8
+ "executor": "nx:run-commands",
9
+ "options": {
10
+ "command": "echo \"No tests\""
11
+ }
12
+ }
13
+ },
14
+ "tags": []
15
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "pop-ups-and-modals": "0px 1px 20px 0px #0000001f",
3
+ "dropdowns": "0px 1px 6px 0px #0000001f",
4
+ "banner-and-snackbars": "0px 4px 24px 0px #00000033",
5
+ "left-elevated-card": "5px 5px 6px 0px #0000001f",
6
+ "right-elevated-card": "-5px 5px 6px 0px #0000001f"
7
+ }
@@ -0,0 +1,148 @@
1
+ {
2
+ "core-content-primary": "#f2f2f8",
3
+ "core-content-secondary": "#b9b9ce",
4
+ "core-content-tertiary": "#9595ac",
5
+ "core-content-placeholder": "#9595ac",
6
+ "core-content-on-bg-inverse": "#1e1e23",
7
+ "core-content-always-white": "#fbfbfd",
8
+ "core-content-accent-soft": "#b2bfff",
9
+ "core-content-always-black": "#0f0f12",
10
+ "core-content-link-visited": "#b2bfff",
11
+ "core-bg-primary": "#0f0f12",
12
+ "core-bg-secondary": "#17171c",
13
+ "core-bg-tertiary": "#1e1e23",
14
+ "core-bg-tertiary-hover": "#33333c",
15
+ "core-bg-accent": "#9397fe",
16
+ "core-bg-accent-soft": "#2b1ca3",
17
+ "core-bg-accent-soft-hover": "#3421c7",
18
+ "core-bg-on-color-inverse": "#fbfbfd",
19
+ "core-bg-loading": "#4841f2",
20
+ "core-bg-modal-overlay": "#0f0f12bf",
21
+ "core-bg-gradient-0": "#0f0f1200",
22
+ "core-bg-accent-hover": "#b2bfff",
23
+ "core-bg-text-mark-soft": "#1b125c",
24
+ "core-bg-text-mark-soft-hover": "#231780",
25
+ "core-bg-text-mark": "#2b1ca3",
26
+ "core-bg-text-mark-hover": "#3421c7",
27
+ "core-border-default": "#33333c",
28
+ "core-border-focus": "#9397fe",
29
+ "core-border-hover": "#9595ac",
30
+ "core-border-contrast": "#7f7f94",
31
+ "core-border-contrast-hover": "#ebebf4",
32
+ "core-border-text-mark": "#9397fe",
33
+ "core-border-text-mark-hover": "#b2bfff",
34
+ "brand-content-default": "#0f0f12",
35
+ "brand-content-brand-soft": "#dcf706",
36
+ "brand-bg-brand": "#dcf706",
37
+ "brand-bg-brand-hover": "#bcd902",
38
+ "brand-bg-brand-soft": "#3c4301",
39
+ "brand-border-default": "#bcd902",
40
+ "semantic-content-success": "#fbfbfd",
41
+ "semantic-content-success-soft": "#4ade80",
42
+ "semantic-content-error": "#fbfbfd",
43
+ "semantic-content-error-soft": "#fe8c8c",
44
+ "semantic-content-warning": "#0f0f12",
45
+ "semantic-content-warning-soft": "#facc15",
46
+ "semantic-content-info": "#fbfbfd",
47
+ "semantic-content-info-soft": "#b2bfff",
48
+ "semantic-content-error-label": "#fe8c8c",
49
+ "semantic-content-success-label": "#4ade80",
50
+ "semantic-bg-success": "#166534",
51
+ "semantic-bg-success-soft": "#052e16",
52
+ "semantic-bg-success-action": "#15803d",
53
+ "semantic-bg-success-soft-action": "#0a4d25",
54
+ "semantic-bg-error": "#991b1b",
55
+ "semantic-bg-error-action": "#b91c1c",
56
+ "semantic-bg-error-soft": "#450a0a",
57
+ "semantic-bg-error-soft-action": "#6f1313",
58
+ "semantic-bg-warning": "#eab308",
59
+ "semantic-bg-warning-action": "#facc15",
60
+ "semantic-bg-warning-soft": "#422006",
61
+ "semantic-bg-warning-soft-action": "#64370a",
62
+ "semantic-bg-info": "#3c26eb",
63
+ "semantic-bg-info-action": "#4841f2",
64
+ "semantic-bg-info-soft": "#1b125c",
65
+ "semantic-bg-info-soft-action": "#3421c7",
66
+ "semantic-bg-error-action-hover": "#6f1313",
67
+ "semantic-bg-success-action-hover": "#0a4d25",
68
+ "semantic-border-success": "#15803d",
69
+ "semantic-border-success-soft": "#0a4d25",
70
+ "semantic-border-error": "#b91c1c",
71
+ "semantic-border-error-soft": "#6f1313",
72
+ "semantic-border-warning": "#facc15",
73
+ "semantic-border-warning-soft": "#64370a",
74
+ "semantic-border-info": "#4841f2",
75
+ "semantic-border-info-soft": "#2b1ca3",
76
+ "primitives-neutral-25": "#fbfbfd",
77
+ "primitives-neutral-50": "#f2f2f8",
78
+ "primitives-neutral-100": "#ebebf4",
79
+ "primitives-neutral-150": "#dbdbe9",
80
+ "primitives-neutral-200": "#ccccde",
81
+ "primitives-neutral-300": "#b9b9ce",
82
+ "primitives-neutral-400": "#9595ac",
83
+ "primitives-neutral-450": "#7f7f94",
84
+ "primitives-neutral-500": "#646474",
85
+ "primitives-neutral-600": "#484851",
86
+ "primitives-neutral-700": "#33333c",
87
+ "primitives-neutral-800": "#1e1e23",
88
+ "primitives-neutral-900": "#17171c",
89
+ "primitives-neutral-950": "#0f0f12",
90
+ "primitives-neutral-950-0": "#0f0f1200",
91
+ "primitives-neutral-25-0": "#fbfbfd00",
92
+ "primitives-neutral-950-75": "#0f0f12bf",
93
+ "primitives-brand-25": "#fdffee",
94
+ "primitives-brand-50": "#fbffdc",
95
+ "primitives-brand-100": "#f8ffbf",
96
+ "primitives-brand-200": "#f3ff92",
97
+ "primitives-brand-250": "#e9f781",
98
+ "primitives-brand-300": "#e6f668",
99
+ "primitives-brand-400": "#e0f538",
100
+ "primitives-brand-500": "#dcf706",
101
+ "primitives-brand-550": "#cce804",
102
+ "primitives-brand-600": "#bcd902",
103
+ "primitives-brand-700": "#a5b900",
104
+ "primitives-brand-800": "#798800",
105
+ "primitives-brand-900": "#576200",
106
+ "primitives-brand-950": "#3c4301",
107
+ "primitives-ultramarine-25": "#f4f5ff",
108
+ "primitives-ultramarine-50": "#e5ebff",
109
+ "primitives-ultramarine-100": "#d0daff",
110
+ "primitives-ultramarine-200": "#b2bfff",
111
+ "primitives-ultramarine-300": "#9397fe",
112
+ "primitives-ultramarine-400": "#555cf9",
113
+ "primitives-ultramarine-450": "#4841f2",
114
+ "primitives-ultramarine-500": "#433de2",
115
+ "primitives-ultramarine-600": "#3c26eb",
116
+ "primitives-ultramarine-700": "#3421c7",
117
+ "primitives-ultramarine-800": "#2b1ca3",
118
+ "primitives-ultramarine-900": "#231780",
119
+ "primitives-ultramarine-950": "#1b125c",
120
+ "primitives-green-100": "#dcfce7",
121
+ "primitives-green-200": "#bbf7d0",
122
+ "primitives-green-300": "#70f3a0",
123
+ "primitives-green-400": "#4ade80",
124
+ "primitives-green-700": "#15803d",
125
+ "primitives-green-800": "#166534",
126
+ "primitives-green-900": "#0a4d25",
127
+ "primitives-green-950": "#052e16",
128
+ "primitives-red-100": "#fee2e2",
129
+ "primitives-red-200": "#fecaca",
130
+ "primitives-red-300": "#fe8c8c",
131
+ "primitives-red-400": "#f87171",
132
+ "primitives-red-600": "#dc2626",
133
+ "primitives-red-700": "#b91c1c",
134
+ "primitives-red-800": "#991b1b",
135
+ "primitives-red-900": "#6f1313",
136
+ "primitives-red-950": "#450a0a",
137
+ "primitives-yellow-50": "#fefacf",
138
+ "primitives-yellow-100": "#fef9c3",
139
+ "primitives-yellow-200": "#fef08a",
140
+ "primitives-yellow-300": "#feeb62",
141
+ "primitives-yellow-400": "#fcdc3c",
142
+ "primitives-yellow-500": "#facc15",
143
+ "primitives-yellow-550": "#f2bf0f",
144
+ "primitives-yellow-600": "#eab308",
145
+ "primitives-yellow-800": "#854d0e",
146
+ "primitives-yellow-900": "#64370a",
147
+ "primitives-yellow-950": "#422006"
148
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "linear-gradient-top": "linear-gradient(180deg, #0f0f12 0%, #0f0f1200 100%)",
3
+ "linear-gradient-bottom": "linear-gradient(180deg, #0f0f1200 0%, #0f0f12 100%)"
4
+ }
@@ -0,0 +1,148 @@
1
+ {
2
+ "core-content-primary": "#1e1e23",
3
+ "core-content-secondary": "#484851",
4
+ "core-content-tertiary": "#646474",
5
+ "core-content-placeholder": "#646474",
6
+ "core-content-on-bg-inverse": "#fbfbfd",
7
+ "core-content-always-white": "#f2f2f8",
8
+ "core-content-accent-soft": "#3c26eb",
9
+ "core-content-always-black": "#0f0f12",
10
+ "core-content-link-visited": "#2b1ca3",
11
+ "core-bg-primary": "#fbfbfd",
12
+ "core-bg-secondary": "#f2f2f8",
13
+ "core-bg-tertiary": "#fbfbfd",
14
+ "core-bg-tertiary-hover": "#dbdbe9",
15
+ "core-bg-accent": "#555cf9",
16
+ "core-bg-accent-soft": "#d0daff",
17
+ "core-bg-accent-soft-hover": "#b2bfff",
18
+ "core-bg-on-color-inverse": "#1e1e23",
19
+ "core-bg-loading": "#4841f2",
20
+ "core-bg-modal-overlay": "#0f0f12bf",
21
+ "core-bg-gradient-0": "#fbfbfd00",
22
+ "core-bg-accent-hover": "#433de2",
23
+ "core-bg-text-mark-soft": "#e5ebff",
24
+ "core-bg-text-mark-soft-hover": "#d0daff",
25
+ "core-bg-text-mark": "#b2bfff",
26
+ "core-bg-text-mark-hover": "#9397fe",
27
+ "core-border-default": "#dbdbe9",
28
+ "core-border-focus": "#555cf9",
29
+ "core-border-hover": "#9595ac",
30
+ "core-border-contrast": "#7f7f94",
31
+ "core-border-contrast-hover": "#33333c",
32
+ "core-border-text-mark": "#555cf9",
33
+ "core-border-text-mark-hover": "#433de2",
34
+ "brand-content-default": "#0f0f12",
35
+ "brand-content-brand-soft": "#576200",
36
+ "brand-bg-brand": "#cce804",
37
+ "brand-bg-brand-hover": "#dcf706",
38
+ "brand-bg-brand-soft": "#e9f781",
39
+ "brand-border-default": "#bcd902",
40
+ "semantic-content-success": "#fbfbfd",
41
+ "semantic-content-success-soft": "#166534",
42
+ "semantic-content-error": "#fbfbfd",
43
+ "semantic-content-error-soft": "#991b1b",
44
+ "semantic-content-warning": "#0f0f12",
45
+ "semantic-content-warning-soft": "#854d0e",
46
+ "semantic-content-info": "#fbfbfd",
47
+ "semantic-content-info-soft": "#2b1ca3",
48
+ "semantic-content-error-label": "#dc2626",
49
+ "semantic-content-success-label": "#15803d",
50
+ "semantic-bg-success": "#15803d",
51
+ "semantic-bg-success-soft": "#dcfce7",
52
+ "semantic-bg-success-action": "#166534",
53
+ "semantic-bg-success-soft-action": "#bbf7d0",
54
+ "semantic-bg-error": "#dc2626",
55
+ "semantic-bg-error-action": "#b91c1c",
56
+ "semantic-bg-error-soft": "#fee2e2",
57
+ "semantic-bg-error-soft-action": "#fecaca",
58
+ "semantic-bg-warning": "#fcdc3c",
59
+ "semantic-bg-warning-action": "#f2bf0f",
60
+ "semantic-bg-warning-soft": "#fefacf",
61
+ "semantic-bg-warning-soft-action": "#fef08a",
62
+ "semantic-bg-info": "#433de2",
63
+ "semantic-bg-info-action": "#3421c7",
64
+ "semantic-bg-info-soft": "#e5ebff",
65
+ "semantic-bg-info-soft-action": "#d0daff",
66
+ "semantic-bg-error-action-hover": "#991b1b",
67
+ "semantic-bg-success-action-hover": "#0a4d25",
68
+ "semantic-border-success": "#166534",
69
+ "semantic-border-success-soft": "#bbf7d0",
70
+ "semantic-border-error": "#991b1b",
71
+ "semantic-border-error-soft": "#fecaca",
72
+ "semantic-border-warning": "#facc15",
73
+ "semantic-border-warning-soft": "#fef08a",
74
+ "semantic-border-info": "#3c26eb",
75
+ "semantic-border-info-soft": "#d0daff",
76
+ "primitives-neutral-25": "#fbfbfd",
77
+ "primitives-neutral-50": "#f2f2f8",
78
+ "primitives-neutral-100": "#ebebf4",
79
+ "primitives-neutral-150": "#dbdbe9",
80
+ "primitives-neutral-200": "#ccccde",
81
+ "primitives-neutral-300": "#b9b9ce",
82
+ "primitives-neutral-400": "#9595ac",
83
+ "primitives-neutral-450": "#7f7f94",
84
+ "primitives-neutral-500": "#646474",
85
+ "primitives-neutral-600": "#484851",
86
+ "primitives-neutral-700": "#33333c",
87
+ "primitives-neutral-800": "#1e1e23",
88
+ "primitives-neutral-900": "#17171c",
89
+ "primitives-neutral-950": "#0f0f12",
90
+ "primitives-neutral-950-0": "#0f0f1200",
91
+ "primitives-neutral-25-0": "#fbfbfd00",
92
+ "primitives-neutral-950-75": "#0f0f12bf",
93
+ "primitives-brand-25": "#fdffee",
94
+ "primitives-brand-50": "#fbffdc",
95
+ "primitives-brand-100": "#f8ffbf",
96
+ "primitives-brand-200": "#f3ff92",
97
+ "primitives-brand-250": "#e9f781",
98
+ "primitives-brand-300": "#e6f668",
99
+ "primitives-brand-400": "#e0f538",
100
+ "primitives-brand-500": "#dcf706",
101
+ "primitives-brand-550": "#cce804",
102
+ "primitives-brand-600": "#bcd902",
103
+ "primitives-brand-700": "#a5b900",
104
+ "primitives-brand-800": "#798800",
105
+ "primitives-brand-900": "#576200",
106
+ "primitives-brand-950": "#3c4301",
107
+ "primitives-ultramarine-25": "#f4f5ff",
108
+ "primitives-ultramarine-50": "#e5ebff",
109
+ "primitives-ultramarine-100": "#d0daff",
110
+ "primitives-ultramarine-200": "#b2bfff",
111
+ "primitives-ultramarine-300": "#9397fe",
112
+ "primitives-ultramarine-400": "#555cf9",
113
+ "primitives-ultramarine-450": "#4841f2",
114
+ "primitives-ultramarine-500": "#433de2",
115
+ "primitives-ultramarine-600": "#3c26eb",
116
+ "primitives-ultramarine-700": "#3421c7",
117
+ "primitives-ultramarine-800": "#2b1ca3",
118
+ "primitives-ultramarine-900": "#231780",
119
+ "primitives-ultramarine-950": "#1b125c",
120
+ "primitives-green-100": "#dcfce7",
121
+ "primitives-green-200": "#bbf7d0",
122
+ "primitives-green-300": "#70f3a0",
123
+ "primitives-green-400": "#4ade80",
124
+ "primitives-green-700": "#15803d",
125
+ "primitives-green-800": "#166534",
126
+ "primitives-green-900": "#0a4d25",
127
+ "primitives-green-950": "#052e16",
128
+ "primitives-red-100": "#fee2e2",
129
+ "primitives-red-200": "#fecaca",
130
+ "primitives-red-300": "#fe8c8c",
131
+ "primitives-red-400": "#f87171",
132
+ "primitives-red-600": "#dc2626",
133
+ "primitives-red-700": "#b91c1c",
134
+ "primitives-red-800": "#991b1b",
135
+ "primitives-red-900": "#6f1313",
136
+ "primitives-red-950": "#450a0a",
137
+ "primitives-yellow-50": "#fefacf",
138
+ "primitives-yellow-100": "#fef9c3",
139
+ "primitives-yellow-200": "#fef08a",
140
+ "primitives-yellow-300": "#feeb62",
141
+ "primitives-yellow-400": "#fcdc3c",
142
+ "primitives-yellow-500": "#facc15",
143
+ "primitives-yellow-550": "#f2bf0f",
144
+ "primitives-yellow-600": "#eab308",
145
+ "primitives-yellow-800": "#854d0e",
146
+ "primitives-yellow-900": "#64370a",
147
+ "primitives-yellow-950": "#422006"
148
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "NONE": "0rem",
3
+ "DEFAULT": "0.25rem",
4
+ "MODAL": "0.5rem",
5
+ "CHIPS": "2.75rem",
6
+ "3XS": "0.25rem",
7
+ "XS": "0.5rem",
8
+ "M": "0.75rem",
9
+ "L": "1rem",
10
+ "XL": "1.25rem",
11
+ "XXL": "1.5rem",
12
+ "3XL": "2rem",
13
+ "4XL": "3rem",
14
+ "5XL": "4rem",
15
+ "4XS": "0.125rem",
16
+ "XXS": "0.25rem",
17
+ "S": "0.5rem",
18
+ "LETTERSPACING-0": "0em",
19
+ "PARAGRAPHSPACING-0": "0",
20
+ "PARAGRAPHINDENT-0": "0px"
21
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "heading-30": {"font-family":"Raleway","font-weight":700,"line-height":"normal","font-size":"30px","letter-spacing":"0em","text-decoration":"none"},
3
+ "heading-20": {"font-family":"Raleway","font-weight":700,"line-height":"normal","font-size":"20px","letter-spacing":"0em","text-decoration":"none"},
4
+ "heading-18": {"font-family":"Raleway","font-weight":700,"line-height":"normal","font-size":"18px","letter-spacing":"0em","text-decoration":"none"},
5
+ "heading-16": {"font-family":"Raleway","font-weight":700,"line-height":"24px","font-size":"16px","letter-spacing":"0em","text-decoration":"none"},
6
+ "heading-14": {"font-family":"Raleway","font-weight":600,"line-height":"16px","font-size":"14px","letter-spacing":"0em","text-decoration":"none"},
7
+ "body-16-bold": {"font-family":"Raleway","font-weight":700,"line-height":"24px","font-size":"16px","letter-spacing":"0em","text-decoration":"none"},
8
+ "body-16": {"font-family":"Raleway","font-weight":500,"line-height":"24px","font-size":"16px","letter-spacing":"0em","text-decoration":"none"},
9
+ "body-16-compact": {"font-family":"Raleway","font-weight":500,"line-height":"20px","font-size":"16px","letter-spacing":"0em","text-decoration":"none"},
10
+ "label-14-bold": {"font-family":"Raleway","font-weight":700,"line-height":"normal","font-size":"14px","letter-spacing":"0em","text-decoration":"none"},
11
+ "label-14": {"font-family":"Raleway","font-weight":500,"line-height":"16px","font-size":"14px","letter-spacing":"0em","text-decoration":"none"},
12
+ "label-12-bold": {"font-family":"Raleway","font-weight":700,"line-height":"normal","font-size":"12px","letter-spacing":"0em","text-decoration":"none"},
13
+ "label-12": {"font-family":"Raleway","font-weight":500,"line-height":"normal","font-size":"12px","letter-spacing":"0em","text-decoration":"none"}
14
+ }
package/sd.config.js ADDED
@@ -0,0 +1,190 @@
1
+ import { register } from '@tokens-studio/sd-transforms';
2
+ import StyleDictionary from 'style-dictionary';
3
+
4
+ register(StyleDictionary);
5
+
6
+ /**
7
+ * This is a custom transform that will take a dimension key name and convert it to uppercase, we need to do this to be backwards compabitle with the old utility classes
8
+ * e.g. p-3XL, m-2XL, etc.
9
+ */
10
+ StyleDictionary.registerTransform({
11
+ name: 'custom/name/uppercase-dimensions',
12
+ type: 'name',
13
+ filter: function (token) {
14
+ return token.type === 'dimension';
15
+ },
16
+ transform: function (token) {
17
+ return token.name.toUpperCase().replace('-', '');
18
+ },
19
+ });
20
+
21
+ /**
22
+ * Removes first part of the name and returns the rest due to the naming of the tokens
23
+ * ```json
24
+ * {
25
+ * "heading": {
26
+ * "heading-30": {
27
+ * "value": {...}
28
+ * }
29
+ * ```
30
+ * turns to `heading-30` instead of `heading-heading-30
31
+ */
32
+ StyleDictionary.registerTransform({
33
+ name: 'custom/name/typography',
34
+ type: 'name',
35
+ filter: function (token) {
36
+ return token.type === 'typography';
37
+ },
38
+ transform: function (token) {
39
+ return token.name.split('-').splice(1, token.name.split('-').length).join('-');
40
+ },
41
+ });
42
+
43
+ /**
44
+ * Transforms box shadow tokens to a css box-shadow string
45
+ */
46
+
47
+ StyleDictionary.registerTransform({
48
+ name: 'custom/shadow/css',
49
+ type: 'value',
50
+ filter: function (token) {
51
+ return token.type === 'shadow';
52
+ },
53
+ transform: function (prop) {
54
+ const { offsetX, offsetY, blur, spread, color } = prop.original.value;
55
+
56
+ return `${offsetX}px ${offsetY}px ${blur}px ${spread}px ${color}`;
57
+ },
58
+ });
59
+
60
+ /**
61
+ * This transforms the object keys of a typography token to kebab-case
62
+ * and only allows certain keys to be included in the final output which can be used in css
63
+ */
64
+ StyleDictionary.registerTransform({
65
+ name: 'custom/typography/keys/css',
66
+ type: `value`,
67
+ transitive: true,
68
+ filter: function (token) {
69
+ return token.type === 'typography';
70
+ },
71
+ transform: ({ value }) => {
72
+ if (!value) return;
73
+
74
+ const keys = Object.keys(value);
75
+ const allowedKeys = [
76
+ 'font-family',
77
+ 'font-weight',
78
+ 'line-height',
79
+ 'font-size',
80
+ 'letter-spacing',
81
+ 'text-decoration',
82
+ ];
83
+
84
+ const css = {};
85
+ keys.forEach((key) => {
86
+ const newKey = key.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
87
+
88
+ if (allowedKeys.includes(newKey)) {
89
+ css[newKey] = value[key];
90
+ }
91
+ });
92
+
93
+ return css;
94
+ },
95
+ });
96
+
97
+ /**
98
+ * This transform will convert the line-height value of a typography token to 'normal' if it is 'AUTO' and set numbers without units to pixels
99
+ * This is because 'normal' is the default value for line-height in css and AUTO can not be interpreted by CSS
100
+ */
101
+ StyleDictionary.registerTransform({
102
+ name: 'custom/typography/line-height',
103
+ type: `value`,
104
+ transitive: true,
105
+ filter: function (token) {
106
+ return token.type === 'typography';
107
+ },
108
+ transform: ({ value }) => {
109
+ if (!value) return;
110
+
111
+ if (value['line-height'] === 'AUTO') {
112
+ value['line-height'] = 'normal';
113
+ } else if (!isNaN(Number(value['line-height']))) {
114
+ value['line-height'] = `${value['line-height']}px`;
115
+ }
116
+
117
+ return value;
118
+ },
119
+ });
120
+
121
+ function getStyleDictionaryConfig(theme) {
122
+ return {
123
+ source: [`./transformed-tokens/${theme}.json`],
124
+ preprocessors: ['tokens-studio'],
125
+ platforms: {
126
+ web: {
127
+ transforms: [
128
+ 'name/kebab',
129
+ 'custom/name/uppercase-dimensions',
130
+ 'ts/size/px',
131
+ 'ts/size/lineheight',
132
+ 'ts/typography/fontWeight',
133
+ 'ts/size/css/letterspacing',
134
+ 'custom/typography/keys/css',
135
+ 'custom/name/typography',
136
+ 'custom/shadow/css',
137
+ 'custom/typography/line-height',
138
+ ],
139
+ buildPath: `./sd-output/`,
140
+ files: [
141
+ {
142
+ destination: `${theme}.json`,
143
+ format: 'json/flat',
144
+ filter: function (token) {
145
+ return token.type === 'color';
146
+ },
147
+ },
148
+ {
149
+ destination: 'spacings.json',
150
+ format: 'json/flat',
151
+ filter: function (token) {
152
+ return token.type === 'dimension';
153
+ },
154
+ },
155
+ {
156
+ destination: 'box-shadows.json',
157
+ format: 'json/flat',
158
+ filter: function (token) {
159
+ return token.type === 'shadow';
160
+ },
161
+ },
162
+ {
163
+ destination: 'typography.json',
164
+ format: 'json/flat',
165
+ filter: function (token) {
166
+ return token.type === 'typography';
167
+ },
168
+ },
169
+ ],
170
+ },
171
+ },
172
+ };
173
+ }
174
+
175
+ console.log('Build started...');
176
+
177
+ ['global', 'dark-mode', 'light-mode'].map(async function (set) {
178
+ console.log('\n==============================================');
179
+ console.log(`\nProcessing: [${set}]`);
180
+
181
+ const sd = new StyleDictionary(getStyleDictionaryConfig(set));
182
+
183
+ await sd.cleanAllPlatforms();
184
+ await sd.buildAllPlatforms();
185
+
186
+ console.log('\nEnd processing');
187
+ });
188
+
189
+ console.log('\n==============================================');
190
+ console.log('\nBuild completed!');