create-template-html-css 2.0.4 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +436 -0
- package/CODE-SPLITTING-GUIDE.md +274 -0
- package/COMPONENTS-GALLERY.html +143 -8
- package/HTML-VS-REACT.md +289 -0
- package/QUICKSTART-REACT.md +293 -0
- package/REACT-SUPPORT-SUMMARY.md +235 -0
- package/README.md +261 -12
- package/bin/cli.js +100 -759
- package/bin/commands/create.js +288 -0
- package/bin/commands/gallery.js +42 -0
- package/bin/commands/insert.js +123 -0
- package/bin/commands/list.js +73 -0
- package/package.json +10 -3
- package/src/component-choices.js +7 -0
- package/src/components-registry.js +112 -0
- package/src/format-utils.js +49 -0
- package/src/generator.js +83 -594
- package/src/generators/color-schemes.js +78 -0
- package/src/generators/color-utils.js +108 -0
- package/src/generators/component-filters.js +151 -0
- package/src/generators/html-generators.js +180 -0
- package/src/generators/validation.js +43 -0
- package/src/index.js +2 -1
- package/src/inserter.js +55 -233
- package/src/inserters/backup-utils.js +20 -0
- package/src/inserters/component-loader.js +68 -0
- package/src/inserters/html-utils.js +31 -0
- package/src/inserters/indentation-utils.js +90 -0
- package/src/inserters/validation-utils.js +49 -0
- package/src/react-component-choices.js +97 -0
- package/src/react-component-templates.js +182 -0
- package/src/react-file-operations.js +172 -0
- package/src/react-generator.js +219 -0
- package/src/react-templates.js +418 -0
- package/src/templates/basic-components-templates.js +157 -0
- package/src/templates/form-components-templates.js +194 -0
- package/src/templates/interactive-components-templates.js +139 -0
- package/src/utils/file-utils.js +97 -0
- package/src/utils/path-utils.js +32 -0
- package/src/utils/string-utils.js +51 -0
- package/src/utils/template-loader.js +91 -0
- package/templates/_shared/PATTERNS.md +246 -0
- package/templates/_shared/README.md +74 -0
- package/templates/_shared/base.css +18 -0
- package/templates/blackjack/index.html +1 -1
- package/templates/breakout/index.html +1 -1
- package/templates/connect-four/index.html +1 -1
- package/templates/dice-game/index.html +1 -1
- package/templates/flappy-bird/index.html +1 -1
- package/templates/pong/index.html +1 -1
- package/templates/skeleton/index.html +4 -4
- package/templates/slot-machine/index.html +1 -1
- package/templates/tetris/index.html +1 -1
- package/templates-react/README.md +126 -0
- package/templates-react/alert/Alert.css +158 -0
- package/templates-react/alert/Alert.example.jsx +106 -0
- package/templates-react/alert/Alert.jsx +61 -0
- package/templates-react/badge/Badge.css +196 -0
- package/templates-react/badge/Badge.example.jsx +182 -0
- package/templates-react/badge/Badge.jsx +44 -0
- package/templates-react/button/Button.css +88 -0
- package/templates-react/button/Button.example.jsx +40 -0
- package/templates-react/button/Button.jsx +29 -0
- package/templates-react/card/Card.css +86 -0
- package/templates-react/card/Card.example.jsx +49 -0
- package/templates-react/card/Card.jsx +35 -0
- package/templates-react/checkbox/Checkbox.css +217 -0
- package/templates-react/checkbox/Checkbox.example.jsx +141 -0
- package/templates-react/checkbox/Checkbox.jsx +82 -0
- package/templates-react/counter/Counter.css +99 -0
- package/templates-react/counter/Counter.example.jsx +45 -0
- package/templates-react/counter/Counter.jsx +70 -0
- package/templates-react/dropdown/Dropdown.css +237 -0
- package/templates-react/dropdown/Dropdown.example.jsx +98 -0
- package/templates-react/dropdown/Dropdown.jsx +154 -0
- package/templates-react/form/Form.css +128 -0
- package/templates-react/form/Form.example.jsx +64 -0
- package/templates-react/form/Form.jsx +125 -0
- package/templates-react/input/Input.css +113 -0
- package/templates-react/input/Input.example.jsx +82 -0
- package/templates-react/input/Input.jsx +87 -0
- package/templates-react/modal/Modal.css +152 -0
- package/templates-react/modal/Modal.example.jsx +90 -0
- package/templates-react/modal/Modal.jsx +46 -0
- package/templates-react/navbar/Navbar.css +139 -0
- package/templates-react/navbar/Navbar.example.jsx +37 -0
- package/templates-react/navbar/Navbar.jsx +62 -0
- package/templates-react/progress/Progress.css +247 -0
- package/templates-react/progress/Progress.example.jsx +244 -0
- package/templates-react/progress/Progress.jsx +79 -0
- package/templates-react/switch/Switch.css +244 -0
- package/templates-react/switch/Switch.example.jsx +221 -0
- package/templates-react/switch/Switch.jsx +98 -0
- package/templates-react/todo-list/TodoList.css +236 -0
- package/templates-react/todo-list/TodoList.example.jsx +15 -0
- package/templates-react/todo-list/TodoList.jsx +84 -0
- package/templates-react/tooltip/Tooltip.css +165 -0
- package/templates-react/tooltip/Tooltip.example.jsx +166 -0
- package/templates-react/tooltip/Tooltip.jsx +176 -0
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Templates Generator Module
|
|
3
|
+
*
|
|
4
|
+
* Generates complete React project files including App.jsx, index files,
|
|
5
|
+
* configuration files, and documentation for component-based projects.
|
|
6
|
+
*
|
|
7
|
+
* @module react-templates
|
|
8
|
+
* @requires react-component-templates
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import {
|
|
12
|
+
getComponentTemplate,
|
|
13
|
+
getComponentImports,
|
|
14
|
+
hasComponent,
|
|
15
|
+
getAllComponentNames
|
|
16
|
+
} from './react-component-templates.js';
|
|
17
|
+
|
|
18
|
+
// ============================================================================
|
|
19
|
+
// CONSTANTS
|
|
20
|
+
// ============================================================================
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* React and Vite version constants
|
|
24
|
+
* Ensures consistent dependency versions across generated projects
|
|
25
|
+
*
|
|
26
|
+
* @constant {string}
|
|
27
|
+
*/
|
|
28
|
+
const REACT_VERSION = "^18.2.0";
|
|
29
|
+
const VITE_VERSION = "^5.0.0";
|
|
30
|
+
const VITE_REACT_PLUGIN_VERSION = "^4.2.0";
|
|
31
|
+
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// TEMPLATE HELPERS
|
|
34
|
+
// ============================================================================
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Create App.jsx template wrapper
|
|
38
|
+
*
|
|
39
|
+
* Wraps component usage examples in a complete React App component structure,
|
|
40
|
+
* including proper imports and export statements.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} componentName - Component name in PascalCase (e.g., 'Button')
|
|
43
|
+
* @param {string} additionalImports - React hooks to import (e.g., 'useState, useEffect')
|
|
44
|
+
* @param {string} content - JSX content for the App component body
|
|
45
|
+
* @returns {string} Complete App.jsx file content
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* createAppTemplate('Button', 'useState', 'return <div>...</div>');
|
|
49
|
+
*/
|
|
50
|
+
function createAppTemplate(componentName, additionalImports = '', content) {
|
|
51
|
+
const reactImports = additionalImports
|
|
52
|
+
? `import { ${additionalImports} } from 'react';`
|
|
53
|
+
: '';
|
|
54
|
+
|
|
55
|
+
const importsSection = reactImports ? `${reactImports}\n` : '';
|
|
56
|
+
return `${importsSection}import ${componentName} from './components/${componentName}/${componentName}';
|
|
57
|
+
import './components/${componentName}/${componentName}.css';
|
|
58
|
+
|
|
59
|
+
function App() {
|
|
60
|
+
${content}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default App;`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Create App.jsx template with Lazy Loading
|
|
68
|
+
*
|
|
69
|
+
* Wraps component usage in React.lazy() and Suspense for code splitting.
|
|
70
|
+
* Reduces initial bundle size by loading components on demand.
|
|
71
|
+
*
|
|
72
|
+
* @param {string} componentName - Component name in PascalCase
|
|
73
|
+
* @param {string} additionalImports - React hooks to import
|
|
74
|
+
* @param {string} content - JSX content for the App component body
|
|
75
|
+
* @returns {string} Complete App.jsx with lazy loading
|
|
76
|
+
*/
|
|
77
|
+
function createAppTemplateWithLazyLoading(componentName, additionalImports = '', content) {
|
|
78
|
+
const reactImports = additionalImports
|
|
79
|
+
? `import { lazy, Suspense, ${additionalImports} } from 'react';`
|
|
80
|
+
: `import { lazy, Suspense } from 'react';`;
|
|
81
|
+
|
|
82
|
+
return `${reactImports}
|
|
83
|
+
import './components/${componentName}/${componentName}.css';
|
|
84
|
+
|
|
85
|
+
// Lazy load component for code splitting
|
|
86
|
+
const ${componentName} = lazy(() => import('./components/${componentName}/${componentName}'));
|
|
87
|
+
|
|
88
|
+
function App() {
|
|
89
|
+
return (
|
|
90
|
+
<Suspense fallback={<div className="loading">Loading...</div>}>
|
|
91
|
+
${content}
|
|
92
|
+
</Suspense>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export default App;`;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ============================================================================
|
|
100
|
+
// APP.JSX GENERATOR
|
|
101
|
+
// ============================================================================
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Generate App.jsx content with component examples
|
|
105
|
+
*
|
|
106
|
+
* Creates a complete App.jsx file that demonstrates the component's features.
|
|
107
|
+
* Falls back to a basic example if the component template is not found.
|
|
108
|
+
*
|
|
109
|
+
* @param {string} componentName - Component name in PascalCase (e.g., 'MyButton')
|
|
110
|
+
* @param {string} componentKebab - Component name in kebab-case (e.g., 'my-button')
|
|
111
|
+
* @param {object} options - Generation options
|
|
112
|
+
* @param {boolean} options.lazyLoad - Enable lazy loading with Suspense
|
|
113
|
+
* @returns {string} Complete App.jsx file content
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const appContent = generateAppJsx('Button', 'button', { lazyLoad: true });
|
|
117
|
+
*/
|
|
118
|
+
function generateAppJsx(componentName, componentKebab, options = {}) {
|
|
119
|
+
const { lazyLoad = false } = options;
|
|
120
|
+
|
|
121
|
+
// Validate component exists (optional - could add warning)
|
|
122
|
+
if (!hasComponent(componentKebab)) {
|
|
123
|
+
console.warn(`Warning: No template found for component '${componentKebab}'. Using default template.`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Get template content from separate file
|
|
127
|
+
const templateContent = getComponentTemplate(componentKebab, componentName);
|
|
128
|
+
|
|
129
|
+
// Get required React imports for this component
|
|
130
|
+
const requiredImports = getComponentImports(componentKebab);
|
|
131
|
+
|
|
132
|
+
// Use template content if available, otherwise use default
|
|
133
|
+
const content = templateContent || ` return (
|
|
134
|
+
<div className="App">
|
|
135
|
+
<${componentName} />
|
|
136
|
+
</div>
|
|
137
|
+
);`;
|
|
138
|
+
|
|
139
|
+
// Use lazy loading template if requested
|
|
140
|
+
if (lazyLoad) {
|
|
141
|
+
return createAppTemplateWithLazyLoading(componentName, requiredImports, content);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return createAppTemplate(componentName, requiredImports, content);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// ============================================================================
|
|
148
|
+
// ENTRY POINT GENERATORS
|
|
149
|
+
// ============================================================================
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Generate index.jsx content
|
|
153
|
+
*
|
|
154
|
+
* Creates the main entry point file that renders the React app.
|
|
155
|
+
* Uses React 18's createRoot API for better performance.
|
|
156
|
+
*
|
|
157
|
+
* @returns {string} Complete index.jsx file content
|
|
158
|
+
*/
|
|
159
|
+
function generateIndexJs() {
|
|
160
|
+
return `import { StrictMode } from 'react';
|
|
161
|
+
import ReactDOM from 'react-dom/client';
|
|
162
|
+
import App from './App';
|
|
163
|
+
|
|
164
|
+
const root = ReactDOM.createRoot(document.getElementById('root'));
|
|
165
|
+
root.render(
|
|
166
|
+
<StrictMode>
|
|
167
|
+
<App />
|
|
168
|
+
</StrictMode>
|
|
169
|
+
);
|
|
170
|
+
`;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Generate index.html content
|
|
175
|
+
*
|
|
176
|
+
* Creates the HTML entry point with proper meta tags and root div.
|
|
177
|
+
*
|
|
178
|
+
* @param {string} title - Page title to display in browser tab
|
|
179
|
+
* @returns {string} Complete index.html file content
|
|
180
|
+
*/
|
|
181
|
+
function generateIndexHtml(title) {
|
|
182
|
+
return `<!DOCTYPE html>
|
|
183
|
+
<html lang="en">
|
|
184
|
+
<head>
|
|
185
|
+
<meta charset="UTF-8">
|
|
186
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
187
|
+
<title>${title}</title>
|
|
188
|
+
</head>
|
|
189
|
+
<body>
|
|
190
|
+
<div id="root"></div>
|
|
191
|
+
<script type="module" src="/src/index.jsx"></script>
|
|
192
|
+
</body>
|
|
193
|
+
</html>
|
|
194
|
+
`;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// ============================================================================
|
|
198
|
+
// CONFIG FILE GENERATORS
|
|
199
|
+
// ============================================================================
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Generate package.json content
|
|
203
|
+
*
|
|
204
|
+
* Creates a package.json with React, Vite, and all necessary scripts.
|
|
205
|
+
* Configured as ES module with dev, build, and preview scripts.
|
|
206
|
+
*
|
|
207
|
+
* @param {string} name - Project name (used as package name)
|
|
208
|
+
* @returns {Object} Package.json configuration object
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* const pkg = generatePackageJson('my-react-app');
|
|
212
|
+
* // Returns complete package.json object
|
|
213
|
+
*/
|
|
214
|
+
function generatePackageJson(name) {
|
|
215
|
+
return {
|
|
216
|
+
name: name,
|
|
217
|
+
version: "0.1.0",
|
|
218
|
+
type: "module",
|
|
219
|
+
private: true,
|
|
220
|
+
dependencies: {
|
|
221
|
+
react: REACT_VERSION,
|
|
222
|
+
"react-dom": REACT_VERSION,
|
|
223
|
+
},
|
|
224
|
+
devDependencies: {
|
|
225
|
+
"@vitejs/plugin-react": VITE_REACT_PLUGIN_VERSION,
|
|
226
|
+
vite: VITE_VERSION,
|
|
227
|
+
},
|
|
228
|
+
scripts: {
|
|
229
|
+
dev: "vite",
|
|
230
|
+
build: "vite build",
|
|
231
|
+
preview: "vite preview",
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Generate .gitignore content
|
|
238
|
+
*
|
|
239
|
+
* Creates a comprehensive .gitignore file for React/Vite projects.
|
|
240
|
+
* Includes patterns for dependencies, build outputs, environment files, and editors.
|
|
241
|
+
*
|
|
242
|
+
* @returns {string} Complete .gitignore file content
|
|
243
|
+
*/
|
|
244
|
+
function generateGitignore() {
|
|
245
|
+
return `# Dependencies
|
|
246
|
+
node_modules/
|
|
247
|
+
|
|
248
|
+
# Production
|
|
249
|
+
dist/
|
|
250
|
+
build/
|
|
251
|
+
|
|
252
|
+
# Development
|
|
253
|
+
.DS_Store
|
|
254
|
+
*.log
|
|
255
|
+
.env
|
|
256
|
+
.env.local
|
|
257
|
+
.env.development.local
|
|
258
|
+
.env.test.local
|
|
259
|
+
.env.production.local
|
|
260
|
+
|
|
261
|
+
# Editor
|
|
262
|
+
.vscode/
|
|
263
|
+
.idea/
|
|
264
|
+
*.swp
|
|
265
|
+
*.swo
|
|
266
|
+
`;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Generate vite.config.js content
|
|
271
|
+
*
|
|
272
|
+
* Creates a minimal Vite configuration file with React plugin enabled.
|
|
273
|
+
*
|
|
274
|
+
* @param {boolean} withOptimization - Include code splitting optimizations
|
|
275
|
+
* @returns {string} Complete vite.config.js file content
|
|
276
|
+
*/
|
|
277
|
+
function generateViteConfig(withOptimization = false) {
|
|
278
|
+
if (!withOptimization) {
|
|
279
|
+
return `import { defineConfig } from 'vite';
|
|
280
|
+
import react from '@vitejs/plugin-react';
|
|
281
|
+
|
|
282
|
+
// https://vitejs.dev/config/
|
|
283
|
+
export default defineConfig({
|
|
284
|
+
plugins: [react()],
|
|
285
|
+
});
|
|
286
|
+
`;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return `import { defineConfig } from 'vite';
|
|
290
|
+
import react from '@vitejs/plugin-react';
|
|
291
|
+
|
|
292
|
+
// https://vitejs.dev/config/
|
|
293
|
+
export default defineConfig({
|
|
294
|
+
plugins: [react()],
|
|
295
|
+
build: {
|
|
296
|
+
rollupOptions: {
|
|
297
|
+
output: {
|
|
298
|
+
manualChunks: {
|
|
299
|
+
// Split vendor code into separate chunk
|
|
300
|
+
vendor: ['react', 'react-dom'],
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
// Enable code splitting
|
|
305
|
+
minify: 'terser',
|
|
306
|
+
terserOptions: {
|
|
307
|
+
compress: {
|
|
308
|
+
drop_console: true, // Remove console.log in production
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
});
|
|
313
|
+
`;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Generate README.md content
|
|
318
|
+
*
|
|
319
|
+
* Creates a comprehensive README with installation instructions,
|
|
320
|
+
* available scripts, project structure, and customization guidance.
|
|
321
|
+
*
|
|
322
|
+
* @param {string} name - Project name
|
|
323
|
+
* @param {string} componentName - Component name in PascalCase
|
|
324
|
+
* @returns {string} Complete README.md file content in Markdown format
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* const readme = generateReadme('my-app', 'Button');
|
|
328
|
+
*/
|
|
329
|
+
function generateReadme(name, componentName) {
|
|
330
|
+
return `# ${name}
|
|
331
|
+
|
|
332
|
+
React component project generated with create-template-html-css.
|
|
333
|
+
|
|
334
|
+
## Component: ${componentName}
|
|
335
|
+
|
|
336
|
+
### Installation
|
|
337
|
+
|
|
338
|
+
\`\`\`bash
|
|
339
|
+
npm install
|
|
340
|
+
\`\`\`
|
|
341
|
+
|
|
342
|
+
### Development
|
|
343
|
+
|
|
344
|
+
\`\`\`bash
|
|
345
|
+
npm run dev
|
|
346
|
+
\`\`\`
|
|
347
|
+
|
|
348
|
+
Open [http://localhost:5173](http://localhost:5173) to view it in your browser.
|
|
349
|
+
|
|
350
|
+
### Build
|
|
351
|
+
|
|
352
|
+
\`\`\`bash
|
|
353
|
+
npm run build
|
|
354
|
+
\`\`\`
|
|
355
|
+
|
|
356
|
+
Builds the app for production to the \`dist\` folder.
|
|
357
|
+
|
|
358
|
+
### Preview Production Build
|
|
359
|
+
|
|
360
|
+
\`\`\`bash
|
|
361
|
+
npm run preview
|
|
362
|
+
\`\`\`
|
|
363
|
+
|
|
364
|
+
## Project Structure
|
|
365
|
+
|
|
366
|
+
\`\`\`
|
|
367
|
+
${name}/
|
|
368
|
+
├── src/
|
|
369
|
+
│ ├── components/
|
|
370
|
+
│ │ └── ${componentName}/
|
|
371
|
+
│ │ ├── ${componentName}.jsx
|
|
372
|
+
│ │ └── ${componentName}.css
|
|
373
|
+
│ ├── App.jsx
|
|
374
|
+
│ └── index.jsx
|
|
375
|
+
├── index.html
|
|
376
|
+
├── package.json
|
|
377
|
+
└── README.md
|
|
378
|
+
\`\`\`
|
|
379
|
+
|
|
380
|
+
## Customization
|
|
381
|
+
|
|
382
|
+
Feel free to modify the component files in \`src/components/${componentName}/\` to suit your needs.
|
|
383
|
+
|
|
384
|
+
## License
|
|
385
|
+
|
|
386
|
+
MIT
|
|
387
|
+
`;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// ============================================================================
|
|
391
|
+
// EXPORTS
|
|
392
|
+
// ============================================================================
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Public API exports for React template generation
|
|
396
|
+
*
|
|
397
|
+
* All generator functions for creating a complete React project structure.
|
|
398
|
+
* These functions are used by the CLI to generate project files.
|
|
399
|
+
*
|
|
400
|
+
* @exports generateAppJsx - Generate App.jsx with component examples
|
|
401
|
+
* @exports generateIndexJs - Generate index.jsx entry point
|
|
402
|
+
* @exports generateIndexHtml - Generate index.html
|
|
403
|
+
* @exports generatePackageJson - Generate package.json with dependencies
|
|
404
|
+
* @exports generateGitignore - Generate .gitignore file
|
|
405
|
+
* @exports generateViteConfig - Generate vite.config.js
|
|
406
|
+
* @exports generateReadme - Generate README.md documentation
|
|
407
|
+
* @exports createAppTemplateWithLazyLoading - Create lazy loaded App component
|
|
408
|
+
*/
|
|
409
|
+
export {
|
|
410
|
+
generateAppJsx,
|
|
411
|
+
generateIndexJs,
|
|
412
|
+
generateIndexHtml,
|
|
413
|
+
generatePackageJson,
|
|
414
|
+
generateGitignore,
|
|
415
|
+
generateViteConfig,
|
|
416
|
+
generateReadme,
|
|
417
|
+
createAppTemplateWithLazyLoading,
|
|
418
|
+
};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Basic UI Component Templates
|
|
3
|
+
* Simple display components without complex state management
|
|
4
|
+
*
|
|
5
|
+
* @module templates/basic-components-templates
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const BASIC_TEMPLATES = {
|
|
9
|
+
alert: ` return (
|
|
10
|
+
<div className="App" style={{ padding: '40px', maxWidth: '600px', margin: '0 auto' }}>
|
|
11
|
+
<h1 style={{ marginBottom: '30px' }}>Alert Component Examples</h1>
|
|
12
|
+
|
|
13
|
+
<{ComponentName} type="success" title="Success!">
|
|
14
|
+
Your changes have been saved successfully.
|
|
15
|
+
</{ComponentName}>
|
|
16
|
+
|
|
17
|
+
<{ComponentName} type="error" title="Error">
|
|
18
|
+
Something went wrong. Please try again.
|
|
19
|
+
</{ComponentName}>
|
|
20
|
+
|
|
21
|
+
<{ComponentName} type="warning" title="Warning">
|
|
22
|
+
This action cannot be undone.
|
|
23
|
+
</{ComponentName}>
|
|
24
|
+
|
|
25
|
+
<{ComponentName} type="info" title="Information">
|
|
26
|
+
Check out our new features!
|
|
27
|
+
</{ComponentName}>
|
|
28
|
+
</div>
|
|
29
|
+
);`,
|
|
30
|
+
|
|
31
|
+
badge: ` return (
|
|
32
|
+
<div className="App" style={{ padding: '40px', maxWidth: '800px', margin: '0 auto' }}>
|
|
33
|
+
<h1 style={{ marginBottom: '30px' }}>Badge Component Examples</h1>
|
|
34
|
+
|
|
35
|
+
<div style={{ marginBottom: '30px' }}>
|
|
36
|
+
<h2>Basic Badges</h2>
|
|
37
|
+
<div style={{ display: 'flex', gap: '1rem', flexWrap: 'wrap' }}>
|
|
38
|
+
<{ComponentName} variant="primary">Primary</{ComponentName}>
|
|
39
|
+
<{ComponentName} variant="success">Success</{ComponentName}>
|
|
40
|
+
<{ComponentName} variant="warning">Warning</{ComponentName}>
|
|
41
|
+
<{ComponentName} variant="error">Error</{ComponentName}>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
|
|
45
|
+
<div style={{ marginBottom: '30px' }}>
|
|
46
|
+
<h2>Pill Badges</h2>
|
|
47
|
+
<div style={{ display: 'flex', gap: '1rem', flexWrap: 'wrap' }}>
|
|
48
|
+
<{ComponentName} pill variant="info">New</{ComponentName}>
|
|
49
|
+
<{ComponentName} pill variant="success">Hot</{ComponentName}>
|
|
50
|
+
<{ComponentName} pill variant="warning">Sale</{ComponentName}>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<div style={{ marginBottom: '30px' }}>
|
|
55
|
+
<h2>Count Badges</h2>
|
|
56
|
+
<div style={{ display: 'flex', gap: '2rem', flexWrap: 'wrap' }}>
|
|
57
|
+
<div style={{ position: 'relative', display: 'inline-block' }}>
|
|
58
|
+
<button style={{ padding: '0.5rem 1rem', backgroundColor: '#3b82f6', color: 'white', border: 'none', borderRadius: '0.375rem' }}>
|
|
59
|
+
Messages
|
|
60
|
+
</button>
|
|
61
|
+
<{ComponentName} count={5} variant="error" size="small" />
|
|
62
|
+
</div>
|
|
63
|
+
<div style={{ position: 'relative', display: 'inline-block' }}>
|
|
64
|
+
<button style={{ padding: '0.5rem 1rem', backgroundColor: '#3b82f6', color: 'white', border: 'none', borderRadius: '0.375rem' }}>
|
|
65
|
+
Notifications
|
|
66
|
+
</button>
|
|
67
|
+
<{ComponentName} count={99} variant="primary" size="small" />
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div style={{ marginBottom: '30px' }}>
|
|
73
|
+
<h2>Dot Badges</h2>
|
|
74
|
+
<div style={{ display: 'flex', gap: '2rem', flexWrap: 'wrap' }}>
|
|
75
|
+
<div style={{ position: 'relative', display: 'inline-block' }}>
|
|
76
|
+
<div style={{ width: '48px', height: '48px', borderRadius: '50%', backgroundColor: '#e5e7eb', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '1.5rem' }}>
|
|
77
|
+
👤
|
|
78
|
+
</div>
|
|
79
|
+
<{ComponentName} dot variant="success" position="top-right" />
|
|
80
|
+
</div>
|
|
81
|
+
<div style={{ position: 'relative', display: 'inline-block' }}>
|
|
82
|
+
<div style={{ width: '48px', height: '48px', borderRadius: '50%', backgroundColor: '#e5e7eb', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '1.5rem' }}>
|
|
83
|
+
👤
|
|
84
|
+
</div>
|
|
85
|
+
<{ComponentName} dot variant="error" position="top-left" />
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
);`,
|
|
91
|
+
|
|
92
|
+
button: ` const handleClick = () => {
|
|
93
|
+
alert('Button clicked!');
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<div className="App" style={{
|
|
98
|
+
padding: '40px',
|
|
99
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
100
|
+
backgroundColor: '#f5f5f5',
|
|
101
|
+
minHeight: '100vh'
|
|
102
|
+
}}>
|
|
103
|
+
<h1 style={{ marginBottom: '30px', color: '#333' }}>{ComponentName} Component Examples</h1>
|
|
104
|
+
|
|
105
|
+
<div style={{ marginBottom: '30px' }}>
|
|
106
|
+
<h3 style={{ marginBottom: '15px', color: '#666' }}>Variants:</h3>
|
|
107
|
+
<div style={{ display: 'flex', gap: '15px', flexWrap: 'wrap' }}>
|
|
108
|
+
<{ComponentName} variant="primary" onClick={handleClick}>Primary</{ComponentName}>
|
|
109
|
+
<{ComponentName} variant="secondary" onClick={handleClick}>Secondary</{ComponentName}>
|
|
110
|
+
<{ComponentName} variant="success" onClick={handleClick}>Success</{ComponentName}>
|
|
111
|
+
<{ComponentName} variant="danger" onClick={handleClick}>Danger</{ComponentName}>
|
|
112
|
+
<{ComponentName} variant="outline" onClick={handleClick}>Outline</{ComponentName}>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<div style={{ marginBottom: '30px' }}>
|
|
117
|
+
<h3 style={{ marginBottom: '15px', color: '#666' }}>Sizes:</h3>
|
|
118
|
+
<div style={{ display: 'flex', gap: '15px', alignItems: 'center', flexWrap: 'wrap' }}>
|
|
119
|
+
<{ComponentName} size="small" onClick={handleClick}>Small</{ComponentName}>
|
|
120
|
+
<{ComponentName} size="medium" onClick={handleClick}>Medium</{ComponentName}>
|
|
121
|
+
<{ComponentName} size="large" onClick={handleClick}>Large</{ComponentName}>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
|
|
125
|
+
<div style={{ marginBottom: '30px' }}>
|
|
126
|
+
<h3 style={{ marginBottom: '15px', color: '#666' }}>States:</h3>
|
|
127
|
+
<div style={{ display: 'flex', gap: '15px', flexWrap: 'wrap' }}>
|
|
128
|
+
<{ComponentName} onClick={handleClick}>Normal</{ComponentName}>
|
|
129
|
+
<{ComponentName} disabled>Disabled</{ComponentName}>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
);`,
|
|
134
|
+
|
|
135
|
+
card: ` return (
|
|
136
|
+
<div className="App" style={{ padding: '40px', backgroundColor: '#f5f5f5', minHeight: '100vh' }}>
|
|
137
|
+
<h1 style={{ marginBottom: '30px' }}>{ComponentName} Component</h1>
|
|
138
|
+
<{ComponentName}
|
|
139
|
+
title="Example Card"
|
|
140
|
+
description="This is an example card component with a beautiful design"
|
|
141
|
+
image="https://via.placeholder.com/400x200"
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
);`,
|
|
145
|
+
|
|
146
|
+
counter: ` return (
|
|
147
|
+
<div className="App" style={{ padding: '40px' }}>
|
|
148
|
+
<h1>Counter Component</h1>
|
|
149
|
+
<{ComponentName}
|
|
150
|
+
initialValue={0}
|
|
151
|
+
min={0}
|
|
152
|
+
max={100}
|
|
153
|
+
onChange={(value) => console.log('Count:', value)}
|
|
154
|
+
/>
|
|
155
|
+
</div>
|
|
156
|
+
);`,
|
|
157
|
+
};
|