@sumup-oss/design-tokens 11.0.0-next.1 → 11.0.0-next.2

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.
Files changed (49) hide show
  1. package/dist/{es/scripts → scripts}/build.js +6 -1
  2. package/package.json +9 -7
  3. package/dist/cjs/index.js +0 -63
  4. package/dist/cjs/scripts/build.js +0 -233
  5. package/dist/cjs/themes/consumer.js +0 -816
  6. package/dist/cjs/themes/dark.js +0 -816
  7. package/dist/cjs/themes/fonts.js +0 -129
  8. package/dist/cjs/themes/legacy/light.js +0 -199
  9. package/dist/cjs/themes/light.js +0 -816
  10. package/dist/cjs/themes/schema.js +0 -509
  11. package/dist/cjs/themes/shared.js +0 -598
  12. package/dist/cjs/types/index.js +0 -16
  13. package/dist/es/index.d.ts +0 -26
  14. package/dist/es/scripts/build.d.ts +0 -38
  15. package/dist/es/themes/consumer.d.ts +0 -651
  16. package/dist/es/themes/dark.d.ts +0 -651
  17. package/dist/es/themes/fonts.d.ts +0 -81
  18. package/dist/es/themes/legacy/light.d.ts +0 -88
  19. package/dist/es/themes/light.d.ts +0 -651
  20. package/dist/es/themes/schema.d.ts +0 -1182
  21. package/dist/es/themes/shared.d.ts +0 -464
  22. package/dist/es/types/index.d.ts +0 -191
  23. /package/{consumer-scoped.css → dist/consumer-scoped.css} +0 -0
  24. /package/{consumer.css → dist/consumer.css} +0 -0
  25. /package/{dark-scoped.css → dist/dark-scoped.css} +0 -0
  26. /package/{dark.css → dist/dark.css} +0 -0
  27. /package/{dynamic.css → dist/dynamic.css} +0 -0
  28. /package/{fonts.css → dist/fonts.css} +0 -0
  29. /package/dist/{cjs/index.d.ts → index.d.ts} +0 -0
  30. /package/dist/{es/index.js → index.js} +0 -0
  31. /package/{light-scoped.css → dist/light-scoped.css} +0 -0
  32. /package/{light.css → dist/light.css} +0 -0
  33. /package/dist/{cjs/scripts → scripts}/build.d.ts +0 -0
  34. /package/dist/{cjs/themes → themes}/consumer.d.ts +0 -0
  35. /package/dist/{es/themes → themes}/consumer.js +0 -0
  36. /package/dist/{cjs/themes → themes}/dark.d.ts +0 -0
  37. /package/dist/{es/themes → themes}/dark.js +0 -0
  38. /package/dist/{cjs/themes → themes}/fonts.d.ts +0 -0
  39. /package/dist/{es/themes → themes}/fonts.js +0 -0
  40. /package/dist/{cjs/themes → themes}/legacy/light.d.ts +0 -0
  41. /package/dist/{es/themes → themes}/legacy/light.js +0 -0
  42. /package/dist/{cjs/themes → themes}/light.d.ts +0 -0
  43. /package/dist/{es/themes → themes}/light.js +0 -0
  44. /package/dist/{cjs/themes → themes}/schema.d.ts +0 -0
  45. /package/dist/{es/themes → themes}/schema.js +0 -0
  46. /package/dist/{cjs/themes → themes}/shared.d.ts +0 -0
  47. /package/dist/{es/themes → themes}/shared.js +0 -0
  48. /package/dist/{cjs/types → types}/index.d.ts +0 -0
  49. /package/dist/{es/types → types}/index.js +0 -0
@@ -23,6 +23,7 @@ import { light } from '../themes/light.js';
23
23
  import { dark } from '../themes/dark.js';
24
24
  import { consumer } from '../themes/consumer.js';
25
25
  import { sumup } from '../themes/fonts.js';
26
+ import { fileURLToPath } from 'node:url';
26
27
  function main() {
27
28
  const files = {
28
29
  'light': [
@@ -134,7 +135,11 @@ function main() {
134
135
  const targets = browserslistToTargets(browserslist());
135
136
  Object.entries(files).forEach(([name, configs]) => {
136
137
  const filename = `${name}.css`;
137
- const filepath = path.join(__dirname, '../', filename);
138
+ /* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */
139
+ const __filename = fileURLToPath(import.meta.url);
140
+ const __dirname = path.dirname(__filename);
141
+ /* eslint-enable no-underscore-dangle, @typescript-eslint/naming-convention */
142
+ const filepath = path.join(__dirname, '../dist/', filename);
138
143
  const styles = configs
139
144
  .map((config) => {
140
145
  switch (config.type) {
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@sumup-oss/design-tokens",
3
- "version": "11.0.0-next.1",
3
+ "version": "11.0.0-next.2",
4
4
  "description": "Visual primitives such as typography, color, and spacing that are shared across platforms.",
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/es/index.js",
7
- "types": "dist/es/index.d.ts",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": "./dist/index.js",
10
+ "./*.css": "./dist/*.css"
11
+ },
8
12
  "sideEffects": false,
9
13
  "files": [
10
14
  "dist",
@@ -25,9 +29,7 @@
25
29
  "homepage": "https://github.com/sumup-oss/circuit-ui/tree/main/packages/design-tokens/README.md",
26
30
  "scripts": {
27
31
  "start": "tsc --watch",
28
- "build": "npm run build:es && npm run build:cjs && npm run build:styles",
29
- "build:es": "tsc",
30
- "build:cjs": "tsc --project tsconfig.cjs.json",
32
+ "build": "tsc && npm run build:styles",
31
33
  "build:styles": "tsx ./scripts/build.ts",
32
34
  "lint": "foundry run eslint . --ext .js,.jsx,.ts,.tsx",
33
35
  "lint:fix": "npm run lint -- --fix",
package/dist/cjs/index.js DELETED
@@ -1,63 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright 2020, SumUp Ltd.
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- var desc = Object.getOwnPropertyDescriptor(m, k);
19
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
20
- desc = { enumerable: true, get: function() { return m[k]; } };
21
- }
22
- Object.defineProperty(o, k2, desc);
23
- }) : (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- o[k2] = m[k];
26
- }));
27
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
- Object.defineProperty(o, "default", { enumerable: true, value: v });
29
- }) : function(o, v) {
30
- o["default"] = v;
31
- });
32
- var __importStar = (this && this.__importStar) || (function () {
33
- var ownKeys = function(o) {
34
- ownKeys = Object.getOwnPropertyNames || function (o) {
35
- var ar = [];
36
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
37
- return ar;
38
- };
39
- return ownKeys(o);
40
- };
41
- return function (mod) {
42
- if (mod && mod.__esModule) return mod;
43
- var result = {};
44
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
45
- __setModuleDefault(result, mod);
46
- return result;
47
- };
48
- })();
49
- Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.light = exports.schema = void 0;
51
- const legacy = __importStar(require("./themes/legacy/light.js"));
52
- var schema_js_1 = require("./themes/schema.js");
53
- Object.defineProperty(exports, "schema", { enumerable: true, get: function () { return schema_js_1.schema; } });
54
- /**
55
- * @deprecated
56
- *
57
- * Use the CSS custom properties from `@sumup-oss/design-tokens` instead.
58
- * Use the [`circuit-ui/prefer-custom-properties`](https://github.com/sumup-oss/circuit-ui/tree/main/packages/eslint-plugin-circuit-ui/prefer-custom-properties)
59
- * ESLint rule to automatically migrate your code.
60
- */
61
- // HACK: Copy the theme, otherwise, it gets exported as 'module'.
62
- const light = { ...legacy };
63
- exports.light = light;
@@ -1,233 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- /**
4
- * Copyright 2023, SumUp Ltd.
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.validateTokens = validateTokens;
22
- exports.createCSSCustomProperties = createCSSCustomProperties;
23
- exports.createFontFaceDeclarations = createFontFaceDeclarations;
24
- const node_fs_1 = __importDefault(require("node:fs"));
25
- const node_path_1 = __importDefault(require("node:path"));
26
- const browserslist_1 = __importDefault(require("browserslist"));
27
- const lightningcss_1 = require("lightningcss");
28
- const schema_js_1 = require("../themes/schema.js");
29
- const shared_js_1 = require("../themes/shared.js");
30
- const light_js_1 = require("../themes/light.js");
31
- const dark_js_1 = require("../themes/dark.js");
32
- const consumer_js_1 = require("../themes/consumer.js");
33
- const fonts_js_1 = require("../themes/fonts.js");
34
- function main() {
35
- const files = {
36
- 'light': [
37
- {
38
- type: 'tokens',
39
- tokens: [...light_js_1.light, ...shared_js_1.shared],
40
- selectors: [':root, ::backdrop'],
41
- colorScheme: 'light',
42
- },
43
- {
44
- type: 'tokens',
45
- tokens: shared_js_1.sharedUntilGiga,
46
- selectors: ['@media (max-width: 959px)', ':root, ::backdrop'],
47
- },
48
- ],
49
- 'dark': [
50
- {
51
- type: 'tokens',
52
- tokens: [...dark_js_1.dark, ...shared_js_1.shared],
53
- selectors: [':root, ::backdrop'],
54
- colorScheme: 'dark',
55
- },
56
- {
57
- type: 'tokens',
58
- tokens: shared_js_1.sharedUntilGiga,
59
- selectors: ['@media (max-width: 959px)', ':root, ::backdrop'],
60
- },
61
- ],
62
- 'light-scoped': [
63
- {
64
- type: 'tokens',
65
- tokens: light_js_1.light,
66
- selectors: ['[data-color-scheme="light"]'],
67
- colorScheme: 'light',
68
- },
69
- {
70
- type: 'tokens',
71
- tokens: shared_js_1.sharedUntilGiga,
72
- selectors: ['@media (max-width: 959px)', '[data-color-scheme="light"]'],
73
- },
74
- ],
75
- 'dark-scoped': [
76
- {
77
- type: 'tokens',
78
- tokens: dark_js_1.dark,
79
- selectors: ['[data-color-scheme="dark"]'],
80
- colorScheme: 'dark',
81
- },
82
- {
83
- type: 'tokens',
84
- tokens: shared_js_1.sharedUntilGiga,
85
- selectors: ['@media (max-width: 959px)', '[data-color-scheme="dark"]'],
86
- },
87
- ],
88
- 'dynamic': [
89
- {
90
- type: 'tokens',
91
- tokens: [...light_js_1.light, ...shared_js_1.shared],
92
- selectors: [':root, ::backdrop'],
93
- colorScheme: 'light',
94
- },
95
- {
96
- type: 'tokens',
97
- tokens: shared_js_1.sharedUntilGiga,
98
- selectors: ['@media (max-width: 959px)', ':root, ::backdrop'],
99
- },
100
- {
101
- type: 'tokens',
102
- tokens: dark_js_1.dark,
103
- selectors: ['@media (prefers-color-scheme: dark)', ':root, ::backdrop'],
104
- colorScheme: 'dark',
105
- },
106
- {
107
- type: 'tokens',
108
- tokens: light_js_1.light,
109
- selectors: ['[data-color-scheme="light"]'],
110
- colorScheme: 'light',
111
- },
112
- {
113
- type: 'tokens',
114
- tokens: dark_js_1.dark,
115
- selectors: ['[data-color-scheme="dark"]'],
116
- colorScheme: 'dark',
117
- },
118
- ],
119
- 'consumer': [
120
- {
121
- type: 'tokens',
122
- tokens: [...consumer_js_1.consumer, ...shared_js_1.shared],
123
- selectors: [':root, ::backdrop'],
124
- colorScheme: 'dark',
125
- },
126
- ],
127
- 'consumer-scoped': [
128
- {
129
- type: 'tokens',
130
- tokens: [...consumer_js_1.consumer, ...shared_js_1.shared],
131
- selectors: ['[data-color-scheme="consumer"]'],
132
- colorScheme: 'dark',
133
- },
134
- ],
135
- 'fonts': [
136
- {
137
- type: 'font-faces',
138
- fontFaces: fonts_js_1.sumup,
139
- },
140
- ],
141
- };
142
- const targets = (0, lightningcss_1.browserslistToTargets)((0, browserslist_1.default)());
143
- Object.entries(files).forEach(([name, configs]) => {
144
- const filename = `${name}.css`;
145
- const filepath = node_path_1.default.join(__dirname, '../', filename);
146
- const styles = configs
147
- .map((config) => {
148
- switch (config.type) {
149
- case 'tokens': {
150
- validateTokens(config.tokens);
151
- return createCSSCustomProperties(config);
152
- }
153
- case 'font-faces': {
154
- return createFontFaceDeclarations(config);
155
- }
156
- default: {
157
- throw new Error('Unsupported config type');
158
- }
159
- }
160
- })
161
- .join('\n');
162
- const { code } = (0, lightningcss_1.transform)({
163
- filename,
164
- code: Buffer.from(styles),
165
- targets,
166
- });
167
- node_fs_1.default.writeFileSync(filepath, code, { flag: 'w' });
168
- });
169
- }
170
- /**
171
- * Validates that the token values match the expected type.
172
- */
173
- function validateTokens(tokens) {
174
- tokens.forEach(({ name, type }) => {
175
- const token = schema_js_1.schema.find((t) => t.name === name);
176
- if (!token) {
177
- return;
178
- }
179
- if (token.type !== type) {
180
- throw new Error([
181
- `The "${name}" token does not match the expected type.`,
182
- `Expected "${token.type}". Received "${type}."`,
183
- ].join(' '));
184
- }
185
- });
186
- }
187
- /**
188
- * Generates CSS custom properties from the tokens
189
- */
190
- function createCSSCustomProperties(config) {
191
- const selectorStart = config.selectors
192
- .map((selector) => `${selector} {`)
193
- .join('');
194
- const selectorEnd = config.selectors.map(() => '}').join('');
195
- const colorScheme = config.colorScheme
196
- ? `color-scheme: ${config.colorScheme};`
197
- : '';
198
- const customProperties = config.tokens
199
- .flatMap((token) => {
200
- const { description, name, value } = token;
201
- const lines = [];
202
- if (description) {
203
- lines.push(`/* ${description} */`);
204
- }
205
- lines.push(`${name}: ${value.toString()};`);
206
- return lines;
207
- })
208
- .join(' ');
209
- return `${selectorStart}
210
- ${colorScheme}
211
- ${customProperties}
212
- ${selectorEnd}`;
213
- }
214
- /**
215
- * Generates font face declarations from the font faces
216
- */
217
- function createFontFaceDeclarations(config) {
218
- return config.fontFaces
219
- .map((fontFace) => {
220
- const properties = Object.entries(fontFace)
221
- .map(([name, value]) => `${name}: ${value};`)
222
- .join('');
223
- return `@font-face { ${properties} }`;
224
- })
225
- .join(' ');
226
- }
227
- try {
228
- main();
229
- }
230
- catch (error) {
231
- console.error(error.message);
232
- process.exit(1);
233
- }