@shohojdhara/atomix 0.3.12 → 0.3.14
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/CHANGELOG.md +19 -0
- package/README.md +2 -0
- package/dist/atomix.css +101 -88
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +5 -15258
- package/dist/atomix.min.css.map +1 -1
- package/dist/charts.d.ts +1 -1
- package/dist/charts.js +17 -19
- package/dist/charts.js.map +1 -1
- package/dist/core.d.ts +41 -11
- package/dist/core.js +55 -41
- package/dist/core.js.map +1 -1
- package/dist/forms.d.ts +28 -11
- package/dist/forms.js +25 -24
- package/dist/forms.js.map +1 -1
- package/dist/heavy.d.ts +1 -1
- package/dist/heavy.js +32 -25
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +122 -46
- package/dist/index.esm.js +865 -200
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +870 -204
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/theme.d.ts +27 -2
- package/dist/theme.js +721 -108
- package/dist/theme.js.map +1 -1
- package/package.json +1 -1
- package/scripts/atomix-cli.js +610 -1111
- package/scripts/cli/component-generator.js +610 -0
- package/scripts/cli/documentation-sync.js +542 -0
- package/scripts/cli/interactive-init.js +84 -288
- package/scripts/cli/mappings.js +211 -0
- package/scripts/cli/migration-tools.js +95 -288
- package/scripts/cli/template-manager.js +107 -0
- package/scripts/cli/templates/README.md +123 -0
- package/scripts/cli/templates/composable-templates.js +149 -0
- package/scripts/cli/templates/config-templates.js +126 -0
- package/scripts/cli/templates/index.js +95 -0
- package/scripts/cli/templates/project-templates.js +214 -0
- package/scripts/cli/templates/react-templates.js +261 -0
- package/scripts/cli/templates/scss-templates.js +156 -0
- package/scripts/cli/templates/storybook-templates.js +236 -0
- package/scripts/cli/templates/testing-templates.js +45 -0
- package/scripts/cli/templates/token-templates.js +447 -0
- package/scripts/cli/templates/types-templates.js +133 -0
- package/scripts/cli/templates-original-backup.js +1655 -0
- package/scripts/cli/templates.js +35 -0
- package/scripts/cli/templates_backup.js +684 -0
- package/scripts/cli/theme-bridge.js +20 -14
- package/scripts/cli/token-manager.js +150 -77
- package/scripts/cli/utils.js +37 -25
- package/src/components/Accordion/Accordion.stories.tsx +5 -5
- package/src/components/Accordion/Accordion.test.tsx +57 -0
- package/src/components/Accordion/Accordion.tsx +4 -0
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +41 -44
- package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +1 -1
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +37 -37
- package/src/components/AtomixGlass/stories/Modes.stories.tsx +1 -2
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +50 -51
- package/src/components/Avatar/Avatar.stories.tsx +26 -26
- package/src/components/Badge/Badge.stories.tsx +31 -31
- package/src/components/Badge/Badge.test.tsx +51 -0
- package/src/components/Badge/Badge.tsx +20 -1
- package/src/components/Block/Block.stories.tsx +5 -5
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +1 -1
- package/src/components/Breadcrumb/Breadcrumb.tsx +2 -2
- package/src/components/Button/Button.stories.tsx +13 -13
- package/src/components/Button/Button.tsx +4 -4
- package/src/components/Button/ButtonGroup.stories.tsx +2 -2
- package/src/components/Button/README.md +5 -0
- package/src/components/Callout/Callout.stories.tsx +11 -11
- package/src/components/Callout/Callout.test.tsx +10 -10
- package/src/components/Callout/Callout.tsx +7 -7
- package/src/components/Callout/README.md +9 -8
- package/src/components/Card/Card.tsx +2 -2
- package/src/components/Chart/Chart.stories.tsx +6 -6
- package/src/components/Chart/Chart.tsx +1 -1
- package/src/components/ColorModeToggle/ColorModeToggle.stories.tsx +1 -1
- package/src/components/DataTable/DataTable.tsx +14 -12
- package/src/components/DatePicker/DatePicker.stories.tsx +6 -6
- package/src/components/Dropdown/Dropdown.stories.tsx +4 -4
- package/src/components/Form/Checkbox.stories.tsx +3 -3
- package/src/components/Form/Checkbox.tsx +4 -2
- package/src/components/Form/Form.stories.tsx +3 -3
- package/src/components/Form/FormGroup.stories.tsx +1 -1
- package/src/components/Form/Input.stories.tsx +28 -16
- package/src/components/Form/Input.test.tsx +59 -0
- package/src/components/Form/Input.tsx +97 -95
- package/src/components/Form/Radio.stories.tsx +94 -94
- package/src/components/Form/Radio.tsx +2 -2
- package/src/components/Form/Select.stories.tsx +4 -4
- package/src/components/Form/Select.tsx +2 -2
- package/src/components/Form/Textarea.stories.tsx +22 -7
- package/src/components/Form/Textarea.test.tsx +45 -0
- package/src/components/Form/Textarea.tsx +88 -86
- package/src/components/List/List.stories.tsx +2 -2
- package/src/components/Modal/Modal.stories.tsx +4 -4
- package/src/components/Navigation/Navbar/Navbar.stories.tsx +5 -5
- package/src/components/Navigation/Navbar/Navbar.tsx +1 -1
- package/src/components/Navigation/README.md +1 -1
- package/src/components/Pagination/Pagination.stories.tsx +5 -2
- package/src/components/Pagination/Pagination.tsx +1 -1
- package/src/components/PhotoViewer/PhotoViewer.stories.tsx +10 -10
- package/src/components/Popover/Popover.stories.tsx +1 -1
- package/src/components/ProductReview/ProductReview.tsx +1 -1
- package/src/components/Progress/Progress.tsx +46 -46
- package/src/components/Rating/Rating.stories.tsx +4 -4
- package/src/components/Rating/Rating.tsx +8 -8
- package/src/components/Slider/Slider.stories.tsx +63 -63
- package/src/components/Spinner/Spinner.stories.tsx +2 -2
- package/src/components/Spinner/Spinner.test.tsx +35 -0
- package/src/components/Spinner/Spinner.tsx +9 -2
- package/src/components/Testimonial/Testimonial.stories.tsx +1 -1
- package/src/components/Toggle/Toggle.stories.tsx +32 -9
- package/src/components/Toggle/Toggle.test.tsx +91 -0
- package/src/components/Toggle/Toggle.tsx +44 -27
- package/src/components/Tooltip/Tooltip.tsx +1 -1
- package/src/layouts/Grid/Grid.stories.tsx +49 -49
- package/src/layouts/MasonryGrid/MasonryGrid.stories.tsx +2 -2
- package/src/lib/composables/useAccordion.ts +12 -3
- package/src/lib/composables/useBreadcrumb.ts +2 -2
- package/src/lib/composables/useCallout.ts +7 -7
- package/src/lib/composables/useNavbar.ts +1 -1
- package/src/lib/constants/components.ts +1 -1
- package/src/lib/storybook/InteractiveDemo.tsx +113 -0
- package/src/lib/storybook/PreviewContainer.tsx +36 -0
- package/src/lib/storybook/VariantsGrid.tsx +21 -0
- package/src/lib/storybook/index.ts +3 -0
- package/src/lib/theme/core/createThemeObject.ts +9 -5
- package/src/lib/theme/devtools/CLI.ts +155 -0
- package/src/lib/theme/devtools/DesignTokensCustomizer.stories.tsx +213 -0
- package/src/lib/theme/devtools/DesignTokensCustomizer.tsx +566 -0
- package/src/lib/theme/devtools/LiveEditor.tsx +2 -1
- package/src/lib/theme/devtools/index.ts +3 -0
- package/src/lib/theme/errors/errors.ts +8 -0
- package/src/lib/theme/runtime/ThemeProvider.tsx +117 -57
- package/src/lib/theme/runtime/__tests__/ThemeProvider.integration.test.tsx +305 -0
- package/src/lib/theme/runtime/__tests__/ThemeProvider.test.tsx +588 -0
- package/src/lib/theme/utils/__tests__/themeValidation.test.ts +264 -0
- package/src/lib/theme/utils/index.ts +1 -0
- package/src/lib/theme/utils/themeValidation.ts +501 -0
- package/src/lib/theme-tools.ts +32 -3
- package/src/lib/types/components.ts +81 -26
- package/src/lib/utils/themeNaming.ts +1 -1
- package/src/styles/06-components/_components.atomix-glass.scss +14 -15
- package/src/styles/06-components/_components.callout.scss +29 -33
- package/src/styles/06-components/_index.scss +1 -1
- package/src/styles/99-utilities/_utilities.display.scss +14 -3
- package/src/styles/99-utilities/_utilities.flex.scss +10 -10
- package/src/styles/99-utilities/_utilities.text.scss +28 -8
- package/scripts/cli/__tests__/cli-commands.test.js +0 -204
- package/scripts/cli/__tests__/utils.test.js +0 -201
- package/scripts/cli/__tests__/vitest.config.js +0 -26
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Template Manager CLI
|
|
5
|
+
* Helper utility for managing Atomix CLI templates
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import templates from './templates/index.js';
|
|
9
|
+
import { readFileSync, writeFileSync } from 'fs';
|
|
10
|
+
import { resolve } from 'path';
|
|
11
|
+
|
|
12
|
+
const commands = {
|
|
13
|
+
list: () => {
|
|
14
|
+
console.log('\n📦 Available Templates:\n');
|
|
15
|
+
|
|
16
|
+
console.log('React Component Templates:');
|
|
17
|
+
Object.keys(templates.componentTemplates.react).forEach(name => {
|
|
18
|
+
console.log(` • ${name}`);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
console.log('\nComposable Templates:');
|
|
22
|
+
Object.keys(templates.componentTemplates.composable).forEach(name => {
|
|
23
|
+
console.log(` • ${name}`);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
console.log('\nToken Generators:');
|
|
27
|
+
Object.keys(templates).filter(k => k.startsWith('generate')).forEach(name => {
|
|
28
|
+
console.log(` • ${name}`);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
console.log('\nProject Templates:');
|
|
32
|
+
Object.keys(templates.projectTemplates).forEach(name => {
|
|
33
|
+
console.log(` • ${name}`);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
console.log('\nConfig Templates:');
|
|
37
|
+
Object.keys(templates.configTemplates).forEach(name => {
|
|
38
|
+
console.log(` • ${name}`);
|
|
39
|
+
});
|
|
40
|
+
console.log();
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
validate: () => {
|
|
44
|
+
console.log('\n🔍 Validating Templates...\n');
|
|
45
|
+
|
|
46
|
+
let errors = 0;
|
|
47
|
+
|
|
48
|
+
// Test React templates
|
|
49
|
+
try {
|
|
50
|
+
const testReact = templates.componentTemplates.react.simple('TestComponent');
|
|
51
|
+
if (!testReact.includes('export const TestComponent')) {
|
|
52
|
+
console.log('❌ React simple template failed');
|
|
53
|
+
errors++;
|
|
54
|
+
} else {
|
|
55
|
+
console.log('✅ React simple template passed');
|
|
56
|
+
}
|
|
57
|
+
} catch (err) {
|
|
58
|
+
console.log('❌ React simple template error:', err.message);
|
|
59
|
+
errors++;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Test token generators
|
|
63
|
+
try {
|
|
64
|
+
const colorTokens = templates.generateColorTokens();
|
|
65
|
+
if (!colorTokens.includes('$custom-primary-6')) {
|
|
66
|
+
console.log('❌ Color tokens template failed');
|
|
67
|
+
errors++;
|
|
68
|
+
} else {
|
|
69
|
+
console.log('✅ Color tokens template passed');
|
|
70
|
+
}
|
|
71
|
+
} catch (err) {
|
|
72
|
+
console.log('❌ Color tokens template error:', err.message);
|
|
73
|
+
errors++;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
console.log(`\n${errors === 0 ? '✅' : '❌'} Template validation complete (${errors} errors)\n`);
|
|
77
|
+
|
|
78
|
+
return errors === 0;
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
help: () => {
|
|
82
|
+
console.log(`
|
|
83
|
+
🛠️ Template Manager - Atomix CLI
|
|
84
|
+
|
|
85
|
+
Usage:
|
|
86
|
+
node template-manager.js <command>
|
|
87
|
+
|
|
88
|
+
Commands:
|
|
89
|
+
list List all available templates
|
|
90
|
+
validate Validate all templates for syntax errors
|
|
91
|
+
help Show this help message
|
|
92
|
+
|
|
93
|
+
Examples:
|
|
94
|
+
node template-manager.js list
|
|
95
|
+
node template-manager.js validate
|
|
96
|
+
`);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const command = process.argv[2];
|
|
101
|
+
|
|
102
|
+
if (commands[command]) {
|
|
103
|
+
commands[command]();
|
|
104
|
+
} else {
|
|
105
|
+
console.log('Unknown command. Use "help" for available commands.');
|
|
106
|
+
commands.help();
|
|
107
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Templates Directory
|
|
2
|
+
|
|
3
|
+
This directory contains modular templates for the Atomix CLI. The templates have been split into separate files for better maintainability and organization.
|
|
4
|
+
|
|
5
|
+
## File Structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
templates/
|
|
9
|
+
├── README.md # This documentation file
|
|
10
|
+
├── index.js # Main export file that aggregates all templates
|
|
11
|
+
├── react-templates.js # React component templates (simple, medium, complex)
|
|
12
|
+
├── storybook-templates.js # Storybook story templates
|
|
13
|
+
├── testing-templates.js # Vitest testing templates
|
|
14
|
+
├── scss-templates.js # SCSS styling templates
|
|
15
|
+
├── types-templates.js # TypeScript definition templates
|
|
16
|
+
├── composable-templates.js # Custom hook templates
|
|
17
|
+
├── token-templates.js # Design system token generation functions
|
|
18
|
+
├── project-templates.js # Project scaffolding templates
|
|
19
|
+
└── config-templates.js # Configuration file templates
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Template Categories
|
|
23
|
+
|
|
24
|
+
### React Templates (`react-templates.js`)
|
|
25
|
+
- **simple**: Basic presentational components with minimal state
|
|
26
|
+
- **medium**: Components with state management and interactions
|
|
27
|
+
- **complex**: Advanced components with validation and accessibility
|
|
28
|
+
- **component**: Default template (backward compatibility)
|
|
29
|
+
|
|
30
|
+
### Storybook Templates (`storybook-templates.js`)
|
|
31
|
+
- **story**: Basic Storybook story with essential controls
|
|
32
|
+
- **storyEnhanced**: Enhanced story with detailed documentation and examples
|
|
33
|
+
|
|
34
|
+
### Testing Templates (`testing-templates.js`)
|
|
35
|
+
- **test**: Vitest test template for React components
|
|
36
|
+
|
|
37
|
+
### SCSS Templates (`scss-templates.js`)
|
|
38
|
+
- **scss**: Main SCSS component styles with CSS custom properties
|
|
39
|
+
- **scssSettings**: SCSS settings file with component-specific variables
|
|
40
|
+
- **scssModule**: Empty (CSS modules are not used by default)
|
|
41
|
+
|
|
42
|
+
### TypeScript Templates (`types-templates.js`)
|
|
43
|
+
- **types**: TypeScript interface definitions for component props
|
|
44
|
+
- **constants**: Component constants and selectors
|
|
45
|
+
- **index**: Index file for component exports
|
|
46
|
+
|
|
47
|
+
### Composable Templates (`composable-templates.js`)
|
|
48
|
+
- **hook**: Custom React hook template with state management and accessibility
|
|
49
|
+
|
|
50
|
+
### Token Templates (`token-templates.js`)
|
|
51
|
+
Design system token generation functions:
|
|
52
|
+
- **generateColorTokens**: Color palette tokens
|
|
53
|
+
- **generateSpacingTokens**: Spacing scale tokens
|
|
54
|
+
- **generateTypographyTokens**: Typography scale tokens
|
|
55
|
+
- **generateShadowTokens**: Box shadow tokens
|
|
56
|
+
- **generateRadiusTokens**: Border radius tokens
|
|
57
|
+
- **generateAnimationTokens**: Animation and transition tokens
|
|
58
|
+
|
|
59
|
+
### Project Templates (`project-templates.js`)
|
|
60
|
+
- **react**: React + Vite project setup
|
|
61
|
+
- **nextjs**: Next.js project setup
|
|
62
|
+
- **vanilla**: Vanilla TypeScript project setup
|
|
63
|
+
|
|
64
|
+
### Config Templates (`config-templates.js`)
|
|
65
|
+
- **basic**: Simple JSON configuration
|
|
66
|
+
- **advanced**: Advanced JavaScript configuration with all options
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
Templates are imported through the main `index.js` file, which maintains backward compatibility with the original `templates.js` structure.
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
import templates from './templates/index.js';
|
|
74
|
+
|
|
75
|
+
// Access React templates
|
|
76
|
+
const simpleTemplate = templates.componentTemplates.react.simple('MyComponent');
|
|
77
|
+
|
|
78
|
+
// Access token generators
|
|
79
|
+
const colorTokens = templates.generateColorTokens();
|
|
80
|
+
|
|
81
|
+
// Access project templates
|
|
82
|
+
const reactProject = templates.projectTemplates.react;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Migration from Single File
|
|
86
|
+
|
|
87
|
+
The original `templates.js` file has been split for better maintainability:
|
|
88
|
+
|
|
89
|
+
1. **Backup**: Original file saved as `templates-original-backup.js`
|
|
90
|
+
2. **New structure**: Templates organized by category in separate files
|
|
91
|
+
3. **Compatibility**: All existing imports continue to work through `index.js`
|
|
92
|
+
4. **Benefits**:
|
|
93
|
+
- Easier to locate and edit specific templates
|
|
94
|
+
- Reduced file size for better editor performance
|
|
95
|
+
- Clear separation of concerns
|
|
96
|
+
- Better testability of individual template modules
|
|
97
|
+
|
|
98
|
+
## Adding New Templates
|
|
99
|
+
|
|
100
|
+
1. Choose the appropriate category file or create a new one
|
|
101
|
+
2. Add your template function following the existing pattern
|
|
102
|
+
3. Export it in the category's export object
|
|
103
|
+
4. Update `index.js` if you created a new category
|
|
104
|
+
|
|
105
|
+
Example of adding a new React template:
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
// In react-templates.js
|
|
109
|
+
export const customTemplate = (name) => `// Your custom template code`;
|
|
110
|
+
|
|
111
|
+
// Update the export object
|
|
112
|
+
export const reactTemplates = {
|
|
113
|
+
simple: simpleTemplate,
|
|
114
|
+
medium: mediumTemplate,
|
|
115
|
+
complex: complexTemplate,
|
|
116
|
+
component: defaultTemplate,
|
|
117
|
+
custom: customTemplate, // New template
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Backward Compatibility
|
|
122
|
+
|
|
123
|
+
The modular structure maintains 100% backward compatibility. All existing imports and usage patterns continue to work exactly as before. The main `templates.js` file now imports from the modular structure, ensuring no breaking changes.
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composable Templates
|
|
3
|
+
* Templates for custom hooks and composables
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Custom hook template for React components
|
|
8
|
+
*/
|
|
9
|
+
export const hookTemplate = (name) => `import { useState, useCallback, useRef, useEffect } from 'react';
|
|
10
|
+
import type { ${name}Props } from '../../lib/types/components';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Custom hook for ${name.toLowerCase()} component
|
|
14
|
+
* Provides controlled/uncontrolled state management and accessibility
|
|
15
|
+
*/
|
|
16
|
+
export function use${name}(initialProps?: Partial<${name}Props>) {
|
|
17
|
+
const {
|
|
18
|
+
isOpen: controlledIsOpen,
|
|
19
|
+
defaultIsOpen = false,
|
|
20
|
+
onToggle,
|
|
21
|
+
...props
|
|
22
|
+
} = initialProps || {};
|
|
23
|
+
|
|
24
|
+
// State management for controlled/uncontrolled pattern
|
|
25
|
+
const [internalIsOpen, setInternalIsOpen] = useState(defaultIsOpen);
|
|
26
|
+
const isControlled = typeof controlledIsOpen === 'boolean';
|
|
27
|
+
const isOpen = isControlled ? controlledIsOpen : internalIsOpen;
|
|
28
|
+
|
|
29
|
+
// Refs for DOM elements
|
|
30
|
+
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
31
|
+
const panelRef = useRef<HTMLDivElement>(null);
|
|
32
|
+
|
|
33
|
+
// Toggle function with controlled support
|
|
34
|
+
const toggle = useCallback(() => {
|
|
35
|
+
if (isControlled) {
|
|
36
|
+
onToggle?.(!isOpen);
|
|
37
|
+
} else {
|
|
38
|
+
setInternalIsOpen(!isOpen);
|
|
39
|
+
onToggle?.(!isOpen);
|
|
40
|
+
}
|
|
41
|
+
}, [isOpen, isControlled, onToggle]);
|
|
42
|
+
|
|
43
|
+
// Open function
|
|
44
|
+
const open = useCallback(() => {
|
|
45
|
+
if (isControlled) {
|
|
46
|
+
onToggle?.(true);
|
|
47
|
+
} else {
|
|
48
|
+
setInternalIsOpen(true);
|
|
49
|
+
onToggle?.(true);
|
|
50
|
+
}
|
|
51
|
+
}, [isControlled, onToggle]);
|
|
52
|
+
|
|
53
|
+
// Close function
|
|
54
|
+
const close = useCallback(() => {
|
|
55
|
+
if (isControlled) {
|
|
56
|
+
onToggle?.(false);
|
|
57
|
+
} else {
|
|
58
|
+
setInternalIsOpen(false);
|
|
59
|
+
onToggle?.(false);
|
|
60
|
+
}
|
|
61
|
+
}, [isControlled, onToggle]);
|
|
62
|
+
|
|
63
|
+
// Keyboard navigation
|
|
64
|
+
const handleKeyDown = useCallback((event: KeyboardEvent) => {
|
|
65
|
+
switch (event.key) {
|
|
66
|
+
case 'Enter':
|
|
67
|
+
case ' ':
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
toggle();
|
|
70
|
+
break;
|
|
71
|
+
case 'Escape':
|
|
72
|
+
if (isOpen) {
|
|
73
|
+
close();
|
|
74
|
+
triggerRef.current?.focus();
|
|
75
|
+
}
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}, [isOpen, toggle, close]);
|
|
79
|
+
|
|
80
|
+
// Accessibility helpers
|
|
81
|
+
const getTriggerProps = useCallback(() => ({
|
|
82
|
+
ref: triggerRef,
|
|
83
|
+
'aria-expanded': isOpen,
|
|
84
|
+
'aria-controls': panelRef.current?.id,
|
|
85
|
+
onKeyDown: handleKeyDown,
|
|
86
|
+
onClick: toggle,
|
|
87
|
+
}), [isOpen, handleKeyDown, toggle]);
|
|
88
|
+
|
|
89
|
+
const getPanelProps = useCallback(() => ({
|
|
90
|
+
ref: panelRef,
|
|
91
|
+
'aria-hidden': !isOpen,
|
|
92
|
+
role: 'region',
|
|
93
|
+
}), [isOpen]);
|
|
94
|
+
|
|
95
|
+
const getHeaderProps = useCallback(() => ({
|
|
96
|
+
role: 'heading',
|
|
97
|
+
'aria-level': 3,
|
|
98
|
+
}), []);
|
|
99
|
+
|
|
100
|
+
const getContentProps = useCallback(() => ({
|
|
101
|
+
// Content-specific props
|
|
102
|
+
}), []);
|
|
103
|
+
|
|
104
|
+
// State object for external access
|
|
105
|
+
const state = {
|
|
106
|
+
isOpen,
|
|
107
|
+
isControlled,
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// Set controlled state from external updates
|
|
111
|
+
const setIsOpen = useCallback((newIsOpen: boolean) => {
|
|
112
|
+
if (!isControlled) {
|
|
113
|
+
setInternalIsOpen(newIsOpen);
|
|
114
|
+
}
|
|
115
|
+
}, [isControlled]);
|
|
116
|
+
|
|
117
|
+
return {
|
|
118
|
+
// State
|
|
119
|
+
state,
|
|
120
|
+
isOpen,
|
|
121
|
+
isControlled,
|
|
122
|
+
|
|
123
|
+
// Actions
|
|
124
|
+
toggle,
|
|
125
|
+
open,
|
|
126
|
+
close,
|
|
127
|
+
setIsOpen,
|
|
128
|
+
|
|
129
|
+
// Props helpers
|
|
130
|
+
getTriggerProps,
|
|
131
|
+
getPanelProps,
|
|
132
|
+
getHeaderProps,
|
|
133
|
+
getContentProps,
|
|
134
|
+
|
|
135
|
+
// Refs
|
|
136
|
+
triggerRef,
|
|
137
|
+
panelRef,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export default use${name};
|
|
142
|
+
`;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Composable templates object
|
|
146
|
+
*/
|
|
147
|
+
export const composableTemplates = {
|
|
148
|
+
hook: hookTemplate,
|
|
149
|
+
};
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration Templates
|
|
3
|
+
* Templates for different configuration formats
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Basic configuration templates
|
|
8
|
+
*/
|
|
9
|
+
export const basicConfigTemplates = {
|
|
10
|
+
'.atomixrc.json': {
|
|
11
|
+
theme: {
|
|
12
|
+
path: 'themes/custom',
|
|
13
|
+
tokens: {
|
|
14
|
+
colors: {
|
|
15
|
+
primary: '#7AFFD7',
|
|
16
|
+
secondary: '#FF5733'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
components: {
|
|
21
|
+
path: 'src/components',
|
|
22
|
+
generate: {
|
|
23
|
+
typescript: true,
|
|
24
|
+
stories: true,
|
|
25
|
+
tests: false
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
build: {
|
|
29
|
+
outputPath: 'dist',
|
|
30
|
+
includeSourceMaps: false
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Advanced configuration template
|
|
37
|
+
*/
|
|
38
|
+
export const advancedConfigTemplate = `// Atomix Design System Configuration
|
|
39
|
+
// Generated by Atomix CLI
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
theme: {
|
|
43
|
+
path: 'themes/custom',
|
|
44
|
+
tokens: {
|
|
45
|
+
// Import custom token files
|
|
46
|
+
extend: ['./tokens/colors.scss', './tokens/spacing.scss']
|
|
47
|
+
},
|
|
48
|
+
// Theme configuration
|
|
49
|
+
darkMode: 'class', // 'class' | 'media' | false
|
|
50
|
+
cssVarPrefix: 'atomix',
|
|
51
|
+
scope: ':root'
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
components: {
|
|
55
|
+
path: 'src/components',
|
|
56
|
+
// Component generation options
|
|
57
|
+
generate: {
|
|
58
|
+
typescript: true,
|
|
59
|
+
stories: true,
|
|
60
|
+
tests: true,
|
|
61
|
+
cssModules: false,
|
|
62
|
+
// Custom component templates
|
|
63
|
+
templates: {
|
|
64
|
+
component: './templates/component.tsx.hbs',
|
|
65
|
+
story: './templates/story.tsx.hbs',
|
|
66
|
+
test: './templates/test.tsx.hbs'
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
// Component scanning
|
|
70
|
+
scan: {
|
|
71
|
+
patterns: ['src/components/**/*.{ts,tsx}'],
|
|
72
|
+
exclude: ['**/*.test.*', '**/*.stories.*']
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
build: {
|
|
77
|
+
outputPath: 'dist',
|
|
78
|
+
includeSourceMaps: process.env.NODE_ENV === 'development',
|
|
79
|
+
// Build optimization
|
|
80
|
+
optimization: {
|
|
81
|
+
minify: true,
|
|
82
|
+
treeshake: true,
|
|
83
|
+
purgeCSS: {
|
|
84
|
+
enabled: true,
|
|
85
|
+
content: ['src/**/*.{js,ts,tsx,html}']
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
// Development server
|
|
91
|
+
devServer: {
|
|
92
|
+
port: 3000,
|
|
93
|
+
open: true,
|
|
94
|
+
hmr: true
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
// Plugin configuration
|
|
98
|
+
plugins: [
|
|
99
|
+
// '@shohojdhara/atomix-plugin-storybook',
|
|
100
|
+
// '@shohojdhara/atomix-plugin-tailwind'
|
|
101
|
+
],
|
|
102
|
+
|
|
103
|
+
// CLI commands
|
|
104
|
+
cli: {
|
|
105
|
+
generate: {
|
|
106
|
+
component: {
|
|
107
|
+
template: 'react',
|
|
108
|
+
directory: 'src/components'
|
|
109
|
+
},
|
|
110
|
+
theme: {
|
|
111
|
+
template: 'scss',
|
|
112
|
+
directory: 'themes'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};`;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Configuration templates export object
|
|
120
|
+
*/
|
|
121
|
+
export const configTemplates = {
|
|
122
|
+
basic: basicConfigTemplates,
|
|
123
|
+
advanced: {
|
|
124
|
+
'atomix.config.js': advancedConfigTemplate
|
|
125
|
+
}
|
|
126
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Templates Index
|
|
3
|
+
* Aggregates all template modules for the Atomix CLI
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Import template modules
|
|
7
|
+
import { reactTemplates } from './react-templates.js';
|
|
8
|
+
import { storybookTemplates } from './storybook-templates.js';
|
|
9
|
+
import { testingTemplates } from './testing-templates.js';
|
|
10
|
+
import { scssTemplates } from './scss-templates.js';
|
|
11
|
+
import { typesTemplates } from './types-templates.js';
|
|
12
|
+
import { composableTemplates } from './composable-templates.js';
|
|
13
|
+
import * as tokenTemplates from './token-templates.js';
|
|
14
|
+
import { projectTemplates } from './project-templates.js';
|
|
15
|
+
import { configTemplates } from './config-templates.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Main templates object that maintains backward compatibility
|
|
19
|
+
* This structure matches the original templates.js format
|
|
20
|
+
*/
|
|
21
|
+
export const componentTemplates = {
|
|
22
|
+
react: {
|
|
23
|
+
...reactTemplates,
|
|
24
|
+
...storybookTemplates,
|
|
25
|
+
...testingTemplates,
|
|
26
|
+
...scssTemplates,
|
|
27
|
+
...typesTemplates,
|
|
28
|
+
},
|
|
29
|
+
composable: composableTemplates,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Re-export token generation functions
|
|
33
|
+
export {
|
|
34
|
+
generateColorTokens,
|
|
35
|
+
generateSpacingTokens,
|
|
36
|
+
generateTypographyTokens,
|
|
37
|
+
generateShadowTokens,
|
|
38
|
+
generateRadiusTokens,
|
|
39
|
+
generateAnimationTokens,
|
|
40
|
+
} from './token-templates.js';
|
|
41
|
+
|
|
42
|
+
// Re-export project and config templates
|
|
43
|
+
export { projectTemplates, configTemplates };
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Get template by name and type
|
|
47
|
+
* @param {string} type - Template type (react, composable, etc.)
|
|
48
|
+
* @param {string} name - Template name (simple, medium, complex, etc.)
|
|
49
|
+
* @returns {Function|null} Template function or null if not found
|
|
50
|
+
*/
|
|
51
|
+
export function getTemplate(type, name) {
|
|
52
|
+
if (type === 'react') {
|
|
53
|
+
return componentTemplates.react[name] || null;
|
|
54
|
+
} else if (type === 'composable') {
|
|
55
|
+
return componentTemplates.composable[name] || null;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get all available templates for a type
|
|
62
|
+
* @param {string} type - Template type
|
|
63
|
+
* @returns {Object} Object with all available templates
|
|
64
|
+
*/
|
|
65
|
+
export function getTemplatesByType(type) {
|
|
66
|
+
return componentTemplates[type] || {};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* List all available template types
|
|
71
|
+
* @returns {string[]} Array of template type names
|
|
72
|
+
*/
|
|
73
|
+
export function getTemplateTypes() {
|
|
74
|
+
return Object.keys(componentTemplates);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Legacy export for backward compatibility
|
|
79
|
+
* Maintains the same structure as the original templates.js
|
|
80
|
+
*/
|
|
81
|
+
export default {
|
|
82
|
+
componentTemplates,
|
|
83
|
+
generateColorTokens: tokenTemplates.generateColorTokens,
|
|
84
|
+
generateSpacingTokens: tokenTemplates.generateSpacingTokens,
|
|
85
|
+
generateTypographyTokens: tokenTemplates.generateTypographyTokens,
|
|
86
|
+
generateShadowTokens: tokenTemplates.generateShadowTokens,
|
|
87
|
+
generateRadiusTokens: tokenTemplates.generateRadiusTokens,
|
|
88
|
+
generateAnimationTokens: tokenTemplates.generateAnimationTokens,
|
|
89
|
+
projectTemplates,
|
|
90
|
+
configTemplates,
|
|
91
|
+
// Helper functions
|
|
92
|
+
getTemplate,
|
|
93
|
+
getTemplatesByType,
|
|
94
|
+
getTemplateTypes,
|
|
95
|
+
};
|