@apify/ui-library 0.76.2-featcolortokens-178953.24 → 0.76.3

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 (79) hide show
  1. package/.stylelintrc +12 -0
  2. package/CHANGELOG.md +3454 -0
  3. package/CODEOWNERS +7 -0
  4. package/README.md +5 -18
  5. package/dist/src/components/button.js +1 -1
  6. package/dist/src/components/button.js.map +1 -1
  7. package/dist/src/design_system/colors_theme.d.ts +213 -0
  8. package/dist/src/design_system/colors_theme.d.ts.map +1 -0
  9. package/dist/src/design_system/colors_theme.js +213 -0
  10. package/dist/src/design_system/colors_theme.js.map +1 -0
  11. package/dist/src/design_system/{colors/generated/properties_theme.d.ts → properties_theme.d.ts} +14 -18
  12. package/dist/src/design_system/properties_theme.d.ts.map +1 -0
  13. package/dist/src/design_system/{colors/generated/properties_theme.js → properties_theme.js} +154 -18
  14. package/dist/src/design_system/properties_theme.js.map +1 -0
  15. package/dist/src/design_system/theme.d.ts +87 -88
  16. package/dist/src/design_system/theme.d.ts.map +1 -1
  17. package/dist/src/design_system/theme.js +2 -1
  18. package/dist/src/design_system/theme.js.map +1 -1
  19. package/dist/src/index.d.ts +0 -1
  20. package/dist/src/index.d.ts.map +1 -1
  21. package/dist/src/index.js +0 -1
  22. package/dist/src/index.js.map +1 -1
  23. package/dist/tsconfig.build.tsbuildinfo +1 -1
  24. package/eslint.config.mjs +45 -0
  25. package/package.json +5 -11
  26. package/src/codemods/generate_color_property_tokens.mjs +98 -0
  27. package/src/codemods/generate_color_theme_files.mjs +47 -0
  28. package/src/components/button.tsx +1 -1
  29. package/src/design_system/{colors/generated/colors_theme.light.ts → colors_theme.ts} +143 -40
  30. package/src/design_system/generate_color_definitions.js +44 -0
  31. package/src/design_system/{colors/generated/properties_theme.ts → properties_theme.ts} +293 -19
  32. package/src/design_system/supernova_color_tokens.json +1766 -0
  33. package/src/design_system/theme.ts +2 -1
  34. package/src/index.ts +0 -1
  35. package/tsconfig.build.json +17 -0
  36. package/tsconfig.json +10 -0
  37. package/dist/src/design_system/colors/generated/colors_theme.dark.d.ts +0 -110
  38. package/dist/src/design_system/colors/generated/colors_theme.dark.d.ts.map +0 -1
  39. package/dist/src/design_system/colors/generated/colors_theme.dark.js +0 -110
  40. package/dist/src/design_system/colors/generated/colors_theme.dark.js.map +0 -1
  41. package/dist/src/design_system/colors/generated/colors_theme.light.d.ts +0 -110
  42. package/dist/src/design_system/colors/generated/colors_theme.light.d.ts.map +0 -1
  43. package/dist/src/design_system/colors/generated/colors_theme.light.js +0 -110
  44. package/dist/src/design_system/colors/generated/colors_theme.light.js.map +0 -1
  45. package/dist/src/design_system/colors/generated/css_variables.dark.d.ts +0 -5
  46. package/dist/src/design_system/colors/generated/css_variables.dark.d.ts.map +0 -1
  47. package/dist/src/design_system/colors/generated/css_variables.dark.js +0 -147
  48. package/dist/src/design_system/colors/generated/css_variables.dark.js.map +0 -1
  49. package/dist/src/design_system/colors/generated/css_variables.light.d.ts +0 -5
  50. package/dist/src/design_system/colors/generated/css_variables.light.d.ts.map +0 -1
  51. package/dist/src/design_system/colors/generated/css_variables.light.js +0 -147
  52. package/dist/src/design_system/colors/generated/css_variables.light.js.map +0 -1
  53. package/dist/src/design_system/colors/generated/css_variables_palette.dark.d.ts +0 -5
  54. package/dist/src/design_system/colors/generated/css_variables_palette.dark.d.ts.map +0 -1
  55. package/dist/src/design_system/colors/generated/css_variables_palette.dark.js +0 -74
  56. package/dist/src/design_system/colors/generated/css_variables_palette.dark.js.map +0 -1
  57. package/dist/src/design_system/colors/generated/css_variables_palette.light.d.ts +0 -5
  58. package/dist/src/design_system/colors/generated/css_variables_palette.light.d.ts.map +0 -1
  59. package/dist/src/design_system/colors/generated/css_variables_palette.light.js +0 -74
  60. package/dist/src/design_system/colors/generated/css_variables_palette.light.js.map +0 -1
  61. package/dist/src/design_system/colors/generated/properties_theme.d.ts.map +0 -1
  62. package/dist/src/design_system/colors/generated/properties_theme.js.map +0 -1
  63. package/dist/src/design_system/colors/index.d.ts +0 -8
  64. package/dist/src/design_system/colors/index.d.ts.map +0 -1
  65. package/dist/src/design_system/colors/index.js +0 -8
  66. package/dist/src/design_system/colors/index.js.map +0 -1
  67. package/src/design_system/colors/build_color_tokens.js +0 -183
  68. package/src/design_system/colors/figma_color_tokens.dark.json +0 -886
  69. package/src/design_system/colors/figma_color_tokens.light.json +0 -886
  70. package/src/design_system/colors/generated/colors_theme.dark.ts +0 -110
  71. package/src/design_system/colors/generated/css_variables.dark.ts +0 -147
  72. package/src/design_system/colors/generated/css_variables.light.ts +0 -147
  73. package/src/design_system/colors/generated/css_variables_palette.dark.ts +0 -74
  74. package/src/design_system/colors/generated/css_variables_palette.light.ts +0 -74
  75. package/src/design_system/colors/index.ts +0 -7
  76. package/style/colors/dark.scss +0 -148
  77. package/style/colors/light.scss +0 -148
  78. package/style/colors/palette.dark.scss +0 -75
  79. package/style/colors/palette.light.scss +0 -75
@@ -1,183 +0,0 @@
1
- import StyleDictionary from 'style-dictionary';
2
-
3
- const DO_NOT_EXPORT_COMMENT = `/**
4
- * Do not edit directly, this file was auto-generated.
5
- */
6
- `;
7
-
8
- function toCamelCase(str) {
9
- return str
10
- .toLowerCase()
11
- .replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());
12
- }
13
-
14
- /**
15
- * Converts an object to a TypeScript literal representation with proper indentation
16
- * that can be written to a TypeScript file.
17
- */
18
- function objectToTSLiteral(obj, indentLevel = 0) {
19
- const indent = (level) => ' '.repeat(level); // 2-space indent
20
-
21
- if (obj && typeof obj === 'object') {
22
- const entries = Object.entries(obj);
23
- if (entries.length === 0) return '{}';
24
- return `{\n${entries
25
- .map(
26
- ([key, value]) => `${indent(indentLevel + 1)}${key}: ${objectToTSLiteral(value, indentLevel + 1)}`,
27
- )
28
- .join('\n')}\n${indent(indentLevel)}}${indentLevel > 0 ? ',' : ''}`;
29
- } if (typeof obj === 'string') {
30
- return `'${obj}',`;
31
- }
32
- return String(obj);
33
- }
34
-
35
- /**
36
- * Build color tokens for a given theme.
37
- * @param theme {string} - The theme to build tokens, 'light' or 'dark'.
38
- */
39
- async function buildTheme(theme) {
40
- // Transform to replace 'semantic' and 'decorative' with 'color' in token names
41
- // Example: 'semantic-neutral-text' becomes 'color-neutral-text'
42
- StyleDictionary.registerTransform({
43
- name: 'name/prefix-color-name',
44
- type: 'name',
45
- transform: (prop) => {
46
- return prop.name
47
- .replace(/^semantic/, 'color')
48
- .replace(/^decorative/, 'color');
49
- },
50
- });
51
-
52
- // Format to generate typescript file that exports CSS variables as a string
53
- // Example: export const tokens = `--color-neutral-text: #000; --color-primary: #fff;`
54
- StyleDictionary.registerFormat({
55
- name: 'typescript/css-variables-string',
56
- format: ({ dictionary, options }) => {
57
- const lines = dictionary.allTokens.map((token) => ` --${token.name}: ${token.$value};`);
58
- return `${DO_NOT_EXPORT_COMMENT}\nexport const ${options.varName ?? 'tokens'} = \`\n${lines.join('\n')}\n\`;\n`;
59
- },
60
- });
61
-
62
- // Format to generate typescript file that exports CSS properties as an object
63
- // Example: export const tokens = { colorNeutralText: 'var(--color-neutral-text)', colorPrimary: 'var(--color-primary)' };
64
- StyleDictionary.registerFormat({
65
- name: 'typescript/css-color-properties',
66
- format: ({ dictionary, options }) => {
67
- const properties = {};
68
- dictionary.allTokens.forEach((token) => {
69
- const path = token.path.slice(1).map(toCamelCase);
70
- let current = properties;
71
- for (let i = 0; i < path.length - 1; i++) {
72
- const key = path[i];
73
- if (!(key in current)) {
74
- current[key] = {};
75
- }
76
- current = current[key];
77
- }
78
- current[path[path.length - 1]] = `var(--${token.name})`;
79
- });
80
-
81
- return `${DO_NOT_EXPORT_COMMENT}\nexport const ${options.varName ?? 'tokens'} = ${objectToTSLiteral(properties)} as const;\n`;
82
- },
83
- });
84
-
85
- // Format to generate typescript file that exports CSS colors as an object
86
- // Example: export const tokens = { colorNeutralText: '#000', colorPrimary: '#fff' };
87
- StyleDictionary.registerFormat({
88
- name: 'typescript/css-color-values',
89
- format: ({ dictionary, options }) => {
90
- const properties = {};
91
- dictionary.allTokens.forEach((token) => {
92
- const path = token.path.slice(1);
93
- const name = toCamelCase(path.join(' '));
94
- properties[name] = token.$value;
95
- });
96
-
97
- return `${DO_NOT_EXPORT_COMMENT}\nexport const ${options.varName ?? 'tokens'} = ${objectToTSLiteral(properties)} as const;\n`;
98
- },
99
- });
100
-
101
- // Select only tokens for semantic and decorative colors
102
- StyleDictionary.registerFilter({
103
- name: 'only-colors',
104
- filter: (token) => ['Semantic', 'Decorative'].includes(token.path[0]),
105
- });
106
-
107
- // Select only tokens for palette colors
108
- StyleDictionary.registerFilter({
109
- name: 'only-palette',
110
- filter: (token) => ['Palette'].includes(token.path[0]),
111
- });
112
-
113
- // Select only tokens for theme colors (Decorative and Palette)
114
- StyleDictionary.registerFilter({
115
- name: 'only-theme',
116
- filter: (token) => ['Decorative', 'Palette'].includes(token.path[0]),
117
- });
118
-
119
- const styleDictionary = await (new StyleDictionary()).extend({
120
- source: [`src/design_system/colors/figma_color_tokens.${theme}.json`],
121
- platforms: {
122
- ts: {
123
- transformGroup: 'scss',
124
- transforms: ['name/prefix-color-name'],
125
- buildPath: 'src/design_system/colors/generated/',
126
- files: [
127
- {
128
- destination: `css_variables.${theme}.ts`,
129
- format: 'typescript/css-variables-string',
130
- filter: 'only-colors',
131
- },
132
- {
133
- destination: `css_variables_palette.${theme}.ts`,
134
- format: 'typescript/css-variables-string',
135
- filter: 'only-palette',
136
- },
137
- {
138
- destination: `properties_theme.ts`,
139
- format: 'typescript/css-color-properties',
140
- filter: 'only-colors',
141
- options: {
142
- varName: 'colorProperties',
143
- },
144
- },
145
- {
146
- destination: `colors_theme.${theme}.ts`,
147
- format: 'typescript/css-color-values',
148
- filter: 'only-theme',
149
- options: {
150
- varName: `${theme}Theme`,
151
- },
152
- },
153
- ],
154
- },
155
- style: {
156
- transformGroup: 'scss',
157
- transforms: ['name/prefix-color-name'],
158
- buildPath: 'style/colors/',
159
- files: [
160
- {
161
- destination: `${theme}.scss`,
162
- format: 'scss/map-flat',
163
- mapName: 'tokens',
164
- filter: 'only-colors',
165
- },
166
- {
167
- destination: `palette.${theme}.scss`,
168
- format: 'scss/map-flat',
169
- mapName: 'tokens',
170
- filter: 'only-palette',
171
- },
172
- ],
173
- },
174
- },
175
- });
176
- await styleDictionary.buildPlatform('ts');
177
- await styleDictionary.buildPlatform('style');
178
- }
179
-
180
- await Promise.all([
181
- buildTheme('light'),
182
- buildTheme('dark'),
183
- ]);