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,29 @@
1
+ import React from 'react';
2
+ import './Button.css';
3
+
4
+ /**
5
+ * Button Component
6
+ * A customizable button component with various styles and states
7
+ */
8
+ const Button = ({
9
+ children,
10
+ variant = 'primary',
11
+ size = 'medium',
12
+ disabled = false,
13
+ onClick,
14
+ type = 'button',
15
+ className = ''
16
+ }) => {
17
+ return (
18
+ <button
19
+ type={type}
20
+ className={`btn btn-${variant} btn-${size} ${className}`}
21
+ disabled={disabled}
22
+ onClick={onClick}
23
+ >
24
+ {children}
25
+ </button>
26
+ );
27
+ };
28
+
29
+ export default Button;
@@ -0,0 +1,86 @@
1
+ /* Card Styles */
2
+ .card {
3
+ background: white;
4
+ border-radius: 12px;
5
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
6
+ overflow: hidden;
7
+ transition: all 0.3s ease;
8
+ cursor: pointer;
9
+ max-width: 400px;
10
+ }
11
+
12
+ .card:hover {
13
+ transform: translateY(-5px);
14
+ box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
15
+ }
16
+
17
+ .card-image {
18
+ width: 100%;
19
+ height: 200px;
20
+ overflow: hidden;
21
+ position: relative;
22
+ }
23
+
24
+ .card-image img {
25
+ width: 100%;
26
+ height: 100%;
27
+ object-fit: cover;
28
+ transition: transform 0.3s ease;
29
+ }
30
+
31
+ .card:hover .card-image img {
32
+ transform: scale(1.05);
33
+ }
34
+
35
+ .card-content {
36
+ padding: 24px;
37
+ }
38
+
39
+ .card-title {
40
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
41
+ font-size: 24px;
42
+ font-weight: 700;
43
+ margin: 0 0 12px 0;
44
+ color: #2d3748;
45
+ background: linear-gradient(135deg, {{primaryColor}} 0%, {{secondaryColor}} 100%);
46
+ -webkit-background-clip: text;
47
+ -webkit-text-fill-color: transparent;
48
+ background-clip: text;
49
+ }
50
+
51
+ .card-description {
52
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
53
+ font-size: 16px;
54
+ line-height: 1.6;
55
+ color: #4a5568;
56
+ margin: 0;
57
+ }
58
+
59
+ .card-footer {
60
+ padding: 16px 24px;
61
+ border-top: 1px solid #e2e8f0;
62
+ background: #f7fafc;
63
+ display: flex;
64
+ justify-content: space-between;
65
+ align-items: center;
66
+ }
67
+
68
+ /* Dark Mode Support */
69
+ @media (prefers-color-scheme: dark) {
70
+ .card {
71
+ background: #2d3748;
72
+ }
73
+
74
+ .card-title {
75
+ color: #e2e8f0;
76
+ }
77
+
78
+ .card-description {
79
+ color: #cbd5e0;
80
+ }
81
+
82
+ .card-footer {
83
+ background: #1a202c;
84
+ border-top-color: #4a5568;
85
+ }
86
+ }
@@ -0,0 +1,49 @@
1
+ import React from 'react';
2
+ import Card from './Card';
3
+
4
+ /**
5
+ * Example usage of Card component
6
+ */
7
+ const CardExample = () => {
8
+ const handleCardClick = () => {
9
+ console.log('Card clicked!');
10
+ };
11
+
12
+ return (
13
+ <div style={{ padding: '40px', display: 'flex', gap: '20px', flexWrap: 'wrap' }}>
14
+ <Card
15
+ title="Beautiful Mountain"
16
+ description="Explore the breathtaking views of mountain landscapes and discover the beauty of nature."
17
+ image="https://images.unsplash.com/photo-1506905925346-21bda4d32df4?w=400&h=200&fit=crop"
18
+ imageAlt="Mountain landscape"
19
+ footer={
20
+ <button style={{ padding: '8px 16px', background: '#3182ce', color: 'white', border: 'none', borderRadius: '6px' }}>
21
+ Learn More
22
+ </button>
23
+ }
24
+ onClick={handleCardClick}
25
+ />
26
+
27
+ <Card
28
+ title="Ocean Sunset"
29
+ description="Watch the sun set over the endless horizon and feel the peaceful ocean breeze."
30
+ image="https://images.unsplash.com/photo-1505142468610-359e7d316be0?w=400&h=200&fit=crop"
31
+ imageAlt="Ocean sunset"
32
+ footer={
33
+ <button style={{ padding: '8px 16px', background: '#3182ce', color: 'white', border: 'none', borderRadius: '6px' }}>
34
+ Learn More
35
+ </button>
36
+ }
37
+ onClick={handleCardClick}
38
+ />
39
+
40
+ <Card
41
+ title="Card Without Image"
42
+ description="This card demonstrates how the component looks without an image. It still maintains the same elegant design."
43
+ footer={<span style={{ color: '#718096' }}>No image variant</span>}
44
+ />
45
+ </div>
46
+ );
47
+ };
48
+
49
+ export default CardExample;
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import './Card.css';
3
+
4
+ /**
5
+ * Card Component
6
+ * A versatile card component for displaying content
7
+ */
8
+ const Card = ({
9
+ title,
10
+ description,
11
+ image,
12
+ imageAlt = '',
13
+ footer,
14
+ onClick,
15
+ className = '',
16
+ children
17
+ }) => {
18
+ return (
19
+ <div className={`card ${className}`} onClick={onClick}>
20
+ {image && (
21
+ <div className="card-image">
22
+ <img src={image} alt={imageAlt} />
23
+ </div>
24
+ )}
25
+ <div className="card-content">
26
+ {title && <h3 className="card-title">{title}</h3>}
27
+ {description && <p className="card-description">{description}</p>}
28
+ {children}
29
+ </div>
30
+ {footer && <div className="card-footer">{footer}</div>}
31
+ </div>
32
+ );
33
+ };
34
+
35
+ export default Card;
@@ -0,0 +1,99 @@
1
+ /* Counter Styles */
2
+ .counter-container {
3
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
4
+ background: white;
5
+ padding: 40px;
6
+ border-radius: 20px;
7
+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
8
+ max-width: 400px;
9
+ margin: 0 auto;
10
+ text-align: center;
11
+ }
12
+
13
+ .counter-title {
14
+ font-size: 32px;
15
+ font-weight: 700;
16
+ margin: 0 0 30px 0;
17
+ background: linear-gradient(135deg, {{primaryColor}} 0%, {{secondaryColor}} 100%);
18
+ -webkit-background-clip: text;
19
+ -webkit-text-fill-color: transparent;
20
+ background-clip: text;
21
+ }
22
+
23
+ .counter-display {
24
+ font-size: 96px;
25
+ font-weight: 800;
26
+ background: linear-gradient(135deg, {{primaryColor}} 0%, {{secondaryColor}} 100%);
27
+ -webkit-background-clip: text;
28
+ -webkit-text-fill-color: transparent;
29
+ background-clip: text;
30
+ margin: 40px 0;
31
+ user-select: none;
32
+ animation: pulse 2s ease-in-out infinite;
33
+ }
34
+
35
+ @keyframes pulse {
36
+ 0%, 100% {
37
+ opacity: 1;
38
+ }
39
+ 50% {
40
+ opacity: 0.8;
41
+ }
42
+ }
43
+
44
+ .counter-controls {
45
+ display: flex;
46
+ gap: 12px;
47
+ justify-content: center;
48
+ }
49
+
50
+ .counter-btn {
51
+ font-family: inherit;
52
+ font-size: 32px;
53
+ font-weight: 700;
54
+ width: 80px;
55
+ height: 80px;
56
+ border: none;
57
+ border-radius: 50%;
58
+ cursor: pointer;
59
+ transition: all 0.3s ease;
60
+ outline: none;
61
+ box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
62
+ }
63
+
64
+ .counter-btn:hover:not(:disabled) {
65
+ transform: translateY(-3px);
66
+ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
67
+ }
68
+
69
+ .counter-btn:active:not(:disabled) {
70
+ transform: translateY(0);
71
+ }
72
+
73
+ .counter-btn:disabled {
74
+ opacity: 0.5;
75
+ cursor: not-allowed;
76
+ }
77
+
78
+ .counter-btn-increment {
79
+ background: linear-gradient(135deg, {{primaryColor}} 0%, {{secondaryColor}} 100%);
80
+ color: white;
81
+ }
82
+
83
+ .counter-btn-decrement {
84
+ background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
85
+ color: white;
86
+ }
87
+
88
+ .counter-btn-reset {
89
+ background: linear-gradient(135deg, #868e96 0%, #495057 100%);
90
+ color: white;
91
+ font-size: 16px;
92
+ }
93
+
94
+ /* Dark Mode Support */
95
+ @media (prefers-color-scheme: dark) {
96
+ .counter-container {
97
+ background: #2d3748;
98
+ }
99
+ }
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import Counter from './Counter';
3
+
4
+ /**
5
+ * Example usage of Counter component
6
+ */
7
+ const CounterExample = () => {
8
+ const handleChange = (value) => {
9
+ console.log('Counter value changed to:', value);
10
+ };
11
+
12
+ return (
13
+ <div style={{ padding: '40px' }}>
14
+ <h2 style={{ marginBottom: '40px', textAlign: 'center' }}>Counter Component Examples</h2>
15
+
16
+ <div style={{ display: 'grid', gap: '40px', gridTemplateColumns: 'repeat(auto-fit, minmax(400px, 1fr))' }}>
17
+ <div>
18
+ <h3 style={{ textAlign: 'center' }}>Basic Counter</h3>
19
+ <Counter onChange={handleChange} />
20
+ </div>
21
+
22
+ <div>
23
+ <h3 style={{ textAlign: 'center' }}>Counter with Limits</h3>
24
+ <Counter
25
+ initialValue={5}
26
+ min={0}
27
+ max={10}
28
+ onChange={handleChange}
29
+ />
30
+ </div>
31
+
32
+ <div>
33
+ <h3 style={{ textAlign: 'center' }}>Counter with Custom Step</h3>
34
+ <Counter
35
+ initialValue={0}
36
+ step={5}
37
+ onChange={handleChange}
38
+ />
39
+ </div>
40
+ </div>
41
+ </div>
42
+ );
43
+ };
44
+
45
+ export default CounterExample;
@@ -0,0 +1,70 @@
1
+ import React, { useState } from 'react';
2
+ import './Counter.css';
3
+
4
+ /**
5
+ * Counter Component
6
+ * A simple counter with increment and decrement functionality
7
+ */
8
+ const Counter = ({
9
+ initialValue = 0,
10
+ min,
11
+ max,
12
+ step = 1,
13
+ onChange
14
+ }) => {
15
+ const [count, setCount] = useState(initialValue);
16
+
17
+ const handleIncrement = () => {
18
+ const newValue = count + step;
19
+ if (max === undefined || newValue <= max) {
20
+ setCount(newValue);
21
+ onChange?.(newValue);
22
+ }
23
+ };
24
+
25
+ const handleDecrement = () => {
26
+ const newValue = count - step;
27
+ if (min === undefined || newValue >= min) {
28
+ setCount(newValue);
29
+ onChange?.(newValue);
30
+ }
31
+ };
32
+
33
+ const handleReset = () => {
34
+ setCount(initialValue);
35
+ onChange?.(initialValue);
36
+ };
37
+
38
+ return (
39
+ <div className="counter-container">
40
+ <h2 className="counter-title">Counter</h2>
41
+ <div className="counter-display">
42
+ {count}
43
+ </div>
44
+ <div className="counter-controls">
45
+ <button
46
+ className="counter-btn counter-btn-decrement"
47
+ onClick={handleDecrement}
48
+ disabled={min !== undefined && count <= min}
49
+ >
50
+ -
51
+ </button>
52
+ <button
53
+ className="counter-btn counter-btn-reset"
54
+ onClick={handleReset}
55
+ >
56
+ Reset
57
+ </button>
58
+ <button
59
+ className="counter-btn counter-btn-increment"
60
+ onClick={handleIncrement}
61
+ disabled={max !== undefined && count >= max}
62
+ >
63
+ +
64
+ </button>
65
+ </div>
66
+ </div>
67
+ );
68
+ };
69
+
70
+ export default Counter;
@@ -0,0 +1,128 @@
1
+ /* Form Styles */
2
+ .form-container {
3
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
4
+ background: white;
5
+ padding: 40px;
6
+ border-radius: 20px;
7
+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
8
+ max-width: 500px;
9
+ margin: 0 auto;
10
+ }
11
+
12
+ .form-title {
13
+ font-size: 32px;
14
+ font-weight: 700;
15
+ margin: 0 0 30px 0;
16
+ text-align: center;
17
+ background: linear-gradient(135deg, {{primaryColor}} 0%, {{secondaryColor}} 100%);
18
+ -webkit-background-clip: text;
19
+ -webkit-text-fill-color: transparent;
20
+ background-clip: text;
21
+ }
22
+
23
+ .form {
24
+ display: flex;
25
+ flex-direction: column;
26
+ gap: 20px;
27
+ }
28
+
29
+ .form-group {
30
+ display: flex;
31
+ flex-direction: column;
32
+ gap: 8px;
33
+ }
34
+
35
+ .form-label {
36
+ font-size: 14px;
37
+ font-weight: 600;
38
+ color: #2d3748;
39
+ display: flex;
40
+ align-items: center;
41
+ gap: 4px;
42
+ }
43
+
44
+ .required {
45
+ color: #e53e3e;
46
+ }
47
+
48
+ .form input,
49
+ .form textarea,
50
+ .form select {
51
+ padding: 12px 16px;
52
+ font-size: 16px;
53
+ font-family: inherit;
54
+ border: 2px solid #e2e8f0;
55
+ border-radius: 8px;
56
+ transition: all 0.3s ease;
57
+ outline: none;
58
+ background: white;
59
+ }
60
+
61
+ .form input:focus,
62
+ .form textarea:focus,
63
+ .form select:focus {
64
+ border-color: {{primaryColor}};
65
+ box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
66
+ }
67
+
68
+ .form textarea {
69
+ resize: vertical;
70
+ min-height: 100px;
71
+ }
72
+
73
+ .form-error {
74
+ font-size: 14px;
75
+ color: #e53e3e;
76
+ display: flex;
77
+ align-items: center;
78
+ gap: 4px;
79
+ }
80
+
81
+ .form-submit {
82
+ margin-top: 10px;
83
+ padding: 16px 32px;
84
+ font-size: 16px;
85
+ font-weight: 600;
86
+ font-family: inherit;
87
+ background: linear-gradient(135deg, {{primaryColor}} 0%, {{secondaryColor}} 100%);
88
+ color: white;
89
+ border: none;
90
+ border-radius: 8px;
91
+ cursor: pointer;
92
+ transition: all 0.3s ease;
93
+ box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
94
+ }
95
+
96
+ .form-submit:hover {
97
+ transform: translateY(-2px);
98
+ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
99
+ }
100
+
101
+ .form-submit:active {
102
+ transform: translateY(0);
103
+ }
104
+
105
+ /* Dark Mode Support */
106
+ @media (prefers-color-scheme: dark) {
107
+ .form-container {
108
+ background: #2d3748;
109
+ }
110
+
111
+ .form-label {
112
+ color: #e2e8f0;
113
+ }
114
+
115
+ .form input,
116
+ .form textarea,
117
+ .form select {
118
+ background: #1a202c;
119
+ color: #e2e8f0;
120
+ border-color: #4a5568;
121
+ }
122
+
123
+ .form input:focus,
124
+ .form textarea:focus,
125
+ .form select:focus {
126
+ border-color: {{primaryColor}};
127
+ }
128
+ }
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import Form from './Form';
3
+
4
+ /**
5
+ * Example usage of Form component
6
+ */
7
+ const FormExample = () => {
8
+ const contactFields = [
9
+ {
10
+ name: 'name',
11
+ label: 'Full Name',
12
+ type: 'text',
13
+ required: true,
14
+ placeholder: 'John Doe',
15
+ minLength: 2
16
+ },
17
+ {
18
+ name: 'email',
19
+ label: 'Email Address',
20
+ type: 'email',
21
+ required: true,
22
+ placeholder: 'john@example.com',
23
+ pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
24
+ errorMessage: 'Please enter a valid email address'
25
+ },
26
+ {
27
+ name: 'subject',
28
+ label: 'Subject',
29
+ type: 'select',
30
+ required: true,
31
+ options: [
32
+ { value: 'general', label: 'General Inquiry' },
33
+ { value: 'support', label: 'Technical Support' },
34
+ { value: 'feedback', label: 'Feedback' }
35
+ ]
36
+ },
37
+ {
38
+ name: 'message',
39
+ label: 'Message',
40
+ type: 'textarea',
41
+ required: true,
42
+ placeholder: 'Type your message here...',
43
+ rows: 6,
44
+ minLength: 10
45
+ }
46
+ ];
47
+
48
+ const handleSubmit = (data) => {
49
+ console.log('Form submitted with data:', data);
50
+ alert('Form submitted successfully! Check console for details.');
51
+ };
52
+
53
+ return (
54
+ <div style={{ padding: '40px', maxWidth: '600px', margin: '0 auto' }}>
55
+ <Form
56
+ title="Contact Us"
57
+ fields={contactFields}
58
+ onSubmit={handleSubmit}
59
+ submitButtonText="Send Message"
60
+ />
61
+ </div>
62
+ );
63
+ };
64
+
65
+ export default FormExample;