@apify/ui-library 0.74.2-featCodeBlockWithTabsoptimis-e30911.3 → 0.74.2-featcolortokens-178953.24

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 (81) hide show
  1. package/README.md +18 -5
  2. package/dist/src/components/code/code_block/code_block_with_tabs.d.ts +1 -2
  3. package/dist/src/components/code/code_block/code_block_with_tabs.d.ts.map +1 -1
  4. package/dist/src/components/code/code_block/code_block_with_tabs.js +2 -2
  5. package/dist/src/components/code/code_block/code_block_with_tabs.js.map +1 -1
  6. package/dist/src/design_system/colors/generated/colors_theme.dark.d.ts +110 -0
  7. package/dist/src/design_system/colors/generated/colors_theme.dark.d.ts.map +1 -0
  8. package/dist/src/design_system/colors/generated/colors_theme.dark.js +110 -0
  9. package/dist/src/design_system/colors/generated/colors_theme.dark.js.map +1 -0
  10. package/dist/src/design_system/colors/generated/colors_theme.light.d.ts +110 -0
  11. package/dist/src/design_system/colors/generated/colors_theme.light.d.ts.map +1 -0
  12. package/dist/src/design_system/colors/generated/colors_theme.light.js +110 -0
  13. package/dist/src/design_system/colors/generated/colors_theme.light.js.map +1 -0
  14. package/dist/src/design_system/colors/generated/css_variables.dark.d.ts +5 -0
  15. package/dist/src/design_system/colors/generated/css_variables.dark.d.ts.map +1 -0
  16. package/dist/src/design_system/colors/generated/css_variables.dark.js +147 -0
  17. package/dist/src/design_system/colors/generated/css_variables.dark.js.map +1 -0
  18. package/dist/src/design_system/colors/generated/css_variables.light.d.ts +5 -0
  19. package/dist/src/design_system/colors/generated/css_variables.light.d.ts.map +1 -0
  20. package/dist/src/design_system/colors/generated/css_variables.light.js +147 -0
  21. package/dist/src/design_system/colors/generated/css_variables.light.js.map +1 -0
  22. package/dist/src/design_system/colors/generated/css_variables_palette.dark.d.ts +5 -0
  23. package/dist/src/design_system/colors/generated/css_variables_palette.dark.d.ts.map +1 -0
  24. package/dist/src/design_system/colors/generated/css_variables_palette.dark.js +74 -0
  25. package/dist/src/design_system/colors/generated/css_variables_palette.dark.js.map +1 -0
  26. package/dist/src/design_system/colors/generated/css_variables_palette.light.d.ts +5 -0
  27. package/dist/src/design_system/colors/generated/css_variables_palette.light.d.ts.map +1 -0
  28. package/dist/src/design_system/colors/generated/css_variables_palette.light.js +74 -0
  29. package/dist/src/design_system/colors/generated/css_variables_palette.light.js.map +1 -0
  30. package/dist/src/design_system/{properties_theme.d.ts → colors/generated/properties_theme.d.ts} +18 -14
  31. package/dist/src/design_system/colors/generated/properties_theme.d.ts.map +1 -0
  32. package/dist/src/design_system/{properties_theme.js → colors/generated/properties_theme.js} +18 -154
  33. package/dist/src/design_system/colors/generated/properties_theme.js.map +1 -0
  34. package/dist/src/design_system/colors/index.d.ts +8 -0
  35. package/dist/src/design_system/colors/index.d.ts.map +1 -0
  36. package/dist/src/design_system/colors/index.js +8 -0
  37. package/dist/src/design_system/colors/index.js.map +1 -0
  38. package/dist/src/design_system/theme.d.ts +88 -87
  39. package/dist/src/design_system/theme.d.ts.map +1 -1
  40. package/dist/src/design_system/theme.js +1 -2
  41. package/dist/src/design_system/theme.js.map +1 -1
  42. package/dist/src/index.d.ts +1 -0
  43. package/dist/src/index.d.ts.map +1 -1
  44. package/dist/src/index.js +1 -0
  45. package/dist/src/index.js.map +1 -1
  46. package/dist/tsconfig.build.tsbuildinfo +1 -1
  47. package/package.json +10 -4
  48. package/src/components/code/code_block/code_block_with_tabs.tsx +2 -4
  49. package/src/design_system/colors/build_color_tokens.js +183 -0
  50. package/src/design_system/colors/figma_color_tokens.dark.json +886 -0
  51. package/src/design_system/colors/figma_color_tokens.light.json +886 -0
  52. package/src/design_system/colors/generated/colors_theme.dark.ts +110 -0
  53. package/src/design_system/{colors_theme.ts → colors/generated/colors_theme.light.ts} +40 -143
  54. package/src/design_system/colors/generated/css_variables.dark.ts +147 -0
  55. package/src/design_system/colors/generated/css_variables.light.ts +147 -0
  56. package/src/design_system/colors/generated/css_variables_palette.dark.ts +74 -0
  57. package/src/design_system/colors/generated/css_variables_palette.light.ts +74 -0
  58. package/src/design_system/{properties_theme.ts → colors/generated/properties_theme.ts} +19 -293
  59. package/src/design_system/colors/index.ts +7 -0
  60. package/src/design_system/theme.ts +1 -2
  61. package/src/index.ts +1 -0
  62. package/style/colors/dark.scss +148 -0
  63. package/style/colors/light.scss +148 -0
  64. package/style/colors/palette.dark.scss +75 -0
  65. package/style/colors/palette.light.scss +75 -0
  66. package/.stylelintrc +0 -12
  67. package/CHANGELOG.md +0 -3408
  68. package/CODEOWNERS +0 -7
  69. package/dist/src/design_system/colors_theme.d.ts +0 -213
  70. package/dist/src/design_system/colors_theme.d.ts.map +0 -1
  71. package/dist/src/design_system/colors_theme.js +0 -213
  72. package/dist/src/design_system/colors_theme.js.map +0 -1
  73. package/dist/src/design_system/properties_theme.d.ts.map +0 -1
  74. package/dist/src/design_system/properties_theme.js.map +0 -1
  75. package/eslint.config.mjs +0 -44
  76. package/src/codemods/generate_color_property_tokens.mjs +0 -98
  77. package/src/codemods/generate_color_theme_files.mjs +0 -47
  78. package/src/design_system/generate_color_definitions.js +0 -44
  79. package/src/design_system/supernova_color_tokens.json +0 -1766
  80. package/tsconfig.build.json +0 -17
  81. package/tsconfig.json +0 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/ui-library",
3
- "version": "0.74.2-featCodeBlockWithTabsoptimis-e30911.3+cef0941ab85",
3
+ "version": "0.74.2-featcolortokens-178953.24+d785ae43897",
4
4
  "description": "React UI library used by apify.com",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -17,8 +17,8 @@
17
17
  "build": "npm run clean && npm run compile",
18
18
  "clean": "rimraf ./dist",
19
19
  "compile": "tsc -p tsconfig.build.json",
20
- "generate-theme": "node ./src/codemods/generate_color_theme_files.mjs && node src/codemods/generate_color_property_tokens.mjs && node src/codemods/generate_typograpy_tokens_files.mjs && npm run lint:fix",
21
- "generate-color-definition": "node ./src/design_system/generate_color_definitions.js",
20
+ "generate-theme": "node src/codemods/generate_typograpy_tokens_files.mjs && npm run lint:fix",
21
+ "build-color-tokens": "node src/design_system/colors/build_color_tokens.js",
22
22
  "postpublish": "npm run clean"
23
23
  },
24
24
  "//": [
@@ -63,8 +63,14 @@
63
63
  "eslint-plugin-react-hooks": "^4.6.0",
64
64
  "eslint-plugin-sonarjs": "^1.0.3",
65
65
  "recast": "^0.23.9",
66
+ "style-dictionary": "^4.4.0",
66
67
  "typescript": "^5.1.6",
67
68
  "typescript-eslint": "^8.24.0"
68
69
  },
69
- "gitHead": "cef0941ab85d9a8d282c8e4e7fee14500fb39fe9"
70
+ "files": [
71
+ "dist",
72
+ "src",
73
+ "style"
74
+ ],
75
+ "gitHead": "d785ae43897eefe9e3152ed27bb293f20694c389"
70
76
  }
@@ -74,8 +74,6 @@ type CodeBlockWithTabsProps = SharedBoxProps & {
74
74
  codeBlockProps: SharedCodeBlockProps;
75
75
  currentTabKey: CodeBlockTabKey;
76
76
  tabs: CodeBlockTabProps[];
77
- // Optional prop to set the selected tab, does not influence the content of the code block, used to improve interactivity
78
- optimisticCurrentTabKey?: CodeBlockTabKey;
79
77
  };
80
78
 
81
79
  export const CODE_BLOCK_WITH_TABS_CLASSNAMES = {
@@ -192,7 +190,7 @@ const IMG_RESIZE = {
192
190
  height: 20,
193
191
  };
194
192
 
195
- export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, tabs, optimisticCurrentTabKey, ...props }: CodeBlockWithTabsProps) => {
193
+ export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, tabs, ...props }: CodeBlockWithTabsProps) => {
196
194
  const { generateProxyImageUrl } = useSharedUiDependencies();
197
195
  const currentTab = tabs.find((tab) => tab.key === currentTabKey) ?? tabs[0];
198
196
 
@@ -201,7 +199,7 @@ export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, ta
201
199
  <div className={CODE_BLOCK_WITH_TABS_CLASSNAMES.TABS}>
202
200
  {tabs.map((tab) => {
203
201
  const { label, src } = CODE_BLOCK_TAB_CATALOG[tab.key];
204
- const selected = (optimisticCurrentTabKey ?? currentTabKey) === tab.key;
202
+ const selected = tab.key === currentTab?.key;
205
203
 
206
204
  const commonProps = {
207
205
  className: clsx(CODE_BLOCK_WITH_TABS_CLASSNAMES.TAB, { selected }),
@@ -0,0 +1,183 @@
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 sd = 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 sd.buildPlatform('ts');
177
+ await sd.buildPlatform('style');
178
+ }
179
+
180
+ await Promise.all([
181
+ buildTheme('light'),
182
+ buildTheme('dark'),
183
+ ]);