@apify/ui-library 0.71.0 → 0.71.1-featcolortokens-178953.55
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/dark.d.ts +5 -0
- package/dist/src/design_system/colors/generated/dark.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/dark.js +147 -0
- package/dist/src/design_system/colors/generated/dark.js.map +1 -0
- package/dist/src/design_system/colors/generated/light.d.ts +5 -0
- package/dist/src/design_system/colors/generated/light.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/light.js +147 -0
- package/dist/src/design_system/colors/generated/light.js.map +1 -0
- package/dist/src/design_system/colors/generated/palette.dark.d.ts +5 -0
- package/dist/src/design_system/colors/generated/palette.dark.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/palette.dark.js +74 -0
- package/dist/src/design_system/colors/generated/palette.dark.js.map +1 -0
- package/dist/src/design_system/colors/generated/palette.light.d.ts +5 -0
- package/dist/src/design_system/colors/generated/palette.light.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/palette.light.js +74 -0
- package/dist/src/design_system/colors/generated/palette.light.js.map +1 -0
- package/dist/src/design_system/colors/generated/properties_theme.d.ts +179 -0
- package/dist/src/design_system/colors/generated/properties_theme.d.ts.map +1 -0
- package/dist/src/design_system/colors/generated/properties_theme.js +179 -0
- 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/package.json +8 -5
- package/src/design_system/colors/build_color_tokens.js +169 -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/generated/colors_theme.light.ts +110 -0
- package/src/design_system/colors/generated/dark.scss +148 -0
- package/src/design_system/colors/generated/dark.ts +147 -0
- package/src/design_system/colors/generated/light.scss +148 -0
- package/src/design_system/colors/generated/light.ts +147 -0
- package/src/design_system/colors/generated/palette.dark.scss +75 -0
- package/src/design_system/colors/generated/palette.dark.ts +74 -0
- package/src/design_system/colors/generated/palette.light.scss +75 -0
- package/src/design_system/colors/generated/palette.light.ts +74 -0
- package/src/design_system/colors/generated/properties_theme.ts +179 -0
- 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-dictionary.config.json +29 -0
- package/dist/tsconfig.build.tsbuildinfo +0 -1
- 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
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import StyleDictionary from 'style-dictionary';
|
|
2
|
+
|
|
3
|
+
function toCamelCase(str) {
|
|
4
|
+
return str
|
|
5
|
+
.toLowerCase()
|
|
6
|
+
.replace(/[^a-zA-Z0-9]+(.)/g, (_, chr) => chr.toUpperCase());
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function objectToTSLiteral(obj, indentLevel = 0) {
|
|
10
|
+
const indent = (level) => ' '.repeat(level); // 2-space indent
|
|
11
|
+
|
|
12
|
+
if (Array.isArray(obj)) {
|
|
13
|
+
if (obj.length === 0) return '[]';
|
|
14
|
+
return `[\n${obj
|
|
15
|
+
.map((item) => indent(indentLevel + 1) + objectToTSLiteral(item, indentLevel + 1))
|
|
16
|
+
.join(',\n')}\n${indent(indentLevel)}]`;
|
|
17
|
+
} if (obj && typeof obj === 'object') {
|
|
18
|
+
const entries = Object.entries(obj);
|
|
19
|
+
if (entries.length === 0) return '{}';
|
|
20
|
+
return `{\n${entries
|
|
21
|
+
.map(
|
|
22
|
+
([key, value]) => `${indent(indentLevel + 1)}${key}: ${objectToTSLiteral(value, indentLevel + 1)}`,
|
|
23
|
+
)
|
|
24
|
+
.join('\n')}\n${indent(indentLevel)}}${indentLevel > 0 ? ',' : ''}`;
|
|
25
|
+
} if (typeof obj === 'string') {
|
|
26
|
+
return `'${obj}',`; // add quotes and escape
|
|
27
|
+
}
|
|
28
|
+
return String(obj);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function buildTheme(theme) {
|
|
32
|
+
StyleDictionary.registerTransform({
|
|
33
|
+
name: 'name/prefix-color-name',
|
|
34
|
+
type: 'name',
|
|
35
|
+
transform: (prop) => {
|
|
36
|
+
// replace 'semantic' and 'decorative' with 'color' in the full token name
|
|
37
|
+
return prop.name
|
|
38
|
+
.replace(/^semantic/, 'color')
|
|
39
|
+
.replace(/^decorative/, 'color');
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
StyleDictionary.registerFormat({
|
|
44
|
+
name: 'typescript/css-variables-string',
|
|
45
|
+
format: ({ dictionary, options }) => {
|
|
46
|
+
const lines = dictionary.allTokens.map((token) => ` --${token.name}: ${token.$value};`);
|
|
47
|
+
return `/**
|
|
48
|
+
* Do not edit directly, this file was auto-generated.
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
export const ${options.varName ?? 'tokens'} = \`\n${lines.join('\n')}\n\`;\n`;
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
StyleDictionary.registerFormat({
|
|
56
|
+
name: 'typescript/css-properties',
|
|
57
|
+
format: ({ dictionary, options }) => {
|
|
58
|
+
const properties = {};
|
|
59
|
+
dictionary.allTokens.forEach((token) => {
|
|
60
|
+
const path = token.path.slice(1).map(toCamelCase);
|
|
61
|
+
let current = properties;
|
|
62
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
63
|
+
const key = path[i];
|
|
64
|
+
if (!(key in current)) {
|
|
65
|
+
current[key] = {};
|
|
66
|
+
}
|
|
67
|
+
current = current[key];
|
|
68
|
+
}
|
|
69
|
+
current[path[path.length - 1]] = `var(--${token.name})`;
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
return `/**
|
|
73
|
+
* Do not edit directly, this file was auto-generated.
|
|
74
|
+
*/
|
|
75
|
+
|
|
76
|
+
export const ${options.varName ?? 'tokens'} = ${objectToTSLiteral(properties)} as const;\n`;
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
StyleDictionary.registerFormat({
|
|
81
|
+
name: 'typescript/css-colors',
|
|
82
|
+
format: ({ dictionary, options }) => {
|
|
83
|
+
const properties = {};
|
|
84
|
+
dictionary.allTokens.forEach((token) => {
|
|
85
|
+
const path = token.path.slice(1);
|
|
86
|
+
const name = toCamelCase(path.join(' '));
|
|
87
|
+
properties[name] = token.$value;
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return `/**
|
|
91
|
+
* Do not edit directly, this file was auto-generated.
|
|
92
|
+
*/
|
|
93
|
+
|
|
94
|
+
export const ${options.varName ?? 'tokens'} = ${objectToTSLiteral(properties)} as const;\n`;
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
StyleDictionary.registerFilter({
|
|
99
|
+
name: 'only-colors',
|
|
100
|
+
filter: (token) => ['Semantic', 'Decorative'].includes(token.path[0]),
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
StyleDictionary.registerFilter({
|
|
104
|
+
name: 'only-palette',
|
|
105
|
+
filter: (token) => ['Palette'].includes(token.path[0]),
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
StyleDictionary.registerFilter({
|
|
109
|
+
name: 'only-theme',
|
|
110
|
+
filter: (token) => ['Decorative', 'Palette'].includes(token.path[0]),
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const sd = await (new StyleDictionary()).extend({
|
|
114
|
+
source: [`src/design_system/colors/figma_color_tokens.${theme}.json`],
|
|
115
|
+
platforms: {
|
|
116
|
+
main: {
|
|
117
|
+
transformGroup: 'scss',
|
|
118
|
+
transforms: ['name/prefix-color-name'],
|
|
119
|
+
buildPath: 'src/design_system/colors/generated/',
|
|
120
|
+
files: [
|
|
121
|
+
{
|
|
122
|
+
destination: `${theme}.scss`,
|
|
123
|
+
format: 'scss/map-flat',
|
|
124
|
+
mapName: 'tokens',
|
|
125
|
+
filter: 'only-colors',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
destination: `palette.${theme}.scss`,
|
|
129
|
+
format: 'scss/map-flat',
|
|
130
|
+
mapName: 'tokens',
|
|
131
|
+
filter: 'only-palette',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
destination: `${theme}.ts`,
|
|
135
|
+
format: 'typescript/css-variables-string',
|
|
136
|
+
filter: 'only-colors',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
destination: `palette.${theme}.ts`,
|
|
140
|
+
format: 'typescript/css-variables-string',
|
|
141
|
+
filter: 'only-palette',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
destination: `properties_theme.ts`,
|
|
145
|
+
format: 'typescript/css-properties',
|
|
146
|
+
filter: 'only-colors',
|
|
147
|
+
options: {
|
|
148
|
+
varName: 'colorProperties',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
destination: `colors_theme.${theme}.ts`,
|
|
153
|
+
format: 'typescript/css-colors',
|
|
154
|
+
filter: 'only-theme',
|
|
155
|
+
options: {
|
|
156
|
+
varName: `${theme}Theme`,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
await sd.buildPlatform('main');
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
await Promise.all([
|
|
167
|
+
buildTheme('light'),
|
|
168
|
+
buildTheme('dark'),
|
|
169
|
+
]);
|