@shohojdhara/atomix 0.3.2 → 0.3.4

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 (84) hide show
  1. package/README.md +58 -21
  2. package/dist/atomix.css +96 -121
  3. package/dist/atomix.min.css +3 -3
  4. package/dist/index.d.ts +7937 -7765
  5. package/dist/index.esm.js +3677 -4031
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.js +3648 -3952
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.min.js +1 -1
  10. package/dist/index.min.js.map +1 -1
  11. package/package.json +44 -16
  12. package/scripts/atomix-cli.js +1764 -0
  13. package/scripts/build-themes.js +208 -0
  14. package/scripts/cli/interactive-init.js +520 -0
  15. package/scripts/cli/migration-tools.js +603 -0
  16. package/scripts/cli/theme-bridge.js +129 -0
  17. package/scripts/cli/token-manager.js +519 -0
  18. package/scripts/sync-theme-config.js +309 -0
  19. package/src/components/Button/Button.tsx +36 -1
  20. package/src/components/List/ListGroup.tsx +1 -2
  21. package/src/components/Popover/Popover.tsx +2 -2
  22. package/src/components/Tooltip/Tooltip.stories.tsx +49 -12
  23. package/src/components/Tooltip/Tooltip.tsx +32 -58
  24. package/src/lib/composables/useTooltip.ts +285 -0
  25. package/src/lib/config/index.ts +275 -0
  26. package/src/lib/config/loader.ts +105 -0
  27. package/src/lib/constants/cssVariables.ts +390 -0
  28. package/src/lib/hooks/__tests__/useComponentCustomization.test.ts +151 -0
  29. package/src/lib/hooks/index.ts +19 -0
  30. package/src/lib/hooks/useComponentCustomization.ts +175 -0
  31. package/src/lib/index.ts +14 -1
  32. package/src/lib/patterns/__tests__/slots.test.ts +108 -0
  33. package/src/lib/patterns/index.ts +35 -0
  34. package/src/lib/patterns/slots.tsx +421 -0
  35. package/src/lib/theme/composeTheme.ts +0 -5
  36. package/src/lib/theme/config/index.ts +1 -1
  37. package/src/lib/theme/config/loader.ts +75 -41
  38. package/src/lib/theme/config/types.ts +21 -7
  39. package/src/lib/theme/config/validator.ts +1 -1
  40. package/src/lib/theme/constants.ts +12 -2
  41. package/src/lib/theme/createTheme.ts +2 -135
  42. package/src/lib/theme/createThemeFromConfig.ts +132 -0
  43. package/src/lib/theme/cssVariableMapper.ts +261 -0
  44. package/src/lib/theme/devtools/CLI.ts +161 -76
  45. package/src/lib/theme/devtools/Comparator.tsx +343 -0
  46. package/src/lib/theme/devtools/IMPROVEMENTS.md +429 -0
  47. package/src/lib/theme/devtools/Inspector.tsx +21 -6
  48. package/src/lib/theme/devtools/LiveEditor.tsx +393 -0
  49. package/src/lib/theme/devtools/README.md +433 -0
  50. package/src/lib/theme/devtools/index.ts +12 -11
  51. package/src/lib/theme/generateCSSVariables.ts +79 -38
  52. package/src/lib/theme/index.ts +45 -246
  53. package/src/lib/theme/runtime/ThemeApplicator.ts +252 -0
  54. package/src/lib/theme/runtime/ThemeManager.test.ts +17 -1
  55. package/src/lib/theme/runtime/ThemeManager.ts +7 -7
  56. package/src/lib/theme/themeUtils.ts +27 -5
  57. package/src/lib/theme/types.ts +59 -1
  58. package/src/lib/theme-tools.ts +125 -0
  59. package/src/lib/types/components.ts +260 -72
  60. package/src/lib/types/partProps.ts +426 -0
  61. package/src/lib/utils/__tests__/componentUtils.test.ts +144 -0
  62. package/src/lib/utils/componentUtils.ts +163 -0
  63. package/src/lib/utils/index.ts +17 -57
  64. package/src/styles/01-settings/_settings.colors.scss +10 -10
  65. package/src/styles/01-settings/_settings.navbar.scss +1 -1
  66. package/src/styles/01-settings/_settings.tooltip.scss +1 -1
  67. package/src/styles/03-generic/_generated-root.css +5 -0
  68. package/src/styles/06-components/_components.navbar.scss +12 -5
  69. package/src/styles/06-components/_components.tooltip.scss +31 -81
  70. package/src/themes/README.md +442 -0
  71. package/src/themes/themes.config.js +35 -0
  72. package/src/lib/theme/errors.test.ts +0 -207
  73. package/src/lib/theme/generators/CSSGenerator.ts +0 -311
  74. package/src/lib/theme/generators/ConfigGenerator.ts +0 -287
  75. package/src/lib/theme/generators/TypeGenerator.ts +0 -228
  76. package/src/lib/theme/generators/index.ts +0 -21
  77. package/src/lib/theme/monitoring/ThemeAnalytics.ts +0 -409
  78. package/src/lib/theme/monitoring/index.ts +0 -17
  79. package/src/lib/theme/overrides/ComponentOverrides.ts +0 -243
  80. package/src/lib/theme/overrides/index.ts +0 -15
  81. package/src/lib/theme/studio/ThemeStudio.tsx +0 -312
  82. package/src/lib/theme/studio/index.ts +0 -8
  83. package/src/lib/theme/whitelabel/WhiteLabelManager.ts +0 -364
  84. package/src/lib/theme/whitelabel/index.ts +0 -13
@@ -0,0 +1,433 @@
1
+ # Theme DevTools
2
+
3
+ Developer tools for theme management, debugging, and visualization in the Atomix Design System.
4
+
5
+ ## Overview
6
+
7
+ The Theme DevTools provide a comprehensive suite of tools for working with themes during development:
8
+
9
+ - **CLI Tools** - Command-line interface for theme operations
10
+ - **Inspector** - Detailed theme inspection and validation
11
+ - **Preview** - Live theme preview with sample components
12
+ - **Comparator** - Side-by-side theme comparison
13
+ - **Live Editor** - Real-time theme editing with instant preview
14
+
15
+ ---
16
+
17
+ ## CLI Tools
18
+
19
+ ### Installation
20
+
21
+ ```bash
22
+ npm install @shohojdhara/atomix
23
+ ```
24
+
25
+ ### Usage
26
+
27
+ ```bash
28
+ # Validate theme configuration
29
+ atomix-theme validate
30
+
31
+ # List all available themes
32
+ atomix-theme list
33
+
34
+ # Inspect a specific theme
35
+ atomix-theme inspect --theme my-theme
36
+
37
+ # Compare two themes
38
+ atomix-theme compare --theme1 light --theme2 dark
39
+
40
+ # Export theme to JSON
41
+ atomix-theme export --theme my-theme --output theme.json
42
+
43
+ # Show help
44
+ atomix-theme help
45
+ ```
46
+
47
+ ### Available Commands
48
+
49
+ | Command | Description | Options |
50
+ |---------|-------------|---------|
51
+ | `validate` | Validate theme configuration | `--config`, `--strict` |
52
+ | `list` | List all available themes | - |
53
+ | `inspect` | Inspect a specific theme | `--theme`, `--json` |
54
+ | `compare` | Compare two themes | `--theme1`, `--theme2` |
55
+ | `export` | Export theme to JSON | `--theme`, `--output` |
56
+ | `help` | Show help information | - |
57
+
58
+ ---
59
+
60
+ ## React Components
61
+
62
+ ### ThemeInspector
63
+
64
+ Detailed inspection and debugging information for themes.
65
+
66
+ ```tsx
67
+ import { ThemeInspector } from '@shohojdhara/atomix/theme/devtools';
68
+ import { createTheme } from '@shohojdhara/atomix/theme';
69
+
70
+ const theme = createTheme({ palette: { primary: { main: '#7AFFD7' } } });
71
+
72
+ function App() {
73
+ return (
74
+ <ThemeInspector
75
+ theme={theme}
76
+ showValidation={true}
77
+ showCSSVariables={true}
78
+ showStructure={true}
79
+ />
80
+ );
81
+ }
82
+ ```
83
+
84
+ **Features:**
85
+ - Theme metadata and statistics
86
+ - Validation with error/warning reporting
87
+ - Accessibility issue detection
88
+ - CSS variable generation
89
+ - Theme structure visualization
90
+
91
+ **Props:**
92
+ - `theme` (required) - Theme to inspect
93
+ - `showValidation` (boolean) - Show validation results
94
+ - `showCSSVariables` (boolean) - Show generated CSS variables
95
+ - `showStructure` (boolean) - Show theme structure tree
96
+ - `className` (string) - Custom CSS class
97
+ - `style` (object) - Inline styles
98
+
99
+ ### ThemePreview
100
+
101
+ Live preview of themes with sample components.
102
+
103
+ ```tsx
104
+ import { ThemePreview } from '@shohojdhara/atomix/theme/devtools';
105
+
106
+ function App() {
107
+ return (
108
+ <ThemePreview
109
+ theme={theme}
110
+ showDetails={true}
111
+ showPalette={true}
112
+ showTypography={true}
113
+ showSpacing={false}
114
+ >
115
+ {/* Custom components to preview */}
116
+ <MyCustomComponent />
117
+ </ThemePreview>
118
+ );
119
+ }
120
+ ```
121
+
122
+ **Features:**
123
+ - Theme details display
124
+ - Color palette visualization
125
+ - Typography samples
126
+ - Spacing scale visualization
127
+ - Sample component rendering
128
+ - Custom component preview
129
+
130
+ **Props:**
131
+ - `theme` (required) - Theme to preview
132
+ - `showDetails` (boolean) - Show theme metadata
133
+ - `showPalette` (boolean) - Show color palette
134
+ - `showTypography` (boolean) - Show typography samples
135
+ - `showSpacing` (boolean) - Show spacing scale
136
+ - `children` (ReactNode) - Custom components to render
137
+ - `className` (string) - Custom CSS class
138
+ - `style` (object) - Inline styles
139
+
140
+ ### ThemeComparator
141
+
142
+ Side-by-side comparison of two themes.
143
+
144
+ ```tsx
145
+ import { ThemeComparator } from '@shohojdhara/atomix/theme/devtools';
146
+
147
+ function App() {
148
+ return (
149
+ <ThemeComparator
150
+ themeA={lightTheme}
151
+ themeB={darkTheme}
152
+ showOnlyDifferences={false}
153
+ />
154
+ );
155
+ }
156
+ ```
157
+
158
+ **Features:**
159
+ - Side-by-side theme comparison
160
+ - Difference highlighting (added/removed/changed)
161
+ - Statistics dashboard
162
+ - Detailed value comparison
163
+ - Path-based difference tracking
164
+
165
+ **Props:**
166
+ - `themeA` (required) - First theme to compare
167
+ - `themeB` (required) - Second theme to compare
168
+ - `showOnlyDifferences` (boolean) - Show only differences
169
+ - `className` (string) - Custom CSS class
170
+ - `style` (object) - Inline styles
171
+
172
+ ### ThemeLiveEditor
173
+
174
+ Real-time theme editing with instant preview.
175
+
176
+ ```tsx
177
+ import { ThemeLiveEditor } from '@shohojdhara/atomix/theme/devtools';
178
+
179
+ function App() {
180
+ const handleThemeChange = (newTheme) => {
181
+ console.log('Theme updated:', newTheme);
182
+ };
183
+
184
+ return (
185
+ <ThemeLiveEditor
186
+ initialTheme={theme}
187
+ onChange={handleThemeChange}
188
+ />
189
+ );
190
+ }
191
+ ```
192
+
193
+ **Features:**
194
+ - Visual editor for common properties
195
+ - JSON editor for advanced editing
196
+ - Live preview with instant updates
197
+ - Export theme to JSON file
198
+ - Copy theme JSON to clipboard
199
+ - Syntax validation
200
+
201
+ **Props:**
202
+ - `initialTheme` (required) - Initial theme to edit
203
+ - `onChange` (function) - Callback when theme changes
204
+ - `className` (string) - Custom CSS class
205
+ - `style` (object) - Inline styles
206
+
207
+ ---
208
+
209
+ ## Usage Examples
210
+
211
+ ### Development Workflow
212
+
213
+ ```tsx
214
+ import {
215
+ ThemeInspector,
216
+ ThemePreview,
217
+ ThemeComparator,
218
+ ThemeLiveEditor
219
+ } from '@shohojdhara/atomix/theme/devtools';
220
+ import { createTheme } from '@shohojdhara/atomix/theme';
221
+
222
+ // Create themes
223
+ const lightTheme = createTheme({
224
+ name: 'Light Theme',
225
+ palette: {
226
+ primary: { main: '#2196f3' },
227
+ background: { default: '#ffffff' },
228
+ },
229
+ });
230
+
231
+ const darkTheme = createTheme({
232
+ name: 'Dark Theme',
233
+ palette: {
234
+ primary: { main: '#90caf9' },
235
+ background: { default: '#121212' },
236
+ },
237
+ });
238
+
239
+ // Development dashboard
240
+ function ThemeDashboard() {
241
+ const [currentTheme, setCurrentTheme] = useState(lightTheme);
242
+
243
+ return (
244
+ <div>
245
+ {/* Inspect current theme */}
246
+ <ThemeInspector theme={currentTheme} />
247
+
248
+ {/* Preview theme */}
249
+ <ThemePreview theme={currentTheme} />
250
+
251
+ {/* Compare themes */}
252
+ <ThemeComparator themeA={lightTheme} themeB={darkTheme} />
253
+
254
+ {/* Edit theme live */}
255
+ <ThemeLiveEditor
256
+ initialTheme={currentTheme}
257
+ onChange={setCurrentTheme}
258
+ />
259
+ </div>
260
+ );
261
+ }
262
+ ```
263
+
264
+ ### Storybook Integration
265
+
266
+ ```tsx
267
+ // .storybook/preview.tsx
268
+ import { ThemePreview } from '@shohojdhara/atomix/theme/devtools';
269
+
270
+ export const decorators = [
271
+ (Story, context) => {
272
+ const theme = context.globals.theme;
273
+
274
+ return (
275
+ <ThemePreview theme={theme}>
276
+ <Story />
277
+ </ThemePreview>
278
+ );
279
+ },
280
+ ];
281
+ ```
282
+
283
+ ### Testing Themes
284
+
285
+ ```tsx
286
+ import { ThemeInspector } from '@shohojdhara/atomix/theme/devtools';
287
+
288
+ describe('Theme Validation', () => {
289
+ it('should validate theme structure', () => {
290
+ const theme = createTheme({
291
+ palette: { primary: { main: '#7AFFD7' } },
292
+ });
293
+
294
+ // Use inspector programmatically
295
+ const validator = new ThemeValidator();
296
+ const result = validator.validate(theme);
297
+
298
+ expect(result.valid).toBe(true);
299
+ expect(result.errors).toHaveLength(0);
300
+ });
301
+ });
302
+ ```
303
+
304
+ ---
305
+
306
+ ## Best Practices
307
+
308
+ ### 1. Use Inspector During Development
309
+
310
+ Always inspect themes during development to catch issues early:
311
+
312
+ ```tsx
313
+ <ThemeInspector
314
+ theme={myTheme}
315
+ showValidation={true}
316
+ showCSSVariables={true}
317
+ />
318
+ ```
319
+
320
+ ### 2. Compare Before Releasing
321
+
322
+ Compare theme versions before releasing updates:
323
+
324
+ ```tsx
325
+ <ThemeComparator
326
+ themeA={currentVersion}
327
+ themeB={newVersion}
328
+ />
329
+ ```
330
+
331
+ ### 3. Preview with Real Components
332
+
333
+ Test themes with actual components:
334
+
335
+ ```tsx
336
+ <ThemePreview theme={myTheme}>
337
+ <Button>Test Button</Button>
338
+ <Card>Test Card</Card>
339
+ </ThemePreview>
340
+ ```
341
+
342
+ ### 4. Validate Accessibility
343
+
344
+ Always check accessibility issues:
345
+
346
+ ```tsx
347
+ // Inspector automatically checks contrast ratios
348
+ // and reports accessibility issues
349
+ <ThemeInspector theme={myTheme} showValidation={true} />
350
+ ```
351
+
352
+ ### 5. Export for Sharing
353
+
354
+ Export themes for team collaboration:
355
+
356
+ ```bash
357
+ atomix-theme export --theme my-theme --output shared-theme.json
358
+ ```
359
+
360
+ ---
361
+
362
+ ## Performance Considerations
363
+
364
+ - **Inspector**: Validation runs once on mount, memoized for performance
365
+ - **Preview**: CSS variables generated once, cached
366
+ - **Comparator**: Differences calculated once, memoized
367
+ - **Live Editor**: Debounced updates for smooth editing
368
+
369
+ ---
370
+
371
+ ## Browser Support
372
+
373
+ All devtools components support:
374
+ - Chrome/Edge 90+
375
+ - Firefox 88+
376
+ - Safari 14+
377
+ - Modern mobile browsers
378
+
379
+ ---
380
+
381
+ ## Troubleshooting
382
+
383
+ ### Inspector Not Showing Validation
384
+
385
+ Ensure `ThemeValidator` is available:
386
+
387
+ ```tsx
388
+ import { ThemeValidator } from '@shohojdhara/atomix/theme';
389
+ ```
390
+
391
+ ### Preview Not Rendering
392
+
393
+ Check that theme has required properties:
394
+
395
+ ```tsx
396
+ const theme = createTheme({
397
+ palette: { primary: { main: '#7AFFD7' } }, // Required
398
+ typography: { fontFamily: 'Inter' }, // Required
399
+ });
400
+ ```
401
+
402
+ ### CLI Commands Not Working
403
+
404
+ Ensure theme configuration exists:
405
+
406
+ ```bash
407
+ # Check if atomix.config.ts exists in project root
408
+ ls atomix.config.ts
409
+ ```
410
+
411
+ ---
412
+
413
+ ## Contributing
414
+
415
+ To add new devtools:
416
+
417
+ 1. Create component in `src/lib/theme/devtools/`
418
+ 2. Export from `index.ts`
419
+ 3. Add documentation to this README
420
+ 4. Add tests if applicable
421
+
422
+ ---
423
+
424
+ ## Related Documentation
425
+
426
+ - [Theme System Guide](../../../../docs/THEME_SYSTEM.md)
427
+ - [Getting Started - Theme System](../../../../docs/getting-started/theme-system.md)
428
+ - [Theme System Guide](../../../../docs/THEME_SYSTEM.md)
429
+
430
+ ---
431
+
432
+ **Last Updated:** 2025-01-27
433
+
@@ -1,21 +1,22 @@
1
1
  /**
2
2
  * Theme DevTools Module
3
3
  *
4
- * Developer tools for theme management
4
+ * Developer tools for theme management and debugging
5
5
  */
6
6
 
7
+ // CLI Tools
7
8
  export { ThemeCLI, createCLI, runCLI } from './CLI';
9
+ export type { CLICommand } from './CLI';
10
+
11
+ // React Components
8
12
  export { ThemePreview } from './Preview';
9
- export { ThemeInspector } from './Inspector';
13
+ export type { ThemePreviewProps } from './Preview';
10
14
 
11
- export type {
12
- CLICommand,
13
- } from './CLI';
15
+ export { ThemeInspector } from './Inspector';
16
+ export type { ThemeInspectorProps } from './Inspector';
14
17
 
15
- export type {
16
- ThemePreviewProps,
17
- } from './Preview';
18
+ export { ThemeComparator } from './Comparator';
19
+ export type { ThemeComparatorProps } from './Comparator';
18
20
 
19
- export type {
20
- ThemeInspectorProps,
21
- } from './Inspector';
21
+ export { ThemeLiveEditor } from './LiveEditor';
22
+ export type { ThemeLiveEditorProps } from './LiveEditor';