@apify/ui-library 0.74.2-featcolortokens-178953.24 → 0.76.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 (91) hide show
  1. package/.stylelintrc +12 -0
  2. package/CHANGELOG.md +3430 -0
  3. package/CODEOWNERS +7 -0
  4. package/README.md +5 -18
  5. package/dist/src/components/code/code_block/code_block_with_tabs.d.ts +2 -1
  6. package/dist/src/components/code/code_block/code_block_with_tabs.d.ts.map +1 -1
  7. package/dist/src/components/code/code_block/code_block_with_tabs.js +2 -2
  8. package/dist/src/components/code/code_block/code_block_with_tabs.js.map +1 -1
  9. package/dist/src/components/readme_renderer/index.d.ts +1 -1
  10. package/dist/src/components/readme_renderer/index.d.ts.map +1 -1
  11. package/dist/src/components/readme_renderer/index.js +1 -1
  12. package/dist/src/components/readme_renderer/index.js.map +1 -1
  13. package/dist/src/components/readme_renderer/table_of_contents.d.ts +1 -0
  14. package/dist/src/components/readme_renderer/table_of_contents.d.ts.map +1 -1
  15. package/dist/src/components/readme_renderer/table_of_contents.js +1 -0
  16. package/dist/src/components/readme_renderer/table_of_contents.js.map +1 -1
  17. package/dist/src/design_system/colors_theme.d.ts +213 -0
  18. package/dist/src/design_system/colors_theme.d.ts.map +1 -0
  19. package/dist/src/design_system/colors_theme.js +213 -0
  20. package/dist/src/design_system/colors_theme.js.map +1 -0
  21. package/dist/src/design_system/{colors/generated/properties_theme.d.ts → properties_theme.d.ts} +14 -18
  22. package/dist/src/design_system/properties_theme.d.ts.map +1 -0
  23. package/dist/src/design_system/{colors/generated/properties_theme.js → properties_theme.js} +154 -18
  24. package/dist/src/design_system/properties_theme.js.map +1 -0
  25. package/dist/src/design_system/theme.d.ts +87 -88
  26. package/dist/src/design_system/theme.d.ts.map +1 -1
  27. package/dist/src/design_system/theme.js +2 -1
  28. package/dist/src/design_system/theme.js.map +1 -1
  29. package/dist/src/index.d.ts +0 -1
  30. package/dist/src/index.d.ts.map +1 -1
  31. package/dist/src/index.js +0 -1
  32. package/dist/src/index.js.map +1 -1
  33. package/dist/tsconfig.build.tsbuildinfo +1 -1
  34. package/eslint.config.mjs +44 -0
  35. package/package.json +4 -10
  36. package/src/codemods/generate_color_property_tokens.mjs +98 -0
  37. package/src/codemods/generate_color_theme_files.mjs +47 -0
  38. package/src/components/code/code_block/code_block_with_tabs.tsx +4 -2
  39. package/src/components/readme_renderer/index.ts +1 -1
  40. package/src/components/readme_renderer/table_of_contents.tsx +2 -0
  41. package/src/design_system/{colors/generated/colors_theme.light.ts → colors_theme.ts} +143 -40
  42. package/src/design_system/generate_color_definitions.js +44 -0
  43. package/src/design_system/{colors/generated/properties_theme.ts → properties_theme.ts} +293 -19
  44. package/src/design_system/supernova_color_tokens.json +1766 -0
  45. package/src/design_system/theme.ts +2 -1
  46. package/src/index.ts +0 -1
  47. package/tsconfig.build.json +17 -0
  48. package/tsconfig.json +10 -0
  49. package/dist/src/design_system/colors/generated/colors_theme.dark.d.ts +0 -110
  50. package/dist/src/design_system/colors/generated/colors_theme.dark.d.ts.map +0 -1
  51. package/dist/src/design_system/colors/generated/colors_theme.dark.js +0 -110
  52. package/dist/src/design_system/colors/generated/colors_theme.dark.js.map +0 -1
  53. package/dist/src/design_system/colors/generated/colors_theme.light.d.ts +0 -110
  54. package/dist/src/design_system/colors/generated/colors_theme.light.d.ts.map +0 -1
  55. package/dist/src/design_system/colors/generated/colors_theme.light.js +0 -110
  56. package/dist/src/design_system/colors/generated/colors_theme.light.js.map +0 -1
  57. package/dist/src/design_system/colors/generated/css_variables.dark.d.ts +0 -5
  58. package/dist/src/design_system/colors/generated/css_variables.dark.d.ts.map +0 -1
  59. package/dist/src/design_system/colors/generated/css_variables.dark.js +0 -147
  60. package/dist/src/design_system/colors/generated/css_variables.dark.js.map +0 -1
  61. package/dist/src/design_system/colors/generated/css_variables.light.d.ts +0 -5
  62. package/dist/src/design_system/colors/generated/css_variables.light.d.ts.map +0 -1
  63. package/dist/src/design_system/colors/generated/css_variables.light.js +0 -147
  64. package/dist/src/design_system/colors/generated/css_variables.light.js.map +0 -1
  65. package/dist/src/design_system/colors/generated/css_variables_palette.dark.d.ts +0 -5
  66. package/dist/src/design_system/colors/generated/css_variables_palette.dark.d.ts.map +0 -1
  67. package/dist/src/design_system/colors/generated/css_variables_palette.dark.js +0 -74
  68. package/dist/src/design_system/colors/generated/css_variables_palette.dark.js.map +0 -1
  69. package/dist/src/design_system/colors/generated/css_variables_palette.light.d.ts +0 -5
  70. package/dist/src/design_system/colors/generated/css_variables_palette.light.d.ts.map +0 -1
  71. package/dist/src/design_system/colors/generated/css_variables_palette.light.js +0 -74
  72. package/dist/src/design_system/colors/generated/css_variables_palette.light.js.map +0 -1
  73. package/dist/src/design_system/colors/generated/properties_theme.d.ts.map +0 -1
  74. package/dist/src/design_system/colors/generated/properties_theme.js.map +0 -1
  75. package/dist/src/design_system/colors/index.d.ts +0 -8
  76. package/dist/src/design_system/colors/index.d.ts.map +0 -1
  77. package/dist/src/design_system/colors/index.js +0 -8
  78. package/dist/src/design_system/colors/index.js.map +0 -1
  79. package/src/design_system/colors/build_color_tokens.js +0 -183
  80. package/src/design_system/colors/figma_color_tokens.dark.json +0 -886
  81. package/src/design_system/colors/figma_color_tokens.light.json +0 -886
  82. package/src/design_system/colors/generated/colors_theme.dark.ts +0 -110
  83. package/src/design_system/colors/generated/css_variables.dark.ts +0 -147
  84. package/src/design_system/colors/generated/css_variables.light.ts +0 -147
  85. package/src/design_system/colors/generated/css_variables_palette.dark.ts +0 -74
  86. package/src/design_system/colors/generated/css_variables_palette.light.ts +0 -74
  87. package/src/design_system/colors/index.ts +0 -7
  88. package/style/colors/dark.scss +0 -148
  89. package/style/colors/light.scss +0 -148
  90. package/style/colors/palette.dark.scss +0 -75
  91. package/style/colors/palette.light.scss +0 -75
@@ -0,0 +1,44 @@
1
+ import react from 'eslint-plugin-react';
2
+ import reactHooks from 'eslint-plugin-react-hooks';
3
+ import sonarjs from 'eslint-plugin-sonarjs';
4
+
5
+ import apifyJestConfig from '@apify/eslint-config/jest.js';
6
+ import apifyTypescriptConfig from '@apify/eslint-config/ts.js';
7
+
8
+ // eslint-disable-next-line import/no-default-export
9
+ export default [
10
+ { ignores: ['**/dist'] }, // Ignores need to happen first
11
+ ...apifyTypescriptConfig,
12
+ ...apifyJestConfig,
13
+
14
+ {
15
+ files: ['**/*.ts', '**/*.tsx'],
16
+ settings: {
17
+ react: {
18
+ version: 'detect',
19
+ },
20
+ },
21
+ ...react.configs.flat.recommended,
22
+ },
23
+ {
24
+ plugins: {
25
+ sonarjs,
26
+ 'react-hooks': reactHooks,
27
+ },
28
+ languageOptions: {
29
+ sourceType: 'module',
30
+
31
+ parserOptions: {
32
+ projectService: true,
33
+ tsconfigRootDir: import.meta.dirname,
34
+ },
35
+ },
36
+ rules: {
37
+ 'react/react-in-jsx-scope': 'off',
38
+ 'no-void': 'off',
39
+ 'react/display-name': 'off',
40
+ 'react-hooks/exhaustive-deps': 'error',
41
+ ...reactHooks.configs.recommended.rules,
42
+ },
43
+ },
44
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/ui-library",
3
- "version": "0.74.2-featcolortokens-178953.24+d785ae43897",
3
+ "version": "0.76.0",
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_typograpy_tokens_files.mjs && npm run lint:fix",
21
- "build-color-tokens": "node src/design_system/colors/build_color_tokens.js",
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",
22
22
  "postpublish": "npm run clean"
23
23
  },
24
24
  "//": [
@@ -63,14 +63,8 @@
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",
67
66
  "typescript": "^5.1.6",
68
67
  "typescript-eslint": "^8.24.0"
69
68
  },
70
- "files": [
71
- "dist",
72
- "src",
73
- "style"
74
- ],
75
- "gitHead": "d785ae43897eefe9e3152ed27bb293f20694c389"
69
+ "gitHead": "2a8570db705a7b5bf6054580ab63bb5babfc23ca"
76
70
  }
@@ -0,0 +1,98 @@
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
+
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
4
+ import { print, types } from 'recast';
5
+
6
+ const { builders } = types;
7
+
8
+ const code = readFileSync('./src/design_system/supernova_color_tokens.json', 'utf-8');
9
+
10
+ const lightColorTokens = JSON.parse(code).light;
11
+
12
+ const getObjectValueByPath = (obj, path) => {
13
+ return path.split('.').reduce((acc, part) => acc && acc[part], obj);
14
+ };
15
+
16
+ const getColorPropertyName = (semanticCategory, property) => {
17
+ const semanticColorName = `${property.split(/[_ ]/).map((semanticPartName) => semanticPartName.toLowerCase()).join('-')}`;
18
+
19
+ // lower case and replace spaces with dashes
20
+ const semanticCategoryName = semanticCategory.toLowerCase().split(' ').join('-');
21
+
22
+ return `--color-${semanticCategoryName}-${semanticColorName}`;
23
+ };
24
+
25
+ const generateColorPropertyTokens = (supernovaColorsDefinitions) => {
26
+ const mergedPalettes = { ...supernovaColorsDefinitions.Semantic, ...supernovaColorsDefinitions.Decorative };
27
+
28
+ const colorTheme = {};
29
+ for (const [category, palette] of Object.entries(mergedPalettes)) {
30
+ // convert to camelCase if there are multiple words in the category name
31
+ const categoryName = category
32
+ .split(' ')
33
+ .map((word, i) => (i === 0
34
+ ? word.toLocaleLowerCase()
35
+ : `${word.charAt(0).toUpperCase()}${word.slice(1)}`),
36
+ )
37
+ .join('');
38
+ colorTheme[categoryName] = {};
39
+
40
+ for (const [key, { value }] of Object.entries(palette)) {
41
+ const [firstPart, ...rest] = key.split(' ');
42
+ const propertyName = `${firstPart.toLowerCase()}${rest.join('')}`;
43
+
44
+ const hexLocator = value.slice(1, -1);
45
+ const hex = value.startsWith('#') ? value : getObjectValueByPath(supernovaColorsDefinitions, hexLocator)?.value;
46
+
47
+ colorTheme[categoryName][propertyName] = {
48
+ variable: `var(${getColorPropertyName(category, key)})`,
49
+ hex,
50
+ };
51
+ }
52
+ }
53
+
54
+ return colorTheme;
55
+ };
56
+
57
+ const createPropertyDeclaration = (tokens) => {
58
+ const paletteArray = [];
59
+
60
+ for (const [paletteName, paletteProps] of [...Object.entries(tokens)]) {
61
+ const paletteItemsArray = [];
62
+
63
+ for (const [paletteItemName, { variable, hex }] of Object.entries(paletteProps)) {
64
+ const objectPropertyItem = builders.property(
65
+ 'init',
66
+ builders.identifier(paletteItemName),
67
+ builders.literal(variable),
68
+ );
69
+
70
+ objectPropertyItem.comments = [builders.commentBlock(` ${hex} `)];
71
+
72
+ paletteItemsArray.push(objectPropertyItem);
73
+ }
74
+
75
+ paletteArray.push(builders.property(
76
+ 'init',
77
+ builders.identifier(paletteName),
78
+ builders.objectExpression(paletteItemsArray),
79
+ ));
80
+ }
81
+
82
+ return builders.exportNamedDeclaration(
83
+ builders.variableDeclaration('const', [
84
+ builders.variableDeclarator(
85
+ builders.identifier('colorProperties'),
86
+ builders.tsAsExpression(builders.objectExpression(paletteArray), builders.tsTypeReference(builders.identifier('const'))),
87
+ )]),
88
+ [],
89
+ );
90
+ };
91
+
92
+ const generatedTokens = generateColorPropertyTokens(lightColorTokens);
93
+
94
+ const lightThemeDeclaration = createPropertyDeclaration(generatedTokens);
95
+
96
+ const printedCode = print(builders.program([lightThemeDeclaration])).code;
97
+
98
+ writeFileSync('./src/design_system/properties_theme.ts', printedCode);
@@ -0,0 +1,47 @@
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
+
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
4
+ import { print, types } from 'recast';
5
+
6
+ const { builders } = types;
7
+
8
+ const code = readFileSync('./src/design_system/supernova_color_tokens.json', 'utf-8');
9
+
10
+ const colorTokens = JSON.parse(code);
11
+
12
+ const lightThemeProperty = colorTokens.light;
13
+ const darkThemeProperty = colorTokens.dark;
14
+
15
+ function createThemeDeclaration(themeProperty, variableName) {
16
+ const paletteArray = [];
17
+
18
+ const { Decorative, Palette } = themeProperty;
19
+
20
+ for (const [paletteName, paletteProps] of [...Object.entries(Palette), ...Object.entries(Decorative)]) {
21
+ for (const [paletteItemName, paletteItem] of Object.entries(paletteProps)) {
22
+ paletteArray.push(
23
+ builders.property(
24
+ 'init',
25
+ builders.identifier(`${paletteName.toLowerCase()}${paletteItemName}`),
26
+ builders.literal(paletteItem.value),
27
+ ),
28
+ );
29
+ }
30
+ }
31
+
32
+ return builders.exportNamedDeclaration(
33
+ builders.variableDeclaration('const', [
34
+ builders.variableDeclarator(
35
+ builders.identifier(variableName),
36
+ builders.tsAsExpression(builders.objectExpression(paletteArray), builders.tsTypeReference(builders.identifier('const'))),
37
+ )]),
38
+ [],
39
+ );
40
+ }
41
+
42
+ const lightThemeDeclaration = createThemeDeclaration(lightThemeProperty, 'lightTheme');
43
+ const darkThemeDeclaration = createThemeDeclaration(darkThemeProperty, 'darkTheme');
44
+
45
+ const printedCode = print(builders.program([lightThemeDeclaration, darkThemeDeclaration])).code;
46
+
47
+ writeFileSync('./src/design_system/colors_theme.ts', printedCode);
@@ -74,6 +74,8 @@ 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;
77
79
  };
78
80
 
79
81
  export const CODE_BLOCK_WITH_TABS_CLASSNAMES = {
@@ -190,7 +192,7 @@ const IMG_RESIZE = {
190
192
  height: 20,
191
193
  };
192
194
 
193
- export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, tabs, ...props }: CodeBlockWithTabsProps) => {
195
+ export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, tabs, optimisticCurrentTabKey, ...props }: CodeBlockWithTabsProps) => {
194
196
  const { generateProxyImageUrl } = useSharedUiDependencies();
195
197
  const currentTab = tabs.find((tab) => tab.key === currentTabKey) ?? tabs[0];
196
198
 
@@ -199,7 +201,7 @@ export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, ta
199
201
  <div className={CODE_BLOCK_WITH_TABS_CLASSNAMES.TABS}>
200
202
  {tabs.map((tab) => {
201
203
  const { label, src } = CODE_BLOCK_TAB_CATALOG[tab.key];
202
- const selected = tab.key === currentTab?.key;
204
+ const selected = (optimisticCurrentTabKey ?? currentTabKey) === tab.key;
203
205
 
204
206
  const commonProps = {
205
207
  className: clsx(CODE_BLOCK_WITH_TABS_CLASSNAMES.TAB, { selected }),
@@ -1,3 +1,3 @@
1
1
  export { useActorTitleHeadingFilter } from './utils.js';
2
2
  export { pythonizeValue } from './pythonize_value.js';
3
- export { TableOfContents } from './table_of_contents.js';
3
+ export { TableOfContents, useShowTableOfContents } from './table_of_contents.js';
@@ -14,6 +14,8 @@ import { Link } from '../link.js';
14
14
  import { Text } from '../text/index.js';
15
15
  import { cleanMarkdown, slugifyHeadingChildren } from './utils.js';
16
16
 
17
+ export const useShowTableOfContents = (markdown: string | null | undefined) => useMemo(() => markdown && !!markdown.match(/^(#{1,3})\s.+$/m), [markdown]);
18
+
17
19
  const TOC_HEADING_ID = 'Contents';
18
20
 
19
21
  const StyledTOCLink = styled(Text)`
@@ -1,44 +1,4 @@
1
- /**
2
- * Do not edit directly, this file was auto-generated.
3
- */
4
-
5
1
  export const lightTheme = {
6
- roseLight: '#f483b5',
7
- roseBase: '#c6387d',
8
- roseDark: '#781552',
9
- roseText: '#b6006b',
10
- buttercupLight: '#ffdd96',
11
- buttercupBase: '#f0b21b',
12
- buttercupDark: '#c37319',
13
- buttercupText: '#a65d00',
14
- paprikaLight: '#e44467',
15
- paprikaBase: '#9b0238',
16
- paprikaDark: '#4a0018',
17
- paprikaText: '#ba0044',
18
- tealLight: '#a7f2ed',
19
- tealBase: '#30c0bb',
20
- tealDark: '#297774',
21
- tealText: '#018181',
22
- indigoLight: '#a1b7ff',
23
- indigoBase: '#5d85e1',
24
- indigoDark: '#365494',
25
- indigoText: '#2563c1',
26
- slateLight: '#c1c5e1',
27
- slateBase: '#8490c4',
28
- slateDark: '#525c85',
29
- slateText: '#566087',
30
- coralLight: '#ffc89f',
31
- coralBase: '#fa8136',
32
- coralDark: '#bb4511',
33
- coralText: '#c74000',
34
- lavenderLight: '#bf97ed',
35
- lavenderBase: '#6a14de',
36
- lavenderDark: '#330276',
37
- lavenderText: '#6e00f4',
38
- bambooLight: '#64cda5',
39
- bambooBase: '#12966f',
40
- bambooDark: '#195d46',
41
- bambooText: '#007455',
42
2
  neutral0: '#ffffff',
43
3
  neutral25: '#f8f9fc',
44
4
  neutral50: '#f3f4fa',
@@ -107,4 +67,147 @@ export const lightTheme = {
107
67
  blue500: '#1672eb',
108
68
  blue600: '#1a57da',
109
69
  blue700: '#224ed5',
70
+ roseLight: '#f483b5',
71
+ roseBase: '#c6387d',
72
+ roseDark: '#781552',
73
+ roseText: '#b6006b',
74
+ buttercupLight: '#ffdd96',
75
+ buttercupBase: '#f0b21b',
76
+ buttercupDark: '#c37319',
77
+ buttercupText: '#a65d00',
78
+ paprikaLight: '#e44467',
79
+ paprikaBase: '#9b0238',
80
+ paprikaDark: '#4a0018',
81
+ paprikaText: '#ba0044',
82
+ tealLight: '#a7f2ed',
83
+ tealBase: '#30c0bb',
84
+ tealDark: '#297774',
85
+ tealText: '#018181',
86
+ indigoLight: '#a1b7ff',
87
+ indigoBase: '#5d85e1',
88
+ indigoDark: '#365494',
89
+ indigoText: '#2563c1',
90
+ slateLight: '#c1c5e1',
91
+ slateBase: '#8490c4',
92
+ slateDark: '#525c85',
93
+ slateText: '#566087',
94
+ coralLight: '#ffc89f',
95
+ coralBase: '#fa8136',
96
+ coralDark: '#bb4511',
97
+ coralText: '#c74000',
98
+ lavenderLight: '#bf97ed',
99
+ lavenderBase: '#6a14de',
100
+ lavenderDark: '#330276',
101
+ lavenderText: '#6e00f4',
102
+ bambooLight: '#64cda5',
103
+ bambooBase: '#12966f',
104
+ bambooDark: '#195d46',
105
+ bambooText: '#007455',
106
+ } as const;
107
+
108
+ export const darkTheme = {
109
+ neutral0: '#ffffff',
110
+ neutral25: '#f8f9fc',
111
+ neutral50: '#f3f4fa',
112
+ neutral75: '#eef0f8',
113
+ neutral100: '#e1e3ed',
114
+ neutral150: '#d1d5e4',
115
+ neutral200: '#c1c6d9',
116
+ neutral250: '#b2b8cc',
117
+ neutral300: '#a5abc0',
118
+ neutral350: '#989eb3',
119
+ neutral400: '#8c93a8',
120
+ neutral450: '#7d8499',
121
+ neutral500: '#6e758a',
122
+ neutral550: '#646a7f',
123
+ neutral600: '#575d71',
124
+ neutral650: '#4d5265',
125
+ neutral700: '#414758',
126
+ neutral750: '#343847',
127
+ neutral775: '#2d313e',
128
+ neutral800: '#2a2d39',
129
+ neutral850: '#252832',
130
+ neutral875: '#1e2027',
131
+ neutral900: '#1a1b21',
132
+ neutral950: '#101114',
133
+ yellow25: '#fcdc73',
134
+ yellow50: '#ffd761',
135
+ yellow75: '#f9ce4b',
136
+ yellow100: '#f5bc38',
137
+ yellow200: '#cf9117',
138
+ yellow300: '#a56909',
139
+ yellow350: '#8a4f05',
140
+ yellow400: '#6d3806',
141
+ yellow500: '#5d2e0e',
142
+ yellow600: '#3f1b07',
143
+ yellow700: '#301806',
144
+ red25: '#f5a790',
145
+ red50: '#fe9e8a',
146
+ red75: '#ff8770',
147
+ red100: '#ff7157',
148
+ red200: '#ef6045',
149
+ red300: '#cf4436',
150
+ red350: '#aa3229',
151
+ red400: '#812420',
152
+ red500: '#672523',
153
+ red600: '#40191b',
154
+ red700: '#381719',
155
+ green25: '#74d584',
156
+ green50: '#6ccd7c',
157
+ green75: '#55c06a',
158
+ green100: '#3bb358',
159
+ green200: '#23a64a',
160
+ green300: '#068a35',
161
+ green350: '#006e29',
162
+ green400: '#00531e',
163
+ green500: '#14441f',
164
+ green600: '#0f2b14',
165
+ green700: '#09260f',
166
+ blue25: '#92C0ff',
167
+ blue50: '#8ebcff',
168
+ blue75: '#80a9ff',
169
+ blue100: '#6f9dff',
170
+ blue200: '#5990ff',
171
+ blue300: '#3970d7',
172
+ blue350: '#295cbb',
173
+ blue400: '#194594',
174
+ blue500: '#1a3a78',
175
+ blue600: '#0d2550',
176
+ blue700: '#151d34',
177
+ roseLight: '#e88bb3',
178
+ roseBase: '#b8487b',
179
+ roseDark: '#6f234f',
180
+ roseText: '#ed8bb5',
181
+ buttercupLight: '#f9deaa',
182
+ buttercupBase: '#e5b557',
183
+ buttercupDark: '#b87939',
184
+ buttercupText: '#ebbf6c',
185
+ paprikaLight: '#e26c7d',
186
+ paprikaBase: '#9e384b',
187
+ paprikaDark: '#511d27',
188
+ paprikaText: '#f67c8d',
189
+ tealLight: '#aef0f5',
190
+ tealBase: '#58bcc4',
191
+ tealDark: '#408288',
192
+ tealText: '#62c1c8',
193
+ indigoLight: '#a8b7ed',
194
+ indigoBase: '#6d85ca',
195
+ indigoDark: '#425484',
196
+ indigoText: '#a2b2eb',
197
+ slateLight: '#c2c5dc',
198
+ slateBase: '#8690bf',
199
+ slateDark: '#535c81',
200
+ slateText: '#afb2c9',
201
+ coralLight: '#f3ccb0',
202
+ coralBase: '#f08848',
203
+ coralDark: '#9a4e2d',
204
+ coralText: '#f9b27b',
205
+ lavenderLight: '#b482ed',
206
+ lavenderBase: '#8148c9',
207
+ lavenderDark: '#48296f',
208
+ lavenderText: '#be8af9',
209
+ bambooLight: '#7acaa9',
210
+ bambooBase: '#439274',
211
+ bambooDark: '#305b4a',
212
+ bambooText: '#65bc99',
110
213
  } as const;
@@ -0,0 +1,44 @@
1
+ import { readFileSync } from 'node:fs';
2
+
3
+ const code = readFileSync('./src/design_system/supernova_color_tokens.json', 'utf-8');
4
+
5
+ const colorsDefinitions = JSON.parse(code);
6
+
7
+ const getObjectValueByPath = (obj, path) => {
8
+ return path.split('.').reduce((acc, part) => {
9
+ return acc && acc[part];
10
+ }, obj);
11
+ };
12
+
13
+ const getColorPropertyName = (semanticCategory, property) => {
14
+ const semanticColorName = `${property.split(/[_ ]/).map((semanticPartName) => semanticPartName.toLowerCase()).join('-')}`;
15
+
16
+ // lower case and replace spaces with dashes
17
+ const semanticCategoryName = semanticCategory.toLowerCase().split(' ').join('-');
18
+
19
+ return `--color-${semanticCategoryName}-${semanticColorName}`;
20
+ };
21
+
22
+ const generateColorDefinitions = (themeVariant) => {
23
+ const mergedPalette = {
24
+ ...colorsDefinitions[themeVariant].Semantic,
25
+ ...colorsDefinitions[themeVariant].Decorative,
26
+ };
27
+
28
+ const colorDefinitions = [];
29
+ for (const [semanticCategory, palette] of Object.entries(mergedPalette)) {
30
+ for (const [key, { value }] of Object.entries(palette)) {
31
+ colorDefinitions.push(
32
+
33
+ `${getColorPropertyName(semanticCategory, key)}: ${value.startsWith('#') ? value : getObjectValueByPath(colorsDefinitions[themeVariant], value.slice(1, -1)).value};`,
34
+ );
35
+ }
36
+ }
37
+
38
+ return colorDefinitions.join('\n');
39
+ };
40
+
41
+ ['light', 'dark'].forEach((themeVariant) => {
42
+ // eslint-disable-next-line no-console
43
+ console.log(`\n*** CSS variables from ${themeVariant} mode ***\n`, generateColorDefinitions(themeVariant));
44
+ });