@shohojdhara/atomix 0.4.7 → 0.4.9
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/atomix.config.ts +58 -1
- package/dist/atomix.css +172 -157
- package/dist/atomix.css.map +1 -1
- package/dist/atomix.min.css +4 -4
- package/dist/atomix.min.css.map +1 -1
- package/dist/charts.d.ts +33 -0
- package/dist/charts.js +1274 -164
- package/dist/charts.js.map +1 -1
- package/dist/core.d.ts +33 -10
- package/dist/core.js +1099 -83
- package/dist/core.js.map +1 -1
- package/dist/forms.d.ts +33 -0
- package/dist/forms.js +2106 -1050
- package/dist/forms.js.map +1 -1
- package/dist/heavy.d.ts +42 -1
- package/dist/heavy.js +1663 -638
- package/dist/heavy.js.map +1 -1
- package/dist/index.d.ts +442 -270
- package/dist/index.esm.js +1947 -680
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1982 -712
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +6 -3
- package/scripts/atomix-cli.js +136 -1827
- package/scripts/cli/__tests__/basic.test.js +3 -2
- package/scripts/cli/__tests__/clean.test.js +278 -0
- package/scripts/cli/__tests__/component-validator.test.js +433 -0
- package/scripts/cli/__tests__/generator.test.js +613 -0
- package/scripts/cli/__tests__/glass-motion.test.js +256 -0
- package/scripts/cli/__tests__/integration.test.js +719 -108
- package/scripts/cli/__tests__/migrate.test.js +74 -0
- package/scripts/cli/__tests__/security.test.js +206 -0
- package/scripts/cli/__tests__/test-setup.js +3 -1
- package/scripts/cli/__tests__/theme-bridge.test.js +507 -0
- package/scripts/cli/__tests__/token-provider.test.js +361 -0
- package/scripts/cli/__tests__/utils.test.js +5 -5
- package/scripts/cli/commands/benchmark.js +105 -0
- package/scripts/cli/commands/build-theme.js +115 -0
- package/scripts/cli/commands/clean.js +109 -0
- package/scripts/cli/commands/doctor.js +88 -0
- package/scripts/cli/commands/generate.js +218 -0
- package/scripts/cli/commands/init.js +73 -0
- package/scripts/cli/commands/migrate.js +106 -0
- package/scripts/cli/commands/sync-tokens.js +206 -0
- package/scripts/cli/commands/theme-bridge.js +248 -0
- package/scripts/cli/commands/tokens.js +157 -0
- package/scripts/cli/commands/validate.js +194 -0
- package/scripts/cli/internal/ai-engine.js +156 -0
- package/scripts/cli/internal/compiler.js +114 -0
- package/scripts/cli/internal/component-validator.js +443 -0
- package/scripts/cli/internal/config-loader.js +162 -0
- package/scripts/cli/internal/filesystem.js +158 -0
- package/scripts/cli/internal/generator.js +430 -0
- package/scripts/cli/internal/glass-generator.js +398 -0
- package/scripts/cli/internal/hook-generator.js +369 -0
- package/scripts/cli/internal/hooks.js +61 -0
- package/scripts/cli/internal/itcss-generator.js +565 -0
- package/scripts/cli/internal/motion-generator.js +679 -0
- package/scripts/cli/internal/template-engine.js +301 -0
- package/scripts/cli/internal/theme-bridge.js +664 -0
- package/scripts/cli/internal/tokens/engine.js +122 -0
- package/scripts/cli/internal/tokens/provider.js +34 -0
- package/scripts/cli/internal/tokens/providers/figma.js +50 -0
- package/scripts/cli/internal/tokens/providers/style-dictionary.js +48 -0
- package/scripts/cli/internal/tokens/providers/w3c.js +48 -0
- package/scripts/cli/internal/tokens/token-provider.js +443 -0
- package/scripts/cli/internal/tokens/token-validator.js +513 -0
- package/scripts/cli/internal/validator.js +276 -0
- package/scripts/cli/internal/wizard.js +115 -0
- package/scripts/cli/mappings.js +23 -0
- package/scripts/cli/migration-tools.js +164 -94
- package/scripts/cli/plugins/style-dictionary.js +46 -0
- package/scripts/cli/templates/README.md +525 -95
- package/scripts/cli/templates/common-templates.js +40 -14
- package/scripts/cli/templates/components/react-component.ts +282 -0
- package/scripts/cli/templates/config/project-config.ts +112 -0
- package/scripts/cli/templates/hooks/use-component.ts +477 -0
- package/scripts/cli/templates/index.js +19 -4
- package/scripts/cli/templates/index.ts +171 -0
- package/scripts/cli/templates/next-templates.js +72 -0
- package/scripts/cli/templates/react-templates.js +70 -126
- package/scripts/cli/templates/scss-templates.js +35 -35
- package/scripts/cli/templates/stories/storybook-story.ts +241 -0
- package/scripts/cli/templates/styles/scss-component.ts +255 -0
- package/scripts/cli/templates/tests/vitest-test.ts +229 -0
- package/scripts/cli/templates/token-templates.js +337 -1
- package/scripts/cli/templates/tokens/token-generators.ts +1088 -0
- package/scripts/cli/templates/types/component-types.ts +145 -0
- package/scripts/cli/templates/utils/testing-utils.ts +144 -0
- package/scripts/cli/templates/vanilla-templates.js +39 -0
- package/scripts/cli/token-manager.js +8 -2
- package/scripts/cli/utils/cache-manager.js +240 -0
- package/scripts/cli/utils/detector.js +46 -0
- package/scripts/cli/utils/diagnostics.js +289 -0
- package/scripts/cli/utils/error.js +89 -0
- package/scripts/cli/utils/helpers.js +67 -0
- package/scripts/cli/utils/logger.js +75 -0
- package/scripts/cli/utils/security.js +302 -0
- package/scripts/cli/utils/telemetry.js +115 -0
- package/scripts/cli/utils/validation.js +37 -0
- package/scripts/cli/utils.js +28 -341
- package/src/components/Accordion/Accordion.stories.tsx +0 -18
- package/src/components/Accordion/Accordion.test.tsx +0 -17
- package/src/components/Accordion/Accordion.tsx +0 -4
- package/src/components/AtomixGlass/AtomixGlass.test.tsx +37 -3
- package/src/components/AtomixGlass/AtomixGlass.tsx +143 -31
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +129 -31
- package/src/components/AtomixGlass/PerformanceDashboard.tsx +219 -0
- package/src/components/AtomixGlass/README.md +25 -10
- package/src/components/AtomixGlass/__snapshots__/AtomixGlass.test.tsx.snap +216 -0
- package/src/components/AtomixGlass/animation-system.ts +578 -0
- package/src/components/AtomixGlass/shader-utils.ts +4 -1
- package/src/components/AtomixGlass/stories/Overview.stories.tsx +157 -6
- package/src/components/AtomixGlass/stories/Phase1-Animation.stories.tsx +653 -0
- package/src/components/AtomixGlass/stories/Phase1-Test.stories.tsx +95 -0
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +51 -51
- package/src/components/AtomixGlass/stories/shared-components.tsx +6 -0
- package/src/components/Avatar/Avatar.tsx +1 -1
- package/src/components/Button/Button.stories.disabled-link.tsx +10 -0
- package/src/components/Button/Button.stories.tsx +10 -0
- package/src/components/Button/Button.test.tsx +16 -11
- package/src/components/Button/Button.tsx +4 -4
- package/src/components/Card/Card.tsx +1 -1
- package/src/components/Dropdown/Dropdown.tsx +12 -12
- package/src/components/Form/Select.tsx +62 -3
- package/src/components/Modal/Modal.tsx +14 -3
- package/src/components/Navigation/Navbar/Navbar.tsx +44 -0
- package/src/components/Slider/Slider.stories.tsx +3 -3
- package/src/components/Slider/Slider.tsx +38 -0
- package/src/components/Steps/Steps.tsx +3 -3
- package/src/components/Tabs/Tabs.tsx +77 -8
- package/src/components/Testimonial/Testimonial.tsx +1 -1
- package/src/components/TypedButton/TypedButton.stories.tsx +59 -0
- package/src/components/TypedButton/TypedButton.tsx +39 -0
- package/src/components/TypedButton/index.ts +2 -0
- package/src/components/VideoPlayer/VideoPlayer.tsx +11 -4
- package/src/lib/composables/index.ts +4 -7
- package/src/lib/composables/types.ts +45 -0
- package/src/lib/composables/useAccordion.ts +0 -7
- package/src/lib/composables/useAtomixGlass.ts +148 -6
- package/src/lib/composables/useAtomixGlassStyles.ts +9 -7
- package/src/lib/composables/useChartExport.ts +3 -13
- package/src/lib/composables/useDropdown.ts +66 -0
- package/src/lib/composables/useFocusTrap.ts +80 -0
- package/src/lib/composables/usePerformanceMonitor.ts +448 -0
- package/src/lib/composables/useResponsiveGlass.presets.ts +192 -0
- package/src/lib/composables/useResponsiveGlass.ts +441 -0
- package/src/lib/composables/useTooltip.ts +16 -0
- package/src/lib/composables/useTypedButton.ts +66 -0
- package/src/lib/config/index.ts +62 -5
- package/src/lib/constants/components.ts +62 -7
- package/src/lib/theme/devtools/__tests__/useHistory.test.tsx +150 -0
- package/src/lib/theme/tokens/centralized-tokens.ts +120 -0
- package/src/lib/theme/utils/__tests__/domUtils.test.ts +101 -0
- package/src/lib/types/components.ts +37 -11
- package/src/lib/types/glass.ts +35 -0
- package/src/lib/types/index.ts +1 -0
- package/src/lib/utils/displacement-generator.ts +1 -1
- package/src/styles/01-settings/_settings.testtypecheck.scss +53 -0
- package/src/styles/01-settings/_settings.typedbutton.scss +53 -0
- package/src/styles/06-components/_components.atomix-glass.scss +17 -21
- package/src/styles/06-components/_components.edge-panel.scss +1 -5
- package/src/styles/06-components/_components.modal.scss +1 -4
- package/src/styles/06-components/_components.navbar.scss +1 -1
- package/src/styles/06-components/_components.testbutton.scss +212 -0
- package/src/styles/06-components/_components.testtypecheck.scss +212 -0
- package/src/styles/06-components/_components.tooltip.scss +9 -5
- package/src/styles/06-components/_components.typedbutton.scss +212 -0
- package/src/styles/99-utilities/_index.scss +1 -0
- package/src/styles/99-utilities/_utilities.text.scss +1 -1
- package/src/styles/99-utilities/_utilities.touch-target.scss +36 -0
- package/scripts/cli/component-generator.js +0 -564
- package/scripts/cli/interactive-init.js +0 -357
- package/src/styles/06-components/old.chart.styles.scss +0 -2788
|
@@ -508,51 +508,77 @@ export const envTemplate = `# Environment Variables
|
|
|
508
508
|
export const itcssIndexTemplates = {
|
|
509
509
|
settings: `// Settings Layer
|
|
510
510
|
// Global variables, config switches, and brand colors
|
|
511
|
+
//
|
|
512
|
+
// This layer imports design tokens and configuration from Atomix.
|
|
513
|
+
// Override variables here before importing tools and other layers.
|
|
511
514
|
|
|
512
|
-
// Import
|
|
513
|
-
|
|
515
|
+
// Import core design tokens from Atomix
|
|
516
|
+
@use '@shohojdhara/atomix/scss/settings' as *;
|
|
517
|
+
|
|
518
|
+
// Optional: Override specific tokens for your brand
|
|
519
|
+
// Example:
|
|
520
|
+
// $primary-6: #your-brand-color;
|
|
521
|
+
// $font-family-base: 'Your Font', sans-serif;
|
|
514
522
|
`,
|
|
515
523
|
|
|
516
524
|
tools: `// Tools Layer
|
|
517
525
|
// Globally used mixins and functions
|
|
526
|
+
//
|
|
527
|
+
// This layer imports utility mixins and functions from Atomix.
|
|
528
|
+
// Use these tools to generate consistent CSS across your project.
|
|
518
529
|
|
|
519
|
-
// Import Atomix tools
|
|
520
|
-
|
|
530
|
+
// Import Atomix tools (mixins, functions)
|
|
531
|
+
@use '@shohojdhara/atomix/scss/tools' as *;
|
|
521
532
|
`,
|
|
522
533
|
|
|
523
534
|
generic: `// Generic Layer
|
|
524
535
|
// Ground-zero styles (normalize.css, resets, box-sizing)
|
|
536
|
+
//
|
|
537
|
+
// This layer imports base reset and normalization styles.
|
|
538
|
+
// These are far-reaching, low-specificity foundational styles.
|
|
525
539
|
|
|
526
|
-
// Import Atomix generic styles
|
|
527
|
-
|
|
540
|
+
// Import Atomix generic styles
|
|
541
|
+
@use '@shohojdhara/atomix/scss/generic' as *;
|
|
528
542
|
`,
|
|
529
543
|
|
|
530
544
|
elements: `// Elements Layer
|
|
531
545
|
// Unclassed HTML elements (type selectors)
|
|
546
|
+
//
|
|
547
|
+
// This layer imports base element styling from Atomix.
|
|
548
|
+
// Styles for bare HTML elements without classes.
|
|
532
549
|
|
|
533
|
-
// Import Atomix element styles
|
|
534
|
-
|
|
550
|
+
// Import Atomix element styles
|
|
551
|
+
@use '@shohojdhara/atomix/scss/elements' as *;
|
|
535
552
|
`,
|
|
536
553
|
|
|
537
554
|
objects: `// Objects Layer
|
|
538
555
|
// Cosmetic-free design patterns (layouts, grids)
|
|
556
|
+
//
|
|
557
|
+
// This layer imports structural layout patterns from Atomix.
|
|
558
|
+
// Object classes are functional, not cosmetic.
|
|
539
559
|
|
|
540
|
-
// Import Atomix object styles
|
|
541
|
-
|
|
560
|
+
// Import Atomix object styles
|
|
561
|
+
@use '@shohojdhara/atomix/scss/objects' as *;
|
|
542
562
|
`,
|
|
543
563
|
|
|
544
564
|
components: `// Components Layer
|
|
545
565
|
// Designed components, chunks of UI
|
|
566
|
+
//
|
|
567
|
+
// This layer imports UI component styles from Atomix.
|
|
568
|
+
// Components are specific, designed pieces of interface.
|
|
546
569
|
|
|
547
|
-
// Import Atomix
|
|
548
|
-
|
|
570
|
+
// Import Atomix component styles
|
|
571
|
+
@use '@shohojdhara/atomix/scss/components' as *;
|
|
549
572
|
`,
|
|
550
573
|
|
|
551
574
|
utilities: `// Utilities Layer
|
|
552
575
|
// Helper classes with ability to override anything
|
|
576
|
+
//
|
|
577
|
+
// This layer imports utility helper classes from Atomix.
|
|
578
|
+
// Utilities use !important to override previous layers.
|
|
553
579
|
|
|
554
|
-
// Import Atomix utilities
|
|
555
|
-
|
|
580
|
+
// Import Atomix utilities
|
|
581
|
+
@use '@shohojdhara/atomix/scss/utilities' as *;
|
|
556
582
|
`,
|
|
557
583
|
|
|
558
584
|
main: `// Main Stylesheet
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Component Templates
|
|
3
|
+
* Templates for generating React components following Atomix architecture
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generates a full-featured React component with composable pattern
|
|
8
|
+
*/
|
|
9
|
+
export const componentTemplate = (name: string): string => {
|
|
10
|
+
const componentPrefix = name.toLowerCase().replace(/([A-Z])/g, '-$1').toLowerCase().replace(/^-/, '');
|
|
11
|
+
|
|
12
|
+
return `import React, { forwardRef, useCallback, memo } from 'react';
|
|
13
|
+
import { use${name} } from '../../lib/composables/use${name}';
|
|
14
|
+
import { ${name.toUpperCase()}, THEME_NAMING } from '../../lib/constants/components';
|
|
15
|
+
import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
|
|
16
|
+
import { ThemeNaming } from '../../lib/utils/themeNaming';
|
|
17
|
+
import type { ${name}Props } from '../../lib/types/components';
|
|
18
|
+
|
|
19
|
+
export const ${name} = React.memo(
|
|
20
|
+
forwardRef<HTMLDivElement, ${name}Props>(
|
|
21
|
+
(
|
|
22
|
+
{
|
|
23
|
+
children,
|
|
24
|
+
className = '',
|
|
25
|
+
disabled = false,
|
|
26
|
+
variant = 'primary',
|
|
27
|
+
size = 'md',
|
|
28
|
+
glass,
|
|
29
|
+
onClick,
|
|
30
|
+
onHover,
|
|
31
|
+
onFocus,
|
|
32
|
+
onBlur,
|
|
33
|
+
'aria-label': ariaLabel,
|
|
34
|
+
'aria-describedby': ariaDescribedBy,
|
|
35
|
+
tabIndex,
|
|
36
|
+
style,
|
|
37
|
+
...props
|
|
38
|
+
},
|
|
39
|
+
ref
|
|
40
|
+
) => {
|
|
41
|
+
const { generateClassNames, handleClick } = use${name}({
|
|
42
|
+
variant,
|
|
43
|
+
size,
|
|
44
|
+
disabled,
|
|
45
|
+
glass,
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const componentClass = [
|
|
49
|
+
${name.toUpperCase()}.BASE_CLASS,
|
|
50
|
+
ThemeNaming.variantClass('${componentPrefix}', variant),
|
|
51
|
+
size !== 'md' ? ThemeNaming.sizeClass('${componentPrefix}', size) : '',
|
|
52
|
+
disabled ? ThemeNaming.stateClass('${componentPrefix}', 'disabled') : '',
|
|
53
|
+
glass ? ThemeNaming.stateClass('${componentPrefix}', 'glass') : '',
|
|
54
|
+
className,
|
|
55
|
+
]
|
|
56
|
+
.filter(Boolean)
|
|
57
|
+
.join(' ');
|
|
58
|
+
|
|
59
|
+
// Handle click event
|
|
60
|
+
const handleClickEvent = useCallback(
|
|
61
|
+
(event: React.MouseEvent<HTMLDivElement>) => {
|
|
62
|
+
if (disabled) {
|
|
63
|
+
event.preventDefault();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
onClick?.(event);
|
|
67
|
+
},
|
|
68
|
+
[disabled, onClick]
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// Handle hover
|
|
72
|
+
const handleMouseEnter = useCallback(
|
|
73
|
+
(event: React.MouseEvent<HTMLDivElement>) => {
|
|
74
|
+
if (!disabled) {
|
|
75
|
+
onHover?.(event);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
[disabled, onHover]
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
// Handle focus
|
|
82
|
+
const handleFocusEvent = useCallback(
|
|
83
|
+
(event: React.FocusEvent<HTMLDivElement>) => {
|
|
84
|
+
if (!disabled) {
|
|
85
|
+
onFocus?.(event);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
[disabled, onFocus]
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
// Handle blur
|
|
92
|
+
const handleBlurEvent = useCallback(
|
|
93
|
+
(event: React.FocusEvent<HTMLDivElement>) => {
|
|
94
|
+
if (!disabled) {
|
|
95
|
+
onBlur?.(event);
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
[disabled, onBlur]
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
// Component props
|
|
102
|
+
const componentProps = {
|
|
103
|
+
ref,
|
|
104
|
+
className: componentClass,
|
|
105
|
+
onClick: handleClickEvent,
|
|
106
|
+
onMouseEnter: onHover ? handleMouseEnter : undefined,
|
|
107
|
+
onFocus: onFocus ? handleFocusEvent : undefined,
|
|
108
|
+
onBlur: onBlur ? handleBlurEvent : undefined,
|
|
109
|
+
'aria-disabled': disabled,
|
|
110
|
+
'aria-label': ariaLabel,
|
|
111
|
+
'aria-describedby': ariaDescribedBy,
|
|
112
|
+
tabIndex: tabIndex !== undefined ? tabIndex : (disabled ? -1 : 0),
|
|
113
|
+
style,
|
|
114
|
+
...props,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Default glass props
|
|
118
|
+
const defaultGlassProps = {
|
|
119
|
+
displacementScale: 20,
|
|
120
|
+
blurAmount: 0,
|
|
121
|
+
saturation: 200,
|
|
122
|
+
elasticity: 0,
|
|
123
|
+
};
|
|
124
|
+
const glassProps = glass === true ? defaultGlassProps : { ...defaultGlassProps, ...glass };
|
|
125
|
+
|
|
126
|
+
// Component content
|
|
127
|
+
const componentContent = (
|
|
128
|
+
<div {...componentProps}>
|
|
129
|
+
{children}
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
return glass ? <AtomixGlass {...glassProps}>{componentContent}</AtomixGlass> : componentContent;
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
${name}.displayName = '${name}';
|
|
139
|
+
|
|
140
|
+
export default ${name};`;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Generates a simple presentational React component
|
|
145
|
+
*/
|
|
146
|
+
export const simpleTemplate = (name: string): string => `import React, { forwardRef } from 'react';
|
|
147
|
+
import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
|
|
148
|
+
import type { ${name}Props } from '../../lib/types/components';
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* ${name} - Simple Presentational Component
|
|
152
|
+
*
|
|
153
|
+
* @param {${name}Props} props - Component properties
|
|
154
|
+
* @returns {JSX.Element} The rendered component
|
|
155
|
+
*/
|
|
156
|
+
export const ${name} = forwardRef<HTMLDivElement, ${name}Props>(
|
|
157
|
+
({ children, className = '', glass, 'aria-label': ariaLabel, ...props }, ref) => {
|
|
158
|
+
const componentClass = [\`c-${name.toLowerCase()}\`, className].filter(Boolean).join(' ');
|
|
159
|
+
|
|
160
|
+
const content = (
|
|
161
|
+
<div ref={ref} className={componentClass} aria-label={ariaLabel} {...props}>
|
|
162
|
+
{children}
|
|
163
|
+
</div>
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
return glass ? <AtomixGlass {...(glass === true ? {} : glass)}>{content}</AtomixGlass> : content;
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
|
|
170
|
+
${name}.displayName = '${name}';
|
|
171
|
+
`;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Generates a medium complexity React component with composable pattern
|
|
175
|
+
*/
|
|
176
|
+
export const mediumTemplate = (name: string): string => `import React, { forwardRef, useId, memo } from 'react';
|
|
177
|
+
import { ${name.toUpperCase()} } from '../../lib/constants/components';
|
|
178
|
+
import { use${name} } from '../../lib/composables/use${name}';
|
|
179
|
+
import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
|
|
180
|
+
import type { ${name}Props } from '../../lib/types/components';
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* ${name} - Medium Presentational Component
|
|
184
|
+
*
|
|
185
|
+
* @param {${name}Props} props - Component properties
|
|
186
|
+
* @returns {JSX.Element} The rendered component
|
|
187
|
+
*/
|
|
188
|
+
export const ${name} = memo(
|
|
189
|
+
forwardRef<HTMLDivElement, ${name}Props>(
|
|
190
|
+
({ children, className = '', disabled = false, glass, style, 'aria-label': ariaLabel, ...props }, ref) => {
|
|
191
|
+
const instanceId = useId();
|
|
192
|
+
const { generateClassNames } = use${name}({ disabled });
|
|
193
|
+
|
|
194
|
+
const content = (
|
|
195
|
+
<div
|
|
196
|
+
ref={ref}
|
|
197
|
+
className={generateClassNames(className)}
|
|
198
|
+
style={style}
|
|
199
|
+
aria-label={ariaLabel}
|
|
200
|
+
aria-disabled={disabled}
|
|
201
|
+
{...props}
|
|
202
|
+
>
|
|
203
|
+
{children}
|
|
204
|
+
</div>
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
return glass ? <AtomixGlass {...(glass === true ? {} : glass)}>{content}</AtomixGlass> : content;
|
|
208
|
+
}
|
|
209
|
+
)
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
${name}.displayName = '${name}';
|
|
213
|
+
|
|
214
|
+
export default ${name};
|
|
215
|
+
`;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Generates a complex React component with state management
|
|
219
|
+
*/
|
|
220
|
+
export const complexTemplate = (name: string): string => `import React, { forwardRef, useId, memo } from 'react';
|
|
221
|
+
import { ${name.toUpperCase()} } from '../../lib/constants/components';
|
|
222
|
+
import { use${name} } from '../../lib/composables/use${name}';
|
|
223
|
+
import { AtomixGlass } from '../AtomixGlass/AtomixGlass';
|
|
224
|
+
import type { ${name}Props, ${name}State } from '../../lib/types/components';
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* ${name} - Complex Functional Component
|
|
228
|
+
*
|
|
229
|
+
* @param {${name}Props} props - Component properties
|
|
230
|
+
* @returns {JSX.Element} The rendered component
|
|
231
|
+
*/
|
|
232
|
+
export const ${name} = memo(
|
|
233
|
+
forwardRef<HTMLDivElement, ${name}Props>(
|
|
234
|
+
({ children, className = '', disabled = false, glass, style, onStateChange, 'aria-label': ariaLabel, ...props }, ref) => {
|
|
235
|
+
const instanceId = useId();
|
|
236
|
+
const { generateClassNames } = use${name}({ disabled, onStateChange });
|
|
237
|
+
|
|
238
|
+
const content = (
|
|
239
|
+
<div
|
|
240
|
+
ref={ref}
|
|
241
|
+
className={generateClassNames(className)}
|
|
242
|
+
style={style}
|
|
243
|
+
aria-label={ariaLabel}
|
|
244
|
+
aria-disabled={disabled}
|
|
245
|
+
{...props}
|
|
246
|
+
>
|
|
247
|
+
{children}
|
|
248
|
+
</div>
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
return glass ? <AtomixGlass {...(glass === true ? {} : glass)}>{content}</AtomixGlass> : content;
|
|
252
|
+
}
|
|
253
|
+
)
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
${name}.displayName = '${name}';
|
|
257
|
+
|
|
258
|
+
export default ${name};
|
|
259
|
+
`;
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Generates an index file export for a component
|
|
263
|
+
*/
|
|
264
|
+
export const indexTemplate = (name: string): string => `export { default as ${name} } from './${name}';
|
|
265
|
+
export type { ${name}Props } from './${name}';
|
|
266
|
+
`;
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* All React component templates
|
|
270
|
+
*/
|
|
271
|
+
export const reactComponentTemplates = {
|
|
272
|
+
component: componentTemplate,
|
|
273
|
+
simple: simpleTemplate,
|
|
274
|
+
medium: mediumTemplate,
|
|
275
|
+
complex: complexTemplate,
|
|
276
|
+
index: indexTemplate,
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Type for React component templates object
|
|
281
|
+
*/
|
|
282
|
+
export type ReactComponentTemplates = typeof reactComponentTemplates;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project Configuration Templates
|
|
3
|
+
* Templates for generating project configuration files
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Generates a package.json template for new projects
|
|
8
|
+
*/
|
|
9
|
+
export const packageJsonTemplate = (): string => `{
|
|
10
|
+
"name": "@shohojdhara/atomix-project",
|
|
11
|
+
"version": "1.0.0",
|
|
12
|
+
"description": "Project built with Atomix Design System",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"scripts": {
|
|
15
|
+
"dev": "vite",
|
|
16
|
+
"build": "tsc && vite build",
|
|
17
|
+
"preview": "vite preview",
|
|
18
|
+
"lint": "eslint src --ext ts,tsx",
|
|
19
|
+
"test": "vitest",
|
|
20
|
+
"storybook": "storybook dev -p 6006",
|
|
21
|
+
"build-storybook": "storybook build"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@shohojdhara/atomix": "^2.0.0",
|
|
25
|
+
"react": "^18.2.0",
|
|
26
|
+
"react-dom": "^18.2.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@testing-library/react": "^14.0.0",
|
|
30
|
+
"@types/react": "^18.2.0",
|
|
31
|
+
"@types/react-dom": "^18.2.0",
|
|
32
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
33
|
+
"jest-axe": "^8.0.0",
|
|
34
|
+
"typescript": "^5.0.0",
|
|
35
|
+
"vite": "^5.0.0",
|
|
36
|
+
"vitest": "^1.0.0"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Generates a tsconfig.json template
|
|
43
|
+
*/
|
|
44
|
+
export const tsconfigTemplate = (): string => `{
|
|
45
|
+
"compilerOptions": {
|
|
46
|
+
"target": "ES2020",
|
|
47
|
+
"useDefineForClassFields": true,
|
|
48
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
|
49
|
+
"module": "ESNext",
|
|
50
|
+
"skipLibCheck": true,
|
|
51
|
+
"moduleResolution": "bundler",
|
|
52
|
+
"allowImportingTsExtensions": true,
|
|
53
|
+
"resolveJsonModule": true,
|
|
54
|
+
"isolatedModules": true,
|
|
55
|
+
"noEmit": true,
|
|
56
|
+
"jsx": "react-jsx",
|
|
57
|
+
"strict": true,
|
|
58
|
+
"noUnusedLocals": true,
|
|
59
|
+
"noUnusedParameters": true,
|
|
60
|
+
"noFallthroughCasesInSwitch": true,
|
|
61
|
+
"baseUrl": ".",
|
|
62
|
+
"paths": {
|
|
63
|
+
"@/*": ["src/*"],
|
|
64
|
+
"@components/*": ["src/components/*"],
|
|
65
|
+
"@styles/*": ["src/styles/*"],
|
|
66
|
+
"@lib/*": ["src/lib/*"]
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"include": ["src"],
|
|
70
|
+
"references": [{ "path": "./tsconfig.node.json" }]
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Generates a vite.config.ts template
|
|
76
|
+
*/
|
|
77
|
+
export const viteConfigTemplate = (): string => `import { defineConfig } from 'vite';
|
|
78
|
+
import react from '@vitejs/plugin-react';
|
|
79
|
+
import path from 'path';
|
|
80
|
+
|
|
81
|
+
export default defineConfig({
|
|
82
|
+
plugins: [react()],
|
|
83
|
+
resolve: {
|
|
84
|
+
alias: {
|
|
85
|
+
'@': path.resolve(__dirname, './src'),
|
|
86
|
+
'@components': path.resolve(__dirname, './src/components'),
|
|
87
|
+
'@styles': path.resolve(__dirname, './src/styles'),
|
|
88
|
+
'@lib': path.resolve(__dirname, './src/lib'),
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
css: {
|
|
92
|
+
modules: {
|
|
93
|
+
localsConvention: 'camelCase',
|
|
94
|
+
generateScopedName: '[name]__[local]___[hash:base64:5]',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
`;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* All project configuration templates
|
|
102
|
+
*/
|
|
103
|
+
export const projectConfigTemplates = {
|
|
104
|
+
packageJson: packageJsonTemplate,
|
|
105
|
+
tsconfig: tsconfigTemplate,
|
|
106
|
+
viteConfig: viteConfigTemplate,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Type for project configuration templates object
|
|
111
|
+
*/
|
|
112
|
+
export type ProjectConfigTemplates = typeof projectConfigTemplates;
|