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.
- package/CHANGELOG.md +305 -0
- package/HTML-VS-REACT.md +289 -0
- package/QUICKSTART-REACT.md +293 -0
- package/REACT-SUPPORT-SUMMARY.md +235 -0
- package/README.md +193 -12
- package/bin/cli.js +98 -759
- package/bin/commands/create.js +272 -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 +45 -0
- package/src/react-file-operations.js +172 -0
- package/src/react-generator.js +208 -0
- package/src/react-templates.js +350 -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/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/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/form/Form.css +128 -0
- package/templates-react/form/Form.example.jsx +65 -0
- package/templates-react/form/Form.jsx +125 -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/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
|
@@ -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;
|