@shohojdhara/atomix 0.3.4 → 0.3.6

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 (237) hide show
  1. package/README.md +101 -199
  2. package/atomix.config.ts +241 -0
  3. package/dist/atomix.css +269 -189
  4. package/dist/atomix.css.map +1 -0
  5. package/dist/atomix.min.css +15179 -11
  6. package/dist/atomix.min.css.map +1 -0
  7. package/dist/charts.d.ts +1929 -0
  8. package/dist/charts.js +6477 -0
  9. package/dist/charts.js.map +1 -0
  10. package/dist/core.d.ts +1289 -0
  11. package/dist/core.js +3373 -0
  12. package/dist/core.js.map +1 -0
  13. package/dist/forms.d.ts +1085 -0
  14. package/dist/forms.js +2466 -0
  15. package/dist/forms.js.map +1 -0
  16. package/dist/heavy.d.ts +636 -0
  17. package/dist/heavy.js +4566 -0
  18. package/dist/heavy.js.map +1 -0
  19. package/dist/index.d.ts +5171 -4792
  20. package/dist/index.esm.js +6098 -4563
  21. package/dist/index.esm.js.map +1 -1
  22. package/dist/index.js +6291 -4747
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.min.js +1 -1
  25. package/dist/index.min.js.map +1 -1
  26. package/dist/layout.d.ts +300 -0
  27. package/dist/layout.js +336 -0
  28. package/dist/layout.js.map +1 -0
  29. package/dist/theme.d.ts +2122 -0
  30. package/dist/theme.js +6084 -0
  31. package/dist/theme.js.map +1 -0
  32. package/package.json +59 -27
  33. package/scripts/atomix-cli.js +544 -16
  34. package/scripts/cli/__tests__/cli-commands.test.js +204 -0
  35. package/scripts/cli/__tests__/utils.test.js +201 -0
  36. package/scripts/cli/__tests__/vitest.config.js +26 -0
  37. package/scripts/cli/interactive-init.js +1 -1
  38. package/scripts/cli/token-manager.js +32 -7
  39. package/scripts/cli/utils.js +347 -0
  40. package/src/components/Accordion/Accordion.stories.tsx +50 -17
  41. package/src/components/Accordion/Accordion.tsx +5 -54
  42. package/src/components/Accordion/index.ts +1 -1
  43. package/src/components/AtomixGlass/AtomixGlass.tsx +65 -31
  44. package/src/components/AtomixGlass/AtomixGlassContainer.tsx +11 -4
  45. package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +1 -32
  46. package/src/components/AtomixGlass/stories/Examples.stories.tsx +2 -2
  47. package/src/components/AtomixGlass/stories/shared-components.tsx +0 -31
  48. package/src/components/Avatar/Avatar.stories.tsx +7 -0
  49. package/src/components/Avatar/Avatar.tsx +3 -3
  50. package/src/components/Badge/Badge.stories.tsx +91 -13
  51. package/src/components/Badge/Badge.tsx +3 -3
  52. package/src/components/Block/Block.stories.tsx +7 -23
  53. package/src/components/Breadcrumb/Breadcrumb.stories.tsx +7 -0
  54. package/src/components/Breadcrumb/Breadcrumb.tsx +3 -3
  55. package/src/components/Button/Button.stories.tsx +141 -22
  56. package/src/components/Button/ButtonGroup.stories.tsx +315 -0
  57. package/src/components/Button/ButtonGroup.tsx +67 -0
  58. package/src/components/Button/index.ts +2 -0
  59. package/src/components/Callout/Callout.stories.tsx +8 -6
  60. package/src/components/Card/Card.stories.tsx +82 -28
  61. package/src/components/Card/ElevationCard.tsx +1 -1
  62. package/src/components/Chart/AnimatedChart.tsx +19 -18
  63. package/src/components/Chart/AreaChart.tsx +5 -2
  64. package/src/components/Chart/BarChart.tsx +1 -1
  65. package/src/components/Chart/BubbleChart.tsx +6 -6
  66. package/src/components/Chart/CandlestickChart.tsx +0 -1
  67. package/src/components/Chart/Chart.stories.tsx +5 -7
  68. package/src/components/Chart/Chart.tsx +0 -16
  69. package/src/components/Chart/ChartRenderer.tsx +1 -1
  70. package/src/components/Chart/ChartToolbar.tsx +1 -0
  71. package/src/components/Chart/DonutChart.tsx +0 -1
  72. package/src/components/Chart/FunnelChart.tsx +1 -2
  73. package/src/components/Chart/GaugeChart.tsx +0 -1
  74. package/src/components/Chart/HeatmapChart.tsx +0 -1
  75. package/src/components/Chart/LineChart.tsx +0 -1
  76. package/src/components/Chart/MultiAxisChart.tsx +0 -1
  77. package/src/components/Chart/PieChart.tsx +0 -1
  78. package/src/components/Chart/RadarChart.tsx +19 -13
  79. package/src/components/Chart/ScatterChart.tsx +3 -4
  80. package/src/components/Chart/TreemapChart.tsx +2 -1
  81. package/src/components/Chart/WaterfallChart.tsx +0 -2
  82. package/src/components/Chart/types.ts +12 -2
  83. package/src/components/Chart/utils.ts +4 -3
  84. package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +7 -0
  85. package/src/components/DataTable/DataTable.stories.tsx +23 -16
  86. package/src/components/DataTable/DataTable.tsx +3 -3
  87. package/src/components/DatePicker/DatePicker.stories.tsx +27 -19
  88. package/src/components/Dropdown/Dropdown.stories.tsx +11 -19
  89. package/src/components/Dropdown/Dropdown.tsx +12 -9
  90. package/src/components/EdgePanel/EdgePanel.stories.tsx +1 -0
  91. package/src/components/Footer/Footer.stories.tsx +8 -6
  92. package/src/components/Footer/FooterLink.tsx +9 -2
  93. package/src/components/Footer/FooterSection.tsx +3 -3
  94. package/src/components/Form/Checkbox.stories.tsx +7 -0
  95. package/src/components/Form/Checkbox.tsx +3 -3
  96. package/src/components/Form/Form.stories.tsx +7 -0
  97. package/src/components/Form/FormGroup.stories.tsx +9 -1
  98. package/src/components/Form/Input.stories.tsx +69 -16
  99. package/src/components/Form/Input.tsx +4 -2
  100. package/src/components/Form/Radio.stories.tsx +9 -1
  101. package/src/components/Form/Radio.tsx +3 -3
  102. package/src/components/Form/Select.stories.tsx +9 -1
  103. package/src/components/Form/Select.tsx +3 -3
  104. package/src/components/Form/Textarea.stories.tsx +10 -2
  105. package/src/components/Form/Textarea.tsx +4 -2
  106. package/src/components/Hero/Hero.stories.tsx +7 -0
  107. package/src/components/List/List.stories.tsx +10 -3
  108. package/src/components/List/List.tsx +3 -3
  109. package/src/components/List/ListGroup.tsx +3 -1
  110. package/src/components/Messages/Messages.stories.tsx +8 -7
  111. package/src/components/Modal/Modal.stories.tsx +17 -6
  112. package/src/components/Modal/Modal.tsx +3 -3
  113. package/src/components/Navigation/Menu/MegaMenu.tsx +9 -3
  114. package/src/components/Navigation/Menu/Menu.stories.tsx +7 -0
  115. package/src/components/Navigation/Menu/Menu.tsx +9 -3
  116. package/src/components/Navigation/Nav/Nav.stories.tsx +7 -0
  117. package/src/components/Navigation/Navbar/Navbar.stories.tsx +1 -0
  118. package/src/components/Navigation/SideMenu/SideMenu.stories.tsx +1 -1
  119. package/src/components/Pagination/Pagination.stories.tsx +188 -111
  120. package/src/components/Pagination/Pagination.tsx +88 -7
  121. package/src/components/PhotoViewer/PhotoViewer.stories.tsx +10 -5
  122. package/src/components/PhotoViewer/PhotoViewerImage.tsx +2 -2
  123. package/src/components/Popover/Popover.stories.tsx +191 -115
  124. package/src/components/Popover/Popover.tsx +4 -4
  125. package/src/components/ProductReview/ProductReview.stories.tsx +80 -58
  126. package/src/components/Progress/Progress.stories.tsx +79 -49
  127. package/src/components/Progress/Progress.tsx +6 -2
  128. package/src/components/Rating/Rating.stories.tsx +109 -84
  129. package/src/components/Rating/Rating.tsx +5 -2
  130. package/src/components/River/River.stories.tsx +194 -114
  131. package/src/components/SectionIntro/SectionIntro.stories.tsx +19 -9
  132. package/src/components/Slider/Slider.stories.tsx +7 -0
  133. package/src/components/Slider/Slider.tsx +10 -9
  134. package/src/components/Spinner/Spinner.stories.tsx +15 -11
  135. package/src/components/Spinner/Spinner.tsx +3 -3
  136. package/src/components/Steps/Steps.stories.tsx +132 -98
  137. package/src/components/Tabs/Tabs.stories.tsx +163 -112
  138. package/src/components/Tabs/Tabs.tsx +3 -3
  139. package/src/components/Testimonial/Testimonial.stories.tsx +114 -68
  140. package/src/components/Todo/Todo.stories.tsx +38 -12
  141. package/src/components/Toggle/Toggle.stories.tsx +61 -28
  142. package/src/components/Tooltip/Tooltip.stories.tsx +318 -200
  143. package/src/components/Tooltip/Tooltip.tsx +3 -3
  144. package/src/components/Upload/Upload.stories.tsx +122 -84
  145. package/src/components/VideoPlayer/VideoPlayer.stories.tsx +7 -24
  146. package/src/components/index.ts +6 -2
  147. package/src/layouts/MasonryGrid/MasonryGrid.tsx +2 -2
  148. package/src/lib/composables/useAtomixGlass.ts +2 -3
  149. package/src/lib/composables/useChartPerformance.ts +102 -78
  150. package/src/lib/composables/useChartScale.ts +10 -0
  151. package/src/lib/composables/useHero.ts +9 -2
  152. package/src/lib/composables/useHeroBackgroundSlider.ts +5 -3
  153. package/src/lib/composables/useNavbar.ts +0 -10
  154. package/src/lib/composables/useSideMenu.ts +1 -0
  155. package/src/lib/composables/useVideoPlayer.ts +3 -2
  156. package/src/lib/config/loader.ts +57 -14
  157. package/src/lib/constants/components.ts +10 -0
  158. package/src/lib/hooks/index.ts +0 -1
  159. package/src/lib/hooks/useComponentCustomization.ts +11 -15
  160. package/src/lib/hooks/usePerformanceMonitor.ts +149 -0
  161. package/src/lib/patterns/index.ts +2 -2
  162. package/src/lib/patterns/slots.tsx +2 -2
  163. package/src/lib/theme/README.md +174 -0
  164. package/src/lib/theme/adapters/index.ts +31 -0
  165. package/src/lib/theme/adapters/themeAdapter.ts +287 -0
  166. package/src/lib/theme/config/__tests__/configLoader.test.ts +207 -0
  167. package/src/lib/theme/config/configLoader.ts +254 -0
  168. package/src/lib/theme/config/loader.ts +37 -48
  169. package/src/lib/theme/config/types.ts +2 -2
  170. package/src/lib/theme/config/validator.ts +15 -91
  171. package/src/lib/theme/{constants.ts → constants/constants.ts} +0 -18
  172. package/src/lib/theme/constants/index.ts +8 -0
  173. package/src/lib/theme/core/ThemeRegistry.ts +19 -6
  174. package/src/lib/theme/core/__tests__/createTheme.test.ts +132 -0
  175. package/src/lib/theme/core/composeTheme.ts +155 -0
  176. package/src/lib/theme/core/createTheme.ts +94 -0
  177. package/src/lib/theme/{createTheme.ts → core/createThemeObject.ts} +10 -6
  178. package/src/lib/theme/core/index.ts +5 -19
  179. package/src/lib/theme/devtools/Comparator.tsx +346 -22
  180. package/src/lib/theme/devtools/IMPROVEMENTS.md +139 -38
  181. package/src/lib/theme/devtools/Inspector.tsx +335 -51
  182. package/src/lib/theme/devtools/LiveEditor.tsx +489 -112
  183. package/src/lib/theme/devtools/Preview.tsx +471 -221
  184. package/src/lib/theme/{core → devtools}/ThemeValidator.ts +6 -3
  185. package/src/lib/theme/devtools/index.ts +14 -4
  186. package/src/lib/theme/devtools/useHistory.ts +130 -0
  187. package/src/lib/theme/errors/index.ts +12 -0
  188. package/src/lib/theme/generators/cssFile.ts +79 -0
  189. package/src/lib/theme/generators/generateCSS.ts +89 -0
  190. package/src/lib/theme/{generateCSSVariables.ts → generators/generateCSSVariables.ts} +4 -14
  191. package/src/lib/theme/generators/index.ts +19 -0
  192. package/src/lib/theme/i18n/rtl.ts +7 -7
  193. package/src/lib/theme/index.ts +120 -15
  194. package/src/lib/theme/runtime/ThemeApplicator.ts +53 -95
  195. package/src/lib/theme/{ThemeContext.tsx → runtime/ThemeContext.tsx} +1 -1
  196. package/src/lib/theme/runtime/ThemeErrorBoundary.tsx +4 -4
  197. package/src/lib/theme/runtime/ThemeProvider.tsx +456 -179
  198. package/src/lib/theme/runtime/index.ts +1 -2
  199. package/src/lib/theme/runtime/useTheme.ts +1 -2
  200. package/src/lib/theme/test/testTheme.ts +385 -0
  201. package/src/lib/theme/tokens/index.ts +12 -0
  202. package/src/lib/theme/tokens/tokens.ts +721 -0
  203. package/src/lib/theme/types.ts +6 -42
  204. package/src/lib/theme/{utils.ts → utils/domUtils.ts} +2 -2
  205. package/src/lib/theme/utils/index.ts +11 -0
  206. package/src/lib/theme/utils/injectCSS.ts +90 -0
  207. package/src/lib/theme/utils/themeHelpers.ts +78 -0
  208. package/src/lib/theme/{themeUtils.ts → utils/themeUtils.ts} +1 -1
  209. package/src/lib/theme-tools.ts +8 -9
  210. package/src/lib/types/components.ts +93 -34
  211. package/src/lib/types/partProps.ts +0 -16
  212. package/src/lib/utils/componentUtils.ts +1 -1
  213. package/src/lib/utils/fontPreloader.ts +148 -0
  214. package/src/lib/utils/index.ts +11 -0
  215. package/src/lib/utils/memoryMonitor.ts +189 -0
  216. package/src/styles/01-settings/_settings.design-tokens.scss +4 -1
  217. package/src/styles/01-settings/_settings.fonts.scss +2 -5
  218. package/src/styles/02-tools/_tools.button.scss +66 -79
  219. package/src/styles/06-components/_components.atomix-glass.scss +13 -3
  220. package/src/styles/06-components/_components.navbar.scss +0 -6
  221. package/src/styles/06-components/_components.pagination.scss +88 -0
  222. package/scripts/build-themes.js +0 -208
  223. package/scripts/sync-theme-config.js +0 -309
  224. package/src/components/AtomixGlass/atomixGLass.old.tsx +0 -1263
  225. package/src/lib/theme/composeTheme.ts +0 -370
  226. package/src/lib/theme/core/ThemeCache.ts +0 -283
  227. package/src/lib/theme/core/ThemeEngine.test.ts +0 -146
  228. package/src/lib/theme/core/ThemeEngine.ts +0 -657
  229. package/src/lib/theme/createThemeFromConfig.ts +0 -132
  230. package/src/lib/theme/devtools/CLI.ts +0 -364
  231. package/src/lib/theme/runtime/ThemeManager.test.ts +0 -192
  232. package/src/lib/theme/runtime/ThemeManager.ts +0 -442
  233. package/src/styles/03-generic/_generated-root.css +0 -5
  234. package/src/themes/README.md +0 -442
  235. package/src/themes/themes.config.js +0 -35
  236. /package/src/lib/theme/{cssVariableMapper.ts → adapters/cssVariableMapper.ts} +0 -0
  237. /package/src/lib/theme/{errors.ts → errors/errors.ts} +0 -0
@@ -1,208 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Build script for Atomix themes
5
- *
6
- * This script compiles all theme SCSS files to CSS
7
- * and generates both expanded and minified versions.
8
- */
9
-
10
- import { readdir, mkdir, access } from 'fs/promises';
11
- import { join, basename } from 'path';
12
- import * as sass from 'sass';
13
- import postcss from 'postcss';
14
- import autoprefixer from 'autoprefixer';
15
- import cssnano from 'cssnano';
16
- import { fileURLToPath } from 'url';
17
- import { dirname } from 'path';
18
-
19
- const __filename = fileURLToPath(import.meta.url);
20
- const __dirname = dirname(__filename);
21
-
22
- // Configuration
23
- const THEMES_DIR = join(__dirname, '../src/themes');
24
- const OUTPUT_DIR = join(__dirname, '../dist/themes');
25
- const EXCLUDE_FILES = ['README.md', 'THEME_CHECKLIST.md', 'themes.config.js'];
26
-
27
- /**
28
- * Ensure output directory exists
29
- */
30
- async function ensureOutputDir() {
31
- try {
32
- await access(OUTPUT_DIR);
33
- } catch {
34
- await mkdir(OUTPUT_DIR, { recursive: true });
35
- console.log(`āœ… Created output directory: ${OUTPUT_DIR}`);
36
- }
37
- }
38
-
39
- /**
40
- * Get list of themes to build
41
- */
42
- async function getThemes() {
43
- const entries = await readdir(THEMES_DIR, { withFileTypes: true });
44
- const themes = entries
45
- .filter(entry => entry.isDirectory())
46
- .map(entry => entry.name);
47
-
48
- console.log(`šŸ“¦ Found ${themes.length} themes: ${themes.join(', ')}`);
49
- return themes;
50
- }
51
-
52
- /**
53
- * Check if theme has an index.scss file
54
- */
55
- async function hasIndexScss(themeName) {
56
- try {
57
- await access(join(THEMES_DIR, themeName, 'index.scss'));
58
- return true;
59
- } catch {
60
- return false;
61
- }
62
- }
63
-
64
- /**
65
- * Build a single theme
66
- */
67
- async function buildTheme(themeName) {
68
- const indexPath = join(THEMES_DIR, themeName, 'index.scss');
69
-
70
- // Check if index.scss exists
71
- if (!(await hasIndexScss(themeName))) {
72
- console.log(`āš ļø Skipping ${themeName}: No index.scss found`);
73
- return;
74
- }
75
-
76
- console.log(`šŸ”Ø Building theme: ${themeName}`);
77
-
78
- try {
79
- // Compile SCSS
80
- const result = sass.compile(indexPath, {
81
- loadPaths: [
82
- join(__dirname, '../src'),
83
- join(__dirname, '../src/styles'),
84
- join(__dirname, '../node_modules'),
85
- ],
86
- sourceMap: true,
87
- style: 'expanded',
88
- });
89
-
90
- // Process with PostCSS (autoprefixer)
91
- const processed = await postcss([
92
- autoprefixer({
93
- overrideBrowserslist: ['> 1%', 'last 2 versions', 'not dead'],
94
- }),
95
- ]).process(result.css, {
96
- from: indexPath,
97
- to: join(OUTPUT_DIR, `${themeName}.css`),
98
- map: { inline: false },
99
- });
100
-
101
- // Write expanded CSS
102
- const { writeFile } = await import('fs/promises');
103
- await writeFile(
104
- join(OUTPUT_DIR, `${themeName}.css`),
105
- processed.css,
106
- 'utf8'
107
- );
108
-
109
- // Write source map if available
110
- if (processed.map) {
111
- await writeFile(
112
- join(OUTPUT_DIR, `${themeName}.css.map`),
113
- processed.map.toString(),
114
- 'utf8'
115
- );
116
- }
117
-
118
- console.log(` āœ… Generated ${themeName}.css`);
119
-
120
- // Create minified version
121
- const minified = await postcss([
122
- autoprefixer({
123
- overrideBrowserslist: ['> 1%', 'last 2 versions', 'not dead'],
124
- }),
125
- cssnano({
126
- preset: 'default',
127
- }),
128
- ]).process(result.css, {
129
- from: indexPath,
130
- to: join(OUTPUT_DIR, `${themeName}.min.css`),
131
- });
132
-
133
- await writeFile(
134
- join(OUTPUT_DIR, `${themeName}.min.css`),
135
- minified.css,
136
- 'utf8'
137
- );
138
-
139
- console.log(` āœ… Generated ${themeName}.min.css`);
140
-
141
- return {
142
- theme: themeName,
143
- success: true,
144
- files: [
145
- `${themeName}.css`,
146
- `${themeName}.min.css`,
147
- ],
148
- };
149
- } catch (error) {
150
- console.error(` āŒ Failed to build ${themeName}:`, error.message);
151
- return {
152
- theme: themeName,
153
- success: false,
154
- error: error.message,
155
- };
156
- }
157
- }
158
-
159
- /**
160
- * Build all themes
161
- */
162
- async function buildAllThemes() {
163
- console.log('šŸš€ Starting theme build process...\n');
164
-
165
- // Ensure output directory exists
166
- await ensureOutputDir();
167
-
168
- // Get list of themes
169
- const themes = await getThemes();
170
-
171
- // Build each theme
172
- const results = [];
173
- for (const theme of themes) {
174
- const result = await buildTheme(theme);
175
- results.push(result);
176
- console.log(''); // Add spacing between themes
177
- }
178
-
179
- // Summary
180
- console.log('šŸ“Š Build Summary:');
181
- const successful = results.filter(r => r?.success).length;
182
- const failed = results.filter(r => r && !r.success).length;
183
- const skipped = results.filter(r => !r).length;
184
-
185
- console.log(` āœ… Successful: ${successful}`);
186
- if (failed > 0) {
187
- console.log(` āŒ Failed: ${failed}`);
188
- results.filter(r => r && !r.success).forEach(r => {
189
- console.log(` - ${r.theme}: ${r.error}`);
190
- });
191
- }
192
- if (skipped > 0) {
193
- console.log(` āš ļø Skipped: ${skipped}`);
194
- }
195
-
196
- console.log('\n✨ Theme build complete!');
197
-
198
- // Exit with error code if any builds failed
199
- if (failed > 0) {
200
- process.exit(1);
201
- }
202
- }
203
-
204
- // Run the build
205
- buildAllThemes().catch(error => {
206
- console.error('šŸ’„ Build failed:', error);
207
- process.exit(1);
208
- });
@@ -1,309 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Sync Theme Configuration
5
- *
6
- * This script generates src/themes/themes.config.js from theme.config.ts
7
- * to maintain a single source of truth for theme configuration.
8
- */
9
-
10
- import { readFile, writeFile } from 'fs/promises';
11
- import { join, dirname } from 'path';
12
- import { fileURLToPath } from 'url';
13
-
14
- const __filename = fileURLToPath(import.meta.url);
15
- const __dirname = dirname(__filename);
16
-
17
- // File paths
18
- const THEME_CONFIG_TS = join(__dirname, '../theme.config.ts');
19
- const THEMES_CONFIG_JS = join(__dirname, '../src/themes/themes.config.js');
20
-
21
- /**
22
- * Parse theme.config.ts to extract configuration
23
- * Note: This is a simplified parser that works with the current structure
24
- */
25
- async function parseThemeConfigTS() {
26
- try {
27
- const content = await readFile(THEME_CONFIG_TS, 'utf8');
28
-
29
- // Extract themes object
30
- const themesMatch = content.match(/themes:\s*{([^}]+(?:{[^}]*}[^}]*)*[^}]+)}/s);
31
- if (!themesMatch) {
32
- throw new Error('Could not find themes configuration');
33
- }
34
-
35
- // Extract individual theme configurations
36
- const themes = {};
37
- const themeRegex = /['"]([^'"]+)['"]\s*:\s*{([^}]+(?:{[^}]*}[^}]*)*[^}]+)}/gs;
38
- let match;
39
-
40
- while ((match = themeRegex.exec(themesMatch[1])) !== null) {
41
- const [, themeName, themeConfig] = match;
42
-
43
- // Parse theme properties
44
- const theme = {
45
- name: extractValue(themeConfig, 'name'),
46
- description: extractValue(themeConfig, 'description'),
47
- author: extractValue(themeConfig, 'author'),
48
- version: extractValue(themeConfig, 'version'),
49
- tags: extractArray(themeConfig, 'tags'),
50
- supportsDarkMode: extractBoolean(themeConfig, 'supportsDarkMode'),
51
- status: extractValue(themeConfig, 'status'),
52
- color: extractValue(themeConfig, 'color'),
53
- };
54
-
55
- // Parse features if present
56
- const featuresMatch = themeConfig.match(/features:\s*\[([^\]]*)\]/s);
57
- if (featuresMatch) {
58
- theme.features = featuresMatch[1]
59
- .split(',')
60
- .map(f => f.trim().replace(/['"]/g, ''))
61
- .filter(f => f.length > 0);
62
- }
63
-
64
- // Parse a11y if present
65
- const a11yMatch = themeConfig.match(/a11y:\s*{([^}]*)}/);
66
- if (a11yMatch) {
67
- theme.a11y = {
68
- contrastTarget: extractNumber(a11yMatch[1], 'contrastTarget'),
69
- modes: extractArray(a11yMatch[1], 'modes'),
70
- };
71
- }
72
-
73
- themes[themeName] = theme;
74
- }
75
-
76
- // Extract build configuration
77
- const buildMatch = content.match(/build:\s*(defaultBuildConfig|{[^}]+})/);
78
- const build = buildMatch && buildMatch[1] === 'defaultBuildConfig'
79
- ? getDefaultBuildConfig()
80
- : parseBuildConfig(buildMatch?.[1]);
81
-
82
- // Extract runtime configuration
83
- const runtimeMatch = content.match(/runtime:\s*(defaultRuntimeConfig|{[^}]+})/);
84
- const runtime = runtimeMatch && runtimeMatch[1] === 'defaultRuntimeConfig'
85
- ? getDefaultRuntimeConfig()
86
- : parseRuntimeConfig(runtimeMatch?.[1]);
87
-
88
- // Extract integration configuration
89
- const integrationMatch = content.match(/integration:\s*(defaultIntegrationConfig|{[^}]+})/);
90
- const integration = integrationMatch && integrationMatch[1] === 'defaultIntegrationConfig'
91
- ? getDefaultIntegrationConfig()
92
- : parseIntegrationConfig(integrationMatch?.[1]);
93
-
94
- return {
95
- themes,
96
- build,
97
- runtime,
98
- integration,
99
- dependencies: {},
100
- };
101
- } catch (error) {
102
- console.error('āŒ Failed to parse theme.config.ts:', error.message);
103
- throw error;
104
- }
105
- }
106
-
107
- /**
108
- * Helper function to extract string values
109
- */
110
- function extractValue(text, key) {
111
- const regex = new RegExp(`${key}:\\s*['"]([^'"]+)['"]`);
112
- const match = text.match(regex);
113
- return match ? match[1] : undefined;
114
- }
115
-
116
- /**
117
- * Helper function to extract number values
118
- */
119
- function extractNumber(text, key) {
120
- const regex = new RegExp(`${key}:\\s*(\\d+(?:\\.\\d+)?)`);
121
- const match = text.match(regex);
122
- return match ? parseFloat(match[1]) : undefined;
123
- }
124
-
125
- /**
126
- * Helper function to extract boolean values
127
- */
128
- function extractBoolean(text, key) {
129
- const regex = new RegExp(`${key}:\\s*(true|false)`);
130
- const match = text.match(regex);
131
- return match ? match[1] === 'true' : undefined;
132
- }
133
-
134
- /**
135
- * Helper function to extract array values
136
- */
137
- function extractArray(text, key) {
138
- const regex = new RegExp(`${key}:\\s*\\[([^\\]]*)\\]`);
139
- const match = text.match(regex);
140
- if (!match) return undefined;
141
-
142
- return match[1]
143
- .split(',')
144
- .map(item => item.trim().replace(/['"]/g, ''))
145
- .filter(item => item.length > 0);
146
- }
147
-
148
- /**
149
- * Get default build configuration
150
- */
151
- function getDefaultBuildConfig() {
152
- return {
153
- output: {
154
- directory: 'themes',
155
- formats: {
156
- expanded: '.css',
157
- compressed: '.min.css',
158
- },
159
- },
160
- sass: {
161
- style: 'expanded',
162
- sourceMap: true,
163
- loadPaths: ['src'],
164
- },
165
- };
166
- }
167
-
168
- /**
169
- * Get default runtime configuration
170
- */
171
- function getDefaultRuntimeConfig() {
172
- return {
173
- basePath: '/themes',
174
- cdnPath: null,
175
- preload: [],
176
- lazy: true,
177
- defaultTheme: '',
178
- storageKey: 'atomix-theme',
179
- useMinified: "process.env.NODE_ENV === 'production'",
180
- };
181
- }
182
-
183
- /**
184
- * Get default integration configuration
185
- */
186
- function getDefaultIntegrationConfig() {
187
- return {
188
- cssVariables: {
189
- colorMode: '--storybook-color-mode',
190
- },
191
- classNames: {
192
- theme: 'data-theme',
193
- colorMode: 'data-atomix-color-mode',
194
- },
195
- };
196
- }
197
-
198
- /**
199
- * Parse build configuration
200
- */
201
- function parseBuildConfig(configText) {
202
- if (!configText) return getDefaultBuildConfig();
203
- // For now, return default config
204
- // A more sophisticated parser would be needed for complex objects
205
- return getDefaultBuildConfig();
206
- }
207
-
208
- /**
209
- * Parse runtime configuration
210
- */
211
- function parseRuntimeConfig(configText) {
212
- if (!configText) return getDefaultRuntimeConfig();
213
- // For now, return default config
214
- // A more sophisticated parser would be needed for complex objects
215
- return getDefaultRuntimeConfig();
216
- }
217
-
218
- /**
219
- * Parse integration configuration
220
- */
221
- function parseIntegrationConfig(configText) {
222
- if (!configText) return getDefaultIntegrationConfig();
223
- // For now, return default config
224
- // A more sophisticated parser would be needed for complex objects
225
- return getDefaultIntegrationConfig();
226
- }
227
-
228
- /**
229
- * Generate themes.config.js content
230
- */
231
- function generateThemesConfigJS(config) {
232
- const { themes, build, runtime, integration, dependencies } = config;
233
-
234
- // Convert themes to metadata format
235
- const metadata = {};
236
- for (const [key, theme] of Object.entries(themes)) {
237
- metadata[key] = { ...theme };
238
- // Remove undefined values
239
- Object.keys(metadata[key]).forEach(k => {
240
- if (metadata[key][k] === undefined) {
241
- delete metadata[key][k];
242
- }
243
- });
244
- }
245
-
246
- return `/**
247
- * Theme Configuration
248
- *
249
- * This file is auto-generated from theme.config.ts
250
- * DO NOT EDIT MANUALLY - Edit theme.config.ts instead
251
- *
252
- * Generated on: ${new Date().toISOString()}
253
- */
254
-
255
- export const themesConfig = {
256
- // Theme metadata
257
- metadata: ${JSON.stringify(metadata, null, 4).replace(/"([^"]+)":/g, '$1:')},
258
-
259
- // Build configuration
260
- build: ${JSON.stringify(build, null, 4).replace(/"([^"]+)":/g, '$1:')},
261
-
262
- // Export configuration for package.json
263
- exports: {
264
- './themes/*': './dist/themes/*.css',
265
- './themes/*.min': './dist/themes/*.min.css',
266
- },
267
-
268
- // Theme integration settings
269
- integration: ${JSON.stringify(integration, null, 4).replace(/"([^"]+)":/g, '$1:')},
270
-
271
- // Runtime theme loading configuration
272
- runtime: ${JSON.stringify(runtime, null, 4).replace(/"([^"]+)":/g, '$1:').replace(/"process\.env\.NODE_ENV === 'production'"/g, "process.env.NODE_ENV === 'production'")},
273
-
274
- // Theme dependencies (if a theme requires another theme to be loaded)
275
- dependencies: ${JSON.stringify(dependencies, null, 4).replace(/"([^"]+)":/g, '$1:')},
276
- };`;
277
- }
278
-
279
- /**
280
- * Main function
281
- */
282
- async function main() {
283
- console.log('šŸ”„ Syncing theme configuration...\n');
284
-
285
- try {
286
- // Parse theme.config.ts
287
- console.log('šŸ“– Reading theme.config.ts...');
288
- const config = await parseThemeConfigTS();
289
- console.log(` āœ… Found ${Object.keys(config.themes).length} themes`);
290
-
291
- // Generate themes.config.js
292
- console.log('\nšŸ“ Generating themes.config.js...');
293
- const jsContent = generateThemesConfigJS(config);
294
-
295
- // Write to file
296
- await writeFile(THEMES_CONFIG_JS, jsContent, 'utf8');
297
- console.log(' āœ… Written to src/themes/themes.config.js');
298
-
299
- console.log('\n✨ Configuration sync complete!');
300
- console.log(' themes.config.js has been updated from theme.config.ts');
301
-
302
- } catch (error) {
303
- console.error('\nšŸ’„ Sync failed:', error.message);
304
- process.exit(1);
305
- }
306
- }
307
-
308
- // Run the sync
309
- main();