@apify/ui-library 1.150.0 → 1.151.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.
Files changed (29) hide show
  1. package/dist/design_system/colors/css_variables_brand_dark.d.ts +13 -0
  2. package/dist/design_system/colors/css_variables_brand_dark.d.ts.map +1 -0
  3. package/dist/design_system/colors/css_variables_brand_dark.js +17 -0
  4. package/dist/design_system/colors/generated/css_variables_brand_neutrals.dark.d.ts +5 -0
  5. package/dist/design_system/colors/generated/css_variables_brand_neutrals.dark.d.ts.map +1 -0
  6. package/dist/design_system/colors/generated/css_variables_brand_neutrals.dark.js +45 -0
  7. package/dist/design_system/colors/index.d.ts +1 -0
  8. package/dist/design_system/colors/index.d.ts.map +1 -1
  9. package/dist/files_hash_at_build.txt +1 -1
  10. package/dist/index.js +2 -1
  11. package/dist/src/design_system/colors/css_variables_brand_dark.d.ts +13 -0
  12. package/dist/src/design_system/colors/css_variables_brand_dark.d.ts.map +1 -0
  13. package/dist/src/design_system/colors/css_variables_brand_dark.js +15 -0
  14. package/dist/src/design_system/colors/css_variables_brand_dark.js.map +1 -0
  15. package/dist/src/design_system/colors/generated/css_variables_brand_neutrals.dark.d.ts +5 -0
  16. package/dist/src/design_system/colors/generated/css_variables_brand_neutrals.dark.d.ts.map +1 -0
  17. package/dist/src/design_system/colors/generated/css_variables_brand_neutrals.dark.js +43 -0
  18. package/dist/src/design_system/colors/generated/css_variables_brand_neutrals.dark.js.map +1 -0
  19. package/dist/src/design_system/colors/index.d.ts +1 -0
  20. package/dist/src/design_system/colors/index.d.ts.map +1 -1
  21. package/dist/src/design_system/colors/index.js +1 -0
  22. package/dist/src/design_system/colors/index.js.map +1 -1
  23. package/dist/tsconfig.build.tsbuildinfo +1 -1
  24. package/package.json +2 -2
  25. package/src/design_system/colors/build_color_tokens.js +122 -87
  26. package/src/design_system/colors/css_variables_brand_dark.ts +15 -0
  27. package/src/design_system/colors/figma_color_tokens.brand_neutrals.dark.json +154 -0
  28. package/src/design_system/colors/generated/css_variables_brand_neutrals.dark.ts +43 -0
  29. package/src/design_system/colors/index.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/ui-library",
3
- "version": "1.150.0",
3
+ "version": "1.151.0",
4
4
  "description": "React UI library used by apify.com",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -83,5 +83,5 @@
83
83
  "src",
84
84
  "style"
85
85
  ],
86
- "gitHead": "9bab807c13c3db944300da3795de893a82990a1d"
86
+ "gitHead": "d784b4847b2b7b2c4eeeb14e631da99ebbf15bcf"
87
87
  }
@@ -30,97 +30,103 @@ function objectToTSLiteral(obj, indentLevel = 0) {
30
30
  return String(obj);
31
31
  }
32
32
 
33
+ // Transform to replace 'semantic' and 'decorative' with 'color' in token names
34
+ // Example: 'semantic-neutral-text' becomes 'color-neutral-text'
35
+ StyleDictionary.registerTransform({
36
+ name: 'name/prefix-color-name',
37
+ type: 'name',
38
+ transform: (prop) => {
39
+ return prop.name.replace(/^semantic/, 'color').replace(/^decorative/, 'color');
40
+ },
41
+ });
42
+
43
+ // Format to generate a plain CSS file with tokens inside a :root block
44
+ StyleDictionary.registerFormat({
45
+ name: 'css/custom-properties',
46
+ format: ({ dictionary }) => {
47
+ const lines = dictionary.allTokens.map((token) => ` --${token.name}: ${token.$value};`);
48
+ return `${DO_NOT_EXPORT_COMMENT}\n:root {\n${lines.join('\n')}\n}\n`;
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', 'Brand'].includes(token.path[0]),
117
+ });
118
+
119
+ // Select only the semantic neutral tokens (used for the brand dark neutral override)
120
+ StyleDictionary.registerFilter({
121
+ name: 'only-neutral',
122
+ filter: (token) => token.path[0] === 'Semantic' && token.path[1] === 'Neutral',
123
+ });
124
+
33
125
  /**
34
126
  * Build color tokens for a given theme.
35
127
  * @param theme {string} - The theme to build tokens, 'light' or 'dark'.
36
128
  */
37
129
  async function buildTheme(theme) {
38
- // Transform to replace 'semantic' and 'decorative' with 'color' in token names
39
- // Example: 'semantic-neutral-text' becomes 'color-neutral-text'
40
- StyleDictionary.registerTransform({
41
- name: 'name/prefix-color-name',
42
- type: 'name',
43
- transform: (prop) => {
44
- return prop.name.replace(/^semantic/, 'color').replace(/^decorative/, 'color');
45
- },
46
- });
47
-
48
- // Format to generate a plain CSS file with tokens inside a :root block
49
- StyleDictionary.registerFormat({
50
- name: 'css/custom-properties',
51
- format: ({ dictionary }) => {
52
- const lines = dictionary.allTokens.map((token) => ` --${token.name}: ${token.$value};`);
53
- return `${DO_NOT_EXPORT_COMMENT}\n:root {\n${lines.join('\n')}\n}\n`;
54
- },
55
- });
56
-
57
- // Format to generate typescript file that exports CSS variables as a string
58
- // Example: export const tokens = `--color-neutral-text: #000; --color-primary: #fff;`
59
- StyleDictionary.registerFormat({
60
- name: 'typescript/css-variables-string',
61
- format: ({ dictionary, options }) => {
62
- const lines = dictionary.allTokens.map((token) => ` --${token.name}: ${token.$value};`);
63
- return `${DO_NOT_EXPORT_COMMENT}\nexport const ${options.varName ?? 'tokens'} = \`\n${lines.join('\n')}\n\`;\n`;
64
- },
65
- });
66
-
67
- // Format to generate typescript file that exports CSS properties as an object
68
- // Example: export const tokens = { colorNeutralText: 'var(--color-neutral-text)', colorPrimary: 'var(--color-primary)' };
69
- StyleDictionary.registerFormat({
70
- name: 'typescript/css-color-properties',
71
- format: ({ dictionary, options }) => {
72
- const properties = {};
73
- dictionary.allTokens.forEach((token) => {
74
- const path = token.path.slice(1).map(toCamelCase);
75
- let current = properties;
76
- for (let i = 0; i < path.length - 1; i++) {
77
- const key = path[i];
78
- if (!(key in current)) {
79
- current[key] = {};
80
- }
81
- current = current[key];
82
- }
83
- current[path[path.length - 1]] = `var(--${token.name})`;
84
- });
85
-
86
- return `${DO_NOT_EXPORT_COMMENT}\nexport const ${options.varName ?? 'tokens'} = ${objectToTSLiteral(properties)} as const;\n`;
87
- },
88
- });
89
-
90
- // Format to generate typescript file that exports CSS colors as an object
91
- // Example: export const tokens = { colorNeutralText: '#000', colorPrimary: '#fff' };
92
- StyleDictionary.registerFormat({
93
- name: 'typescript/css-color-values',
94
- format: ({ dictionary, options }) => {
95
- const properties = {};
96
- dictionary.allTokens.forEach((token) => {
97
- const path = token.path.slice(1);
98
- const name = toCamelCase(path.join(' '));
99
- properties[name] = token.$value;
100
- });
101
-
102
- return `${DO_NOT_EXPORT_COMMENT}\nexport const ${options.varName ?? 'tokens'} = ${objectToTSLiteral(properties)} as const;\n`;
103
- },
104
- });
105
-
106
- // Select only tokens for semantic and decorative colors
107
- StyleDictionary.registerFilter({
108
- name: 'only-colors',
109
- filter: (token) => ['Semantic', 'Decorative'].includes(token.path[0]),
110
- });
111
-
112
- // Select only tokens for palette colors
113
- StyleDictionary.registerFilter({
114
- name: 'only-palette',
115
- filter: (token) => ['Palette'].includes(token.path[0]),
116
- });
117
-
118
- // Select only tokens for theme colors (Decorative and Palette)
119
- StyleDictionary.registerFilter({
120
- name: 'only-theme',
121
- filter: (token) => ['Decorative', 'Palette', 'Brand'].includes(token.path[0]),
122
- });
123
-
124
130
  const styleDictionary = await new StyleDictionary().extend({
125
131
  source: [`src/design_system/colors/figma_color_tokens.${theme}.json`],
126
132
  platforms: {
@@ -187,4 +193,33 @@ async function buildTheme(theme) {
187
193
  await styleDictionary.buildPlatform('style');
188
194
  }
189
195
 
190
- await Promise.all([buildTheme('light'), buildTheme('dark')]);
196
+ /**
197
+ * Build the brand dark neutral override (`css_variables_brand_neutrals.dark.ts`).
198
+ *
199
+ * apify.com's dark mode uses a darker neutral palette than the library's default
200
+ * dark tokens. Only the `--color-neutral-*` variables differ, so we emit just the
201
+ * `Semantic.Neutral` group from its own Figma export; `cssColorsVariablesBrandDark`
202
+ * layers these over the base dark tokens and the cascade does the rest.
203
+ */
204
+ async function buildBrandDarkNeutrals() {
205
+ const styleDictionary = await new StyleDictionary().extend({
206
+ source: ['src/design_system/colors/figma_color_tokens.brand_neutrals.dark.json'],
207
+ platforms: {
208
+ ts: {
209
+ transformGroup: 'scss',
210
+ transforms: ['name/prefix-color-name'],
211
+ buildPath: 'src/design_system/colors/generated/',
212
+ files: [
213
+ {
214
+ destination: `css_variables_brand_neutrals.dark.ts`,
215
+ format: 'typescript/css-variables-string',
216
+ filter: 'only-neutral',
217
+ },
218
+ ],
219
+ },
220
+ },
221
+ });
222
+ await styleDictionary.buildPlatform('ts');
223
+ }
224
+
225
+ await Promise.all([buildTheme('light'), buildTheme('dark'), buildBrandDarkNeutrals()]);
@@ -0,0 +1,15 @@
1
+ import { tokens as cssColorsVariablesDark } from './generated/css_variables.dark';
2
+ import { tokens as brandDarkNeutralOverrides } from './generated/css_variables_brand_neutrals.dark';
3
+
4
+ /**
5
+ * Full dark theme using apify.com's darker brand neutral palette.
6
+ *
7
+ * Every `theme.color.neutral.*` value is a `var(--color-neutral-*)` reference,
8
+ * so we ship the standard dark tokens and then re-declare only the neutral
9
+ * variables with the brand palette — the cascade does the rest. The non-neutral
10
+ * tokens therefore stay in sync with `cssColorsVariablesDark` automatically.
11
+ *
12
+ * Apply this on its own as a complete theme (it already includes the base dark
13
+ * tokens); there is no need to also apply `cssColorsVariablesDark`.
14
+ */
15
+ export const cssColorsVariablesBrandDark = `${cssColorsVariablesDark}${brandDarkNeutralOverrides}`;
@@ -0,0 +1,154 @@
1
+ {
2
+ "Semantic": {
3
+ "Neutral": {
4
+ "Text": {
5
+ "$type": "color",
6
+ "$value": "#dfdfdf"
7
+ },
8
+ "Text_Muted": {
9
+ "$type": "color",
10
+ "$value": "#a3a3a3"
11
+ },
12
+ "Text_Subtle": {
13
+ "$type": "color",
14
+ "$value": "#888888"
15
+ },
16
+ "Text_Disabled": {
17
+ "$type": "color",
18
+ "$value": "#454545"
19
+ },
20
+ "Text_On_Primary": {
21
+ "$type": "color",
22
+ "$value": "#161616"
23
+ },
24
+ "Icon_On_Primary": {
25
+ "$type": "color",
26
+ "$value": "#161616"
27
+ },
28
+ "Background": {
29
+ "$type": "color",
30
+ "$value": "#020202"
31
+ },
32
+ "Background_Muted": {
33
+ "$type": "color",
34
+ "$value": "#0f0f0f"
35
+ },
36
+ "Background_Subtle": {
37
+ "$type": "color",
38
+ "$value": "#1d1d1d"
39
+ },
40
+ "Background_White": {
41
+ "$type": "color",
42
+ "$value": "#f3f3f3"
43
+ },
44
+ "Card_Background": {
45
+ "$type": "color",
46
+ "$value": "#0f0f0f"
47
+ },
48
+ "Card_Background_Hover": {
49
+ "$type": "color",
50
+ "$value": "#1d1d1d"
51
+ },
52
+ "Border": {
53
+ "$type": "color",
54
+ "$value": "#2a2a2a"
55
+ },
56
+ "Separator_Subtle": {
57
+ "$type": "color",
58
+ "$value": "#161616"
59
+ },
60
+ "Hover": {
61
+ "$type": "color",
62
+ "$value": "#313131"
63
+ },
64
+ "Disabled": {
65
+ "$type": "color",
66
+ "$value": "#383838"
67
+ },
68
+ "Overflow": {
69
+ "$type": "color",
70
+ "$value": "#2a2a2a"
71
+ },
72
+ "Icon": {
73
+ "$type": "color",
74
+ "$value": "#d8d8d8"
75
+ },
76
+ "Icon_Subtle": {
77
+ "$type": "color",
78
+ "$value": "#6d6d6d"
79
+ },
80
+ "Icon_Disabled": {
81
+ "$type": "color",
82
+ "$value": "#454545"
83
+ },
84
+ "Field_Border": {
85
+ "$type": "color",
86
+ "$value": "#454545"
87
+ },
88
+ "Action_Secondary": {
89
+ "$type": "color",
90
+ "$value": "#2a2a2a"
91
+ },
92
+ "Action_Secondary_Hover": {
93
+ "$type": "color",
94
+ "$value": "#454545"
95
+ },
96
+ "Action_Secondary_Active": {
97
+ "$type": "color",
98
+ "$value": "#454545"
99
+ },
100
+ "Chip_Background": {
101
+ "$type": "color",
102
+ "$value": "#606060"
103
+ },
104
+ "Chip_Background_Hover": {
105
+ "$type": "color",
106
+ "$value": "#7b7b7b"
107
+ },
108
+ "Chip_Background_Active": {
109
+ "$type": "color",
110
+ "$value": "#959595"
111
+ },
112
+ "Chip_Background_Disabled": {
113
+ "$type": "color",
114
+ "$value": "#959595"
115
+ },
116
+ "Large_Tooltip_Background": {
117
+ "$type": "color",
118
+ "$value": "#2a2a2a"
119
+ },
120
+ "Large_Tooltip_Border": {
121
+ "$type": "color",
122
+ "$value": "#383838"
123
+ },
124
+ "Small_Tooltip_Text": {
125
+ "$type": "color",
126
+ "$value": "#ffffff"
127
+ },
128
+ "Small_Tooltip_Background": {
129
+ "$type": "color",
130
+ "$value": "#2a2a2a"
131
+ },
132
+ "Small_Tooltip_Border": {
133
+ "$type": "color",
134
+ "$value": "#383838"
135
+ },
136
+ "Overlay": {
137
+ "$type": "color",
138
+ "$value": "#101114"
139
+ },
140
+ "Field_Background": {
141
+ "$type": "color",
142
+ "$value": "#0f0f0f"
143
+ },
144
+ "Text_Placeholder": {
145
+ "$type": "color",
146
+ "$value": "#7b7b7b"
147
+ },
148
+ "On_Surface": {
149
+ "$type": "color",
150
+ "$value": "rgba(109, 113, 120, 0.22)"
151
+ }
152
+ }
153
+ }
154
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Do not edit directly, this file was auto-generated.
3
+ */
4
+
5
+ export const tokens = `
6
+ --color-neutral-text: #dfdfdf;
7
+ --color-neutral-text-muted: #a3a3a3;
8
+ --color-neutral-text-subtle: #888888;
9
+ --color-neutral-text-disabled: #454545;
10
+ --color-neutral-text-on-primary: #161616;
11
+ --color-neutral-icon-on-primary: #161616;
12
+ --color-neutral-background: #020202;
13
+ --color-neutral-background-muted: #0f0f0f;
14
+ --color-neutral-background-subtle: #1d1d1d;
15
+ --color-neutral-background-white: #f3f3f3;
16
+ --color-neutral-card-background: #0f0f0f;
17
+ --color-neutral-card-background-hover: #1d1d1d;
18
+ --color-neutral-border: #2a2a2a;
19
+ --color-neutral-separator-subtle: #161616;
20
+ --color-neutral-hover: #313131;
21
+ --color-neutral-disabled: #383838;
22
+ --color-neutral-overflow: #2a2a2a;
23
+ --color-neutral-icon: #d8d8d8;
24
+ --color-neutral-icon-subtle: #6d6d6d;
25
+ --color-neutral-icon-disabled: #454545;
26
+ --color-neutral-field-border: #454545;
27
+ --color-neutral-action-secondary: #2a2a2a;
28
+ --color-neutral-action-secondary-hover: #454545;
29
+ --color-neutral-action-secondary-active: #454545;
30
+ --color-neutral-chip-background: #606060;
31
+ --color-neutral-chip-background-hover: #7b7b7b;
32
+ --color-neutral-chip-background-active: #959595;
33
+ --color-neutral-chip-background-disabled: #959595;
34
+ --color-neutral-large-tooltip-background: #2a2a2a;
35
+ --color-neutral-large-tooltip-border: #383838;
36
+ --color-neutral-small-tooltip-text: #ffffff;
37
+ --color-neutral-small-tooltip-background: #2a2a2a;
38
+ --color-neutral-small-tooltip-border: #383838;
39
+ --color-neutral-overlay: #101114;
40
+ --color-neutral-field-background: #0f0f0f;
41
+ --color-neutral-text-placeholder: #7b7b7b;
42
+ --color-neutral-on-surface: rgba(109, 113, 120, 0.22);
43
+ `;
@@ -2,6 +2,7 @@ export { tokens as cssColorsVariablesLight } from './generated/css_variables.lig
2
2
  export { tokens as cssColorsVariablesDark } from './generated/css_variables.dark';
3
3
  export { tokens as cssColorsVariablesPaletteLight } from './generated/css_variables_palette.light';
4
4
  export { tokens as cssColorsVariablesPaletteDark } from './generated/css_variables_palette.dark';
5
+ export { cssColorsVariablesBrandDark } from './css_variables_brand_dark';
5
6
  export { darkTheme } from './generated/colors_theme.dark';
6
7
  export { lightTheme } from './generated/colors_theme.light';
7
8
  export { colorProperties } from './generated/properties_theme';