@apify/ui-library 0.76.3 → 0.76.4-featcolortokens-178953.36
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/README.md +18 -5
- package/dist/src/design_system/colors/generated/colors_theme.dark.d.ts +110 -0
- package/dist/src/design_system/colors/generated/colors_theme.dark.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/colors_theme.dark.js +110 -0
- package/dist/src/design_system/colors/generated/colors_theme.dark.js.map +1 -0
- package/dist/src/design_system/colors/generated/colors_theme.light.d.ts +110 -0
- package/dist/src/design_system/colors/generated/colors_theme.light.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/colors_theme.light.js +110 -0
- package/dist/src/design_system/colors/generated/colors_theme.light.js.map +1 -0
- package/dist/src/design_system/colors/generated/css_variables.dark.d.ts +5 -0
- package/dist/src/design_system/colors/generated/css_variables.dark.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/css_variables.dark.js +147 -0
- package/dist/src/design_system/colors/generated/css_variables.dark.js.map +1 -0
- package/dist/src/design_system/colors/generated/css_variables.light.d.ts +5 -0
- package/dist/src/design_system/colors/generated/css_variables.light.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/css_variables.light.js +147 -0
- package/dist/src/design_system/colors/generated/css_variables.light.js.map +1 -0
- package/dist/src/design_system/colors/generated/css_variables_palette.dark.d.ts +5 -0
- package/dist/src/design_system/colors/generated/css_variables_palette.dark.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/css_variables_palette.dark.js +74 -0
- package/dist/src/design_system/colors/generated/css_variables_palette.dark.js.map +1 -0
- package/dist/src/design_system/colors/generated/css_variables_palette.light.d.ts +5 -0
- package/dist/src/design_system/colors/generated/css_variables_palette.light.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/css_variables_palette.light.js +74 -0
- package/dist/src/design_system/colors/generated/css_variables_palette.light.js.map +1 -0
- package/dist/src/design_system/{properties_theme.d.ts → colors/generated/properties_theme.d.ts} +18 -14
- package/dist/src/design_system/colors/generated/properties_theme.d.ts.map +1 -0
- package/dist/src/design_system/{properties_theme.js → colors/generated/properties_theme.js} +18 -154
- package/dist/src/design_system/colors/generated/properties_theme.js.map +1 -0
- package/dist/src/design_system/colors/index.d.ts +8 -0
- package/dist/src/design_system/colors/index.d.ts.map +1 -0
- package/dist/src/design_system/colors/index.js +8 -0
- package/dist/src/design_system/colors/index.js.map +1 -0
- package/dist/src/design_system/theme.d.ts +88 -87
- package/dist/src/design_system/theme.d.ts.map +1 -1
- package/dist/src/design_system/theme.js +1 -2
- package/dist/src/design_system/theme.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +10 -4
- package/src/design_system/colors/build_color_tokens.js +183 -0
- package/src/design_system/colors/figma_color_tokens.dark.json +886 -0
- package/src/design_system/colors/figma_color_tokens.light.json +886 -0
- package/src/design_system/colors/generated/colors_theme.dark.ts +110 -0
- package/src/design_system/{colors_theme.ts → colors/generated/colors_theme.light.ts} +40 -143
- package/src/design_system/colors/generated/css_variables.dark.ts +147 -0
- package/src/design_system/colors/generated/css_variables.light.ts +147 -0
- package/src/design_system/colors/generated/css_variables_palette.dark.ts +74 -0
- package/src/design_system/colors/generated/css_variables_palette.light.ts +74 -0
- package/src/design_system/{properties_theme.ts → colors/generated/properties_theme.ts} +19 -293
- package/src/design_system/colors/index.ts +7 -0
- package/src/design_system/theme.ts +1 -2
- package/src/index.ts +1 -0
- package/style/colors/dark.scss +148 -0
- package/style/colors/light.scss +148 -0
- package/style/colors/palette.dark.scss +75 -0
- package/style/colors/palette.light.scss +75 -0
- package/.stylelintrc +0 -12
- package/CHANGELOG.md +0 -3454
- package/CODEOWNERS +0 -7
- package/dist/src/design_system/colors_theme.d.ts +0 -213
- package/dist/src/design_system/colors_theme.d.ts.map +0 -1
- package/dist/src/design_system/colors_theme.js +0 -213
- package/dist/src/design_system/colors_theme.js.map +0 -1
- package/dist/src/design_system/properties_theme.d.ts.map +0 -1
- package/dist/src/design_system/properties_theme.js.map +0 -1
- package/eslint.config.mjs +0 -45
- package/src/codemods/generate_color_property_tokens.mjs +0 -98
- package/src/codemods/generate_color_theme_files.mjs +0 -47
- package/src/design_system/generate_color_definitions.js +0 -44
- package/src/design_system/supernova_color_tokens.json +0 -1766
- package/tsconfig.build.json +0 -17
- package/tsconfig.json +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/ui-library",
|
|
3
|
-
"version": "0.76.
|
|
3
|
+
"version": "0.76.4-featcolortokens-178953.36+6fd6cc53c44",
|
|
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
|
|
21
|
-
"
|
|
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
|
-
"
|
|
70
|
+
"files": [
|
|
71
|
+
"dist",
|
|
72
|
+
"src",
|
|
73
|
+
"style"
|
|
74
|
+
],
|
|
75
|
+
"gitHead": "6fd6cc53c446b1af771d55aac21d15e13a64c993"
|
|
70
76
|
}
|
|
@@ -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 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
|
+
]);
|