create-template-html-css 2.0.4 → 2.1.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.
Files changed (66) hide show
  1. package/CHANGELOG.md +305 -0
  2. package/HTML-VS-REACT.md +289 -0
  3. package/QUICKSTART-REACT.md +293 -0
  4. package/REACT-SUPPORT-SUMMARY.md +235 -0
  5. package/README.md +193 -12
  6. package/bin/cli.js +98 -759
  7. package/bin/commands/create.js +272 -0
  8. package/bin/commands/gallery.js +42 -0
  9. package/bin/commands/insert.js +123 -0
  10. package/bin/commands/list.js +73 -0
  11. package/package.json +10 -3
  12. package/src/component-choices.js +7 -0
  13. package/src/components-registry.js +112 -0
  14. package/src/format-utils.js +49 -0
  15. package/src/generator.js +83 -594
  16. package/src/generators/color-schemes.js +78 -0
  17. package/src/generators/color-utils.js +108 -0
  18. package/src/generators/component-filters.js +151 -0
  19. package/src/generators/html-generators.js +180 -0
  20. package/src/generators/validation.js +43 -0
  21. package/src/index.js +2 -1
  22. package/src/inserter.js +55 -233
  23. package/src/inserters/backup-utils.js +20 -0
  24. package/src/inserters/component-loader.js +68 -0
  25. package/src/inserters/html-utils.js +31 -0
  26. package/src/inserters/indentation-utils.js +90 -0
  27. package/src/inserters/validation-utils.js +49 -0
  28. package/src/react-component-choices.js +45 -0
  29. package/src/react-file-operations.js +172 -0
  30. package/src/react-generator.js +208 -0
  31. package/src/react-templates.js +350 -0
  32. package/src/utils/file-utils.js +97 -0
  33. package/src/utils/path-utils.js +32 -0
  34. package/src/utils/string-utils.js +51 -0
  35. package/src/utils/template-loader.js +91 -0
  36. package/templates/_shared/PATTERNS.md +246 -0
  37. package/templates/_shared/README.md +74 -0
  38. package/templates/_shared/base.css +18 -0
  39. package/templates/blackjack/index.html +1 -1
  40. package/templates/breakout/index.html +1 -1
  41. package/templates/connect-four/index.html +1 -1
  42. package/templates/dice-game/index.html +1 -1
  43. package/templates/flappy-bird/index.html +1 -1
  44. package/templates/pong/index.html +1 -1
  45. package/templates/skeleton/index.html +4 -4
  46. package/templates/slot-machine/index.html +1 -1
  47. package/templates/tetris/index.html +1 -1
  48. package/templates-react/README.md +126 -0
  49. package/templates-react/button/Button.css +88 -0
  50. package/templates-react/button/Button.example.jsx +40 -0
  51. package/templates-react/button/Button.jsx +29 -0
  52. package/templates-react/card/Card.css +86 -0
  53. package/templates-react/card/Card.example.jsx +49 -0
  54. package/templates-react/card/Card.jsx +35 -0
  55. package/templates-react/counter/Counter.css +99 -0
  56. package/templates-react/counter/Counter.example.jsx +45 -0
  57. package/templates-react/counter/Counter.jsx +70 -0
  58. package/templates-react/form/Form.css +128 -0
  59. package/templates-react/form/Form.example.jsx +65 -0
  60. package/templates-react/form/Form.jsx +125 -0
  61. package/templates-react/modal/Modal.css +152 -0
  62. package/templates-react/modal/Modal.example.jsx +90 -0
  63. package/templates-react/modal/Modal.jsx +46 -0
  64. package/templates-react/todo-list/TodoList.css +236 -0
  65. package/templates-react/todo-list/TodoList.example.jsx +15 -0
  66. package/templates-react/todo-list/TodoList.jsx +84 -0
@@ -0,0 +1,84 @@
1
+ import React, { useState } from 'react';
2
+ import './TodoList.css';
3
+
4
+ /**
5
+ * TodoList Component
6
+ * A complete todo list with add, toggle, and delete functionality
7
+ */
8
+ const TodoList = () => {
9
+ const [todos, setTodos] = useState([]);
10
+ const [inputValue, setInputValue] = useState('');
11
+
12
+ const addTodo = (e) => {
13
+ e.preventDefault();
14
+ if (inputValue.trim()) {
15
+ setTodos([...todos, {
16
+ id: Date.now(),
17
+ text: inputValue.trim(),
18
+ completed: false
19
+ }]);
20
+ setInputValue('');
21
+ }
22
+ };
23
+
24
+ const toggleTodo = (id) => {
25
+ setTodos(todos.map(todo =>
26
+ todo.id === id ? { ...todo, completed: !todo.completed } : todo
27
+ ));
28
+ };
29
+
30
+ const deleteTodo = (id) => {
31
+ setTodos(todos.filter(todo => todo.id !== id));
32
+ };
33
+
34
+ const activeCount = todos.filter(todo => !todo.completed).length;
35
+ const completedCount = todos.filter(todo => todo.completed).length;
36
+
37
+ return (
38
+ <div className="todo-container">
39
+ <h1 className="todo-title">Todo List</h1>
40
+
41
+ <form onSubmit={addTodo} className="todo-form">
42
+ <input
43
+ type="text"
44
+ value={inputValue}
45
+ onChange={(e) => setInputValue(e.target.value)}
46
+ placeholder="Add a new task..."
47
+ className="todo-input"
48
+ />
49
+ <button type="submit" className="todo-add-btn">Add</button>
50
+ </form>
51
+
52
+ <div className="todo-stats">
53
+ <span className="todo-stat">Active: {activeCount}</span>
54
+ <span className="todo-stat">Completed: {completedCount}</span>
55
+ </div>
56
+
57
+ <ul className="todo-list">
58
+ {todos.length === 0 ? (
59
+ <li className="todo-empty">No tasks yet. Add one above! 🎯</li>
60
+ ) : (
61
+ todos.map(todo => (
62
+ <li key={todo.id} className={`todo-item ${todo.completed ? 'completed' : ''}`}>
63
+ <div className="todo-content" onClick={() => toggleTodo(todo.id)}>
64
+ <div className="todo-checkbox">
65
+ {todo.completed && <span className="todo-checkmark">✓</span>}
66
+ </div>
67
+ <span className="todo-text">{todo.text}</span>
68
+ </div>
69
+ <button
70
+ onClick={() => deleteTodo(todo.id)}
71
+ className="todo-delete-btn"
72
+ aria-label="Delete task"
73
+ >
74
+ ×
75
+ </button>
76
+ </li>
77
+ ))
78
+ )}
79
+ </ul>
80
+ </div>
81
+ );
82
+ };
83
+
84
+ export default TodoList;