create-template-html-css 2.1.0 → 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.
Files changed (53) hide show
  1. package/CHANGELOG.md +131 -0
  2. package/CODE-SPLITTING-GUIDE.md +274 -0
  3. package/COMPONENTS-GALLERY.html +143 -8
  4. package/README.md +71 -3
  5. package/bin/cli.js +2 -0
  6. package/bin/commands/create.js +16 -0
  7. package/package.json +1 -1
  8. package/src/react-component-choices.js +53 -1
  9. package/src/react-component-templates.js +182 -0
  10. package/src/react-generator.js +15 -4
  11. package/src/react-templates.js +192 -124
  12. package/src/templates/basic-components-templates.js +157 -0
  13. package/src/templates/form-components-templates.js +194 -0
  14. package/src/templates/interactive-components-templates.js +139 -0
  15. package/templates-react/alert/Alert.css +158 -0
  16. package/templates-react/alert/Alert.example.jsx +106 -0
  17. package/templates-react/alert/Alert.jsx +61 -0
  18. package/templates-react/badge/Badge.css +196 -0
  19. package/templates-react/badge/Badge.example.jsx +182 -0
  20. package/templates-react/badge/Badge.jsx +44 -0
  21. package/templates-react/button/Button.example.jsx +1 -1
  22. package/templates-react/button/Button.jsx +1 -1
  23. package/templates-react/card/Card.example.jsx +1 -1
  24. package/templates-react/card/Card.jsx +1 -1
  25. package/templates-react/checkbox/Checkbox.css +217 -0
  26. package/templates-react/checkbox/Checkbox.example.jsx +141 -0
  27. package/templates-react/checkbox/Checkbox.jsx +82 -0
  28. package/templates-react/counter/Counter.example.jsx +1 -1
  29. package/templates-react/counter/Counter.jsx +1 -1
  30. package/templates-react/dropdown/Dropdown.css +237 -0
  31. package/templates-react/dropdown/Dropdown.example.jsx +98 -0
  32. package/templates-react/dropdown/Dropdown.jsx +154 -0
  33. package/templates-react/form/Form.example.jsx +0 -1
  34. package/templates-react/form/Form.jsx +1 -1
  35. package/templates-react/input/Input.css +113 -0
  36. package/templates-react/input/Input.example.jsx +82 -0
  37. package/templates-react/input/Input.jsx +87 -0
  38. package/templates-react/modal/Modal.example.jsx +1 -1
  39. package/templates-react/modal/Modal.jsx +1 -1
  40. package/templates-react/navbar/Navbar.css +139 -0
  41. package/templates-react/navbar/Navbar.example.jsx +37 -0
  42. package/templates-react/navbar/Navbar.jsx +62 -0
  43. package/templates-react/progress/Progress.css +247 -0
  44. package/templates-react/progress/Progress.example.jsx +244 -0
  45. package/templates-react/progress/Progress.jsx +79 -0
  46. package/templates-react/switch/Switch.css +244 -0
  47. package/templates-react/switch/Switch.example.jsx +221 -0
  48. package/templates-react/switch/Switch.jsx +98 -0
  49. package/templates-react/todo-list/TodoList.example.jsx +1 -1
  50. package/templates-react/todo-list/TodoList.jsx +1 -1
  51. package/templates-react/tooltip/Tooltip.css +165 -0
  52. package/templates-react/tooltip/Tooltip.example.jsx +166 -0
  53. package/templates-react/tooltip/Tooltip.jsx +176 -0
@@ -0,0 +1,141 @@
1
+ import { useState } from 'react';
2
+ import Checkbox from './Checkbox';
3
+
4
+ function CheckboxExample() {
5
+ const [basicChecked, setBasicChecked] = useState(false);
6
+ const [termsAccepted, setTermsAccepted] = useState(false);
7
+ const [notifications, setNotifications] = useState({
8
+ email: true,
9
+ sms: false,
10
+ push: true
11
+ });
12
+ const [selectedColors, setSelectedColors] = useState([]);
13
+
14
+ const handleNotificationChange = (key) => (checked) => {
15
+ setNotifications(prev => ({ ...prev, [key]: checked }));
16
+ };
17
+
18
+ const handleColorToggle = (color) => (checked) => {
19
+ setSelectedColors(prev =>
20
+ checked
21
+ ? [...prev, color]
22
+ : prev.filter(c => c !== color)
23
+ );
24
+ };
25
+
26
+ return (
27
+ <div style={{ padding: '2rem', maxWidth: '600px', margin: '0 auto' }}>
28
+ <h1>Checkbox Component Examples</h1>
29
+
30
+ <section style={{ marginBottom: '2rem' }}>
31
+ <h2>Basic Checkbox</h2>
32
+ <Checkbox
33
+ label="I agree to the terms and conditions"
34
+ checked={basicChecked}
35
+ onChange={setBasicChecked}
36
+ />
37
+ <p>Status: {basicChecked ? 'Checked' : 'Unchecked'}</p>
38
+ </section>
39
+
40
+ <section style={{ marginBottom: '2rem' }}>
41
+ <h2>Different Sizes</h2>
42
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
43
+ <Checkbox label="Small checkbox" size="small" />
44
+ <Checkbox label="Medium checkbox (default)" size="medium" />
45
+ <Checkbox label="Large checkbox" size="large" />
46
+ </div>
47
+ </section>
48
+
49
+ <section style={{ marginBottom: '2rem' }}>
50
+ <h2>Different Colors</h2>
51
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
52
+ <Checkbox label="Primary color" checked color="primary" />
53
+ <Checkbox label="Secondary color" checked color="secondary" />
54
+ <Checkbox label="Success color" checked color="success" />
55
+ <Checkbox label="Error color" checked color="error" />
56
+ </div>
57
+ </section>
58
+
59
+ <section style={{ marginBottom: '2rem' }}>
60
+ <h2>With Helper Text</h2>
61
+ <Checkbox
62
+ label="Subscribe to newsletter"
63
+ helperText="You can unsubscribe at any time"
64
+ />
65
+ </section>
66
+
67
+ <section style={{ marginBottom: '2rem' }}>
68
+ <h2>Required Field with Error</h2>
69
+ <Checkbox
70
+ label="Accept terms and conditions"
71
+ checked={termsAccepted}
72
+ onChange={setTermsAccepted}
73
+ error={!termsAccepted ? 'You must accept the terms to continue' : ''}
74
+ />
75
+ </section>
76
+
77
+ <section style={{ marginBottom: '2rem' }}>
78
+ <h2>Disabled State</h2>
79
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
80
+ <Checkbox label="Disabled unchecked" disabled />
81
+ <Checkbox label="Disabled checked" checked disabled />
82
+ </div>
83
+ </section>
84
+
85
+ <section style={{ marginBottom: '2rem' }}>
86
+ <h2>Indeterminate State</h2>
87
+ <Checkbox
88
+ label="Select all notifications"
89
+ indeterminate={
90
+ notifications.email !== notifications.sms ||
91
+ notifications.sms !== notifications.push
92
+ }
93
+ checked={notifications.email && notifications.sms && notifications.push}
94
+ />
95
+ </section>
96
+
97
+ <section style={{ marginBottom: '2rem' }}>
98
+ <h2>Checkbox Group</h2>
99
+ <div style={{ marginLeft: '1.5rem' }}>
100
+ <h3 style={{ fontSize: '1rem', marginBottom: '0.5rem' }}>Notification Preferences</h3>
101
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
102
+ <Checkbox
103
+ label="Email notifications"
104
+ checked={notifications.email}
105
+ onChange={handleNotificationChange('email')}
106
+ />
107
+ <Checkbox
108
+ label="SMS notifications"
109
+ checked={notifications.sms}
110
+ onChange={handleNotificationChange('sms')}
111
+ />
112
+ <Checkbox
113
+ label="Push notifications"
114
+ checked={notifications.push}
115
+ onChange={handleNotificationChange('push')}
116
+ />
117
+ </div>
118
+ </div>
119
+ </section>
120
+
121
+ <section style={{ marginBottom: '2rem' }}>
122
+ <h2>Multiple Selection</h2>
123
+ <h3 style={{ fontSize: '1rem', marginBottom: '0.5rem' }}>Choose your favorite colors:</h3>
124
+ <div style={{ display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
125
+ {['Red', 'Blue', 'Green', 'Yellow'].map(color => (
126
+ <Checkbox
127
+ key={color}
128
+ label={color}
129
+ checked={selectedColors.includes(color)}
130
+ onChange={handleColorToggle(color)}
131
+ color={color === 'Red' ? 'error' : color === 'Green' ? 'success' : 'primary'}
132
+ />
133
+ ))}
134
+ </div>
135
+ <p>Selected: {selectedColors.join(', ') || 'None'}</p>
136
+ </section>
137
+ </div>
138
+ );
139
+ }
140
+
141
+ export default CheckboxExample;
@@ -0,0 +1,82 @@
1
+
2
+ import './Checkbox.css';
3
+ import { useState } from 'react';
4
+
5
+ function Checkbox({
6
+ label = '',
7
+ checked = false,
8
+ onChange,
9
+ disabled = false,
10
+ indeterminate = false,
11
+ name = '',
12
+ value = '',
13
+ error = '',
14
+ helperText = '',
15
+ size = 'medium',
16
+ color = 'primary'
17
+ }) {
18
+ const [isChecked, setIsChecked] = useState(checked);
19
+
20
+ const handleChange = (e) => {
21
+ const newValue = e.target.checked;
22
+ setIsChecked(newValue);
23
+ onChange?.(newValue, e);
24
+ };
25
+
26
+ const checkboxId = `checkbox-${name || Math.random().toString(36).substr(2, 9)}`;
27
+
28
+ return (
29
+ <div className={`checkbox-container ${error ? 'checkbox-error' : ''}`}>
30
+ <div className="checkbox-wrapper">
31
+ <div className={`checkbox-input-wrapper ${size}`}>
32
+ <input
33
+ id={checkboxId}
34
+ type="checkbox"
35
+ className={`checkbox-input ${color}`}
36
+ checked={isChecked}
37
+ onChange={handleChange}
38
+ disabled={disabled}
39
+ name={name}
40
+ value={value}
41
+ aria-invalid={!!error}
42
+ aria-describedby={error ? `${checkboxId}-error` : helperText ? `${checkboxId}-helper` : undefined}
43
+ />
44
+ <span
45
+ className={`checkbox-custom ${isChecked ? 'checked' : ''} ${indeterminate ? 'indeterminate' : ''}`}
46
+ aria-hidden="true"
47
+ >
48
+ {indeterminate && !isChecked ? (
49
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
50
+ <line x1="5" y1="12" x2="19" y2="12" strokeWidth="3" strokeLinecap="round"/>
51
+ </svg>
52
+ ) : isChecked ? (
53
+ <svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
54
+ <polyline points="20 6 9 17 4 12" strokeWidth="3" strokeLinecap="round" strokeLinejoin="round"/>
55
+ </svg>
56
+ ) : null}
57
+ </span>
58
+ </div>
59
+
60
+ {label && (
61
+ <label htmlFor={checkboxId} className="checkbox-label">
62
+ {label}
63
+ </label>
64
+ )}
65
+ </div>
66
+
67
+ {helperText && !error && (
68
+ <span id={`${checkboxId}-helper`} className="checkbox-helper-text">
69
+ {helperText}
70
+ </span>
71
+ )}
72
+
73
+ {error && (
74
+ <span id={`${checkboxId}-error`} className="checkbox-error-message">
75
+ {error}
76
+ </span>
77
+ )}
78
+ </div>
79
+ );
80
+ }
81
+
82
+ export default Checkbox;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+
2
2
  import Counter from './Counter';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import React, { useState } from 'react';
1
+ import { useState } from 'react';
2
2
  import './Counter.css';
3
3
 
4
4
  /**
@@ -0,0 +1,237 @@
1
+ .dropdown-container {
2
+ position: relative;
3
+ width: 100%;
4
+ margin-bottom: 1rem;
5
+ }
6
+
7
+ .dropdown-label {
8
+ display: block;
9
+ margin-bottom: 0.5rem;
10
+ font-weight: 500;
11
+ color: #374151;
12
+ font-size: 0.875rem;
13
+ }
14
+
15
+ .dropdown {
16
+ position: relative;
17
+ width: 100%;
18
+ }
19
+
20
+ .dropdown-toggle {
21
+ width: 100%;
22
+ padding: 0.625rem 2.5rem 0.625rem 0.875rem;
23
+ background-color: white;
24
+ border: 2px solid #d1d5db;
25
+ border-radius: 0.5rem;
26
+ font-size: 1rem;
27
+ text-align: left;
28
+ cursor: pointer;
29
+ transition: all 0.2s ease;
30
+ display: flex;
31
+ align-items: center;
32
+ justify-content: space-between;
33
+ position: relative;
34
+ }
35
+
36
+ .dropdown-toggle:hover:not(:disabled) {
37
+ border-color: ##PRIMARY_COLOR##;
38
+ }
39
+
40
+ .dropdown-toggle:focus {
41
+ outline: none;
42
+ border-color: ##PRIMARY_COLOR##;
43
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
44
+ }
45
+
46
+ .dropdown-toggle:disabled {
47
+ background-color: #f3f4f6;
48
+ cursor: not-allowed;
49
+ opacity: 0.6;
50
+ }
51
+
52
+ .dropdown.open .dropdown-toggle {
53
+ border-color: ##PRIMARY_COLOR##;
54
+ border-bottom-left-radius: 0;
55
+ border-bottom-right-radius: 0;
56
+ }
57
+
58
+ .dropdown-value {
59
+ flex: 1;
60
+ overflow: hidden;
61
+ text-overflow: ellipsis;
62
+ white-space: nowrap;
63
+ color: #111827;
64
+ }
65
+
66
+ .dropdown-toggle:disabled .dropdown-value {
67
+ color: #9ca3af;
68
+ }
69
+
70
+ .dropdown-arrow {
71
+ position: absolute;
72
+ right: 0.875rem;
73
+ top: 50%;
74
+ transform: translateY(-50%);
75
+ transition: transform 0.2s ease;
76
+ color: #6b7280;
77
+ font-size: 0.75rem;
78
+ }
79
+
80
+ .dropdown-arrow.up {
81
+ transform: translateY(-50%) rotate(180deg);
82
+ }
83
+
84
+ .dropdown-menu {
85
+ position: absolute;
86
+ top: 100%;
87
+ left: 0;
88
+ right: 0;
89
+ background-color: white;
90
+ border: 2px solid ##PRIMARY_COLOR##;
91
+ border-top: none;
92
+ border-radius: 0 0 0.5rem 0.5rem;
93
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
94
+ z-index: 1000;
95
+ overflow: hidden;
96
+ animation: slideDown 0.2s ease;
97
+ }
98
+
99
+ @keyframes slideDown {
100
+ from {
101
+ opacity: 0;
102
+ transform: translateY(-10px);
103
+ }
104
+ to {
105
+ opacity: 1;
106
+ transform: translateY(0);
107
+ }
108
+ }
109
+
110
+ .dropdown-search {
111
+ padding: 0.5rem;
112
+ border-bottom: 1px solid #e5e7eb;
113
+ }
114
+
115
+ .dropdown-search-input {
116
+ width: 100%;
117
+ padding: 0.5rem;
118
+ border: 1px solid #d1d5db;
119
+ border-radius: 0.375rem;
120
+ font-size: 0.875rem;
121
+ outline: none;
122
+ }
123
+
124
+ .dropdown-search-input:focus {
125
+ border-color: ##PRIMARY_COLOR##;
126
+ }
127
+
128
+ .dropdown-options {
129
+ list-style: none;
130
+ margin: 0;
131
+ padding: 0;
132
+ max-height: inherit;
133
+ overflow-y: auto;
134
+ }
135
+
136
+ .dropdown-option {
137
+ padding: 0.75rem 0.875rem;
138
+ cursor: pointer;
139
+ transition: background-color 0.15s ease;
140
+ color: #374151;
141
+ display: flex;
142
+ align-items: center;
143
+ gap: 0.5rem;
144
+ }
145
+
146
+ .dropdown-option:hover:not(.disabled) {
147
+ background-color: #f3f4f6;
148
+ }
149
+
150
+ .dropdown-option.selected {
151
+ background-color: ##PRIMARY_COLOR##;
152
+ color: white;
153
+ font-weight: 500;
154
+ }
155
+
156
+ .dropdown-option.disabled {
157
+ cursor: not-allowed;
158
+ color: #9ca3af;
159
+ font-style: italic;
160
+ }
161
+
162
+ .dropdown-checkbox {
163
+ width: 1rem;
164
+ height: 1rem;
165
+ cursor: pointer;
166
+ }
167
+
168
+ .dropdown-error .dropdown-toggle {
169
+ border-color: #ef4444;
170
+ }
171
+
172
+ .dropdown-error .dropdown-toggle:focus {
173
+ box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
174
+ }
175
+
176
+ .dropdown-error-message {
177
+ display: block;
178
+ margin-top: 0.375rem;
179
+ font-size: 0.875rem;
180
+ color: #ef4444;
181
+ }
182
+
183
+ /* Dark Mode Support */
184
+ @media (prefers-color-scheme: dark) {
185
+ .dropdown-label {
186
+ color: #e5e7eb;
187
+ }
188
+
189
+ .dropdown-toggle {
190
+ background-color: #1f2937;
191
+ border-color: #4b5563;
192
+ color: #e5e7eb;
193
+ }
194
+
195
+ .dropdown-toggle:hover:not(:disabled) {
196
+ border-color: ##SECONDARY_COLOR##;
197
+ }
198
+
199
+ .dropdown-toggle:disabled {
200
+ background-color: #111827;
201
+ }
202
+
203
+ .dropdown-value {
204
+ color: #e5e7eb;
205
+ }
206
+
207
+ .dropdown.open .dropdown-toggle {
208
+ border-color: ##SECONDARY_COLOR##;
209
+ }
210
+
211
+ .dropdown-menu {
212
+ background-color: #1f2937;
213
+ border-color: ##SECONDARY_COLOR##;
214
+ }
215
+
216
+ .dropdown-search {
217
+ border-bottom-color: #4b5563;
218
+ }
219
+
220
+ .dropdown-search-input {
221
+ background-color: #111827;
222
+ border-color: #4b5563;
223
+ color: #e5e7eb;
224
+ }
225
+
226
+ .dropdown-option {
227
+ color: #e5e7eb;
228
+ }
229
+
230
+ .dropdown-option:hover:not(.disabled) {
231
+ background-color: #374151;
232
+ }
233
+
234
+ .dropdown-option.selected {
235
+ background-color: ##SECONDARY_COLOR##;
236
+ }
237
+ }
@@ -0,0 +1,98 @@
1
+ import { useState } from 'react';
2
+ import Dropdown from './Dropdown';
3
+
4
+ function DropdownExample() {
5
+ const [selected, setSelected] = useState('');
6
+ const [searchableSelected, setSearchableSelected] = useState('');
7
+ const [multiSelected, setMultiSelected] = useState([]);
8
+
9
+ const simpleOptions = ['Apple', 'Banana', 'Cherry', 'Date', 'Elderberry'];
10
+
11
+ const complexOptions = [
12
+ { value: 'react', label: 'React' },
13
+ { value: 'vue', label: 'Vue.js' },
14
+ { value: 'angular', label: 'Angular' },
15
+ { value: 'svelte', label: 'Svelte' },
16
+ { value: 'next', label: 'Next.js' }
17
+ ];
18
+
19
+ const countries = [
20
+ { value: 'us', label: 'United States' },
21
+ { value: 'uk', label: 'United Kingdom' },
22
+ { value: 'ca', label: 'Canada' },
23
+ { value: 'au', label: 'Australia' },
24
+ { value: 'de', label: 'Germany' },
25
+ { value: 'fr', label: 'France' },
26
+ { value: 'jp', label: 'Japan' },
27
+ { value: 'cn', label: 'China' },
28
+ { value: 'in', label: 'India' },
29
+ { value: 'br', label: 'Brazil' }
30
+ ];
31
+
32
+ return (
33
+ <div style={{ padding: '2rem', maxWidth: '600px', margin: '0 auto' }}>
34
+ <h1>Dropdown Component Examples</h1>
35
+
36
+ <section style={{ marginBottom: '2rem' }}>
37
+ <h2>Basic Dropdown</h2>
38
+ <Dropdown
39
+ label="Choose a fruit"
40
+ options={simpleOptions}
41
+ value={selected}
42
+ onChange={setSelected}
43
+ placeholder="Select a fruit"
44
+ />
45
+ <p>Selected: {selected || 'None'}</p>
46
+ </section>
47
+
48
+ <section style={{ marginBottom: '2rem' }}>
49
+ <h2>Searchable Dropdown</h2>
50
+ <Dropdown
51
+ label="Select your country"
52
+ options={countries}
53
+ value={searchableSelected}
54
+ onChange={setSearchableSelected}
55
+ placeholder="Search and select..."
56
+ searchable
57
+ />
58
+ <p>Selected: {searchableSelected || 'None'}</p>
59
+ </section>
60
+
61
+ <section style={{ marginBottom: '2rem' }}>
62
+ <h2>Multiple Selection</h2>
63
+ <Dropdown
64
+ label="Choose frameworks"
65
+ options={complexOptions}
66
+ value={multiSelected}
67
+ onChange={setMultiSelected}
68
+ placeholder="Select frameworks"
69
+ multiple
70
+ searchable
71
+ />
72
+ <p>Selected: {multiSelected.join(', ') || 'None'}</p>
73
+ </section>
74
+
75
+ <section style={{ marginBottom: '2rem' }}>
76
+ <h2>Disabled Dropdown</h2>
77
+ <Dropdown
78
+ label="Disabled dropdown"
79
+ options={simpleOptions}
80
+ placeholder="Cannot select"
81
+ disabled
82
+ />
83
+ </section>
84
+
85
+ <section style={{ marginBottom: '2rem' }}>
86
+ <h2>With Error</h2>
87
+ <Dropdown
88
+ label="Required field"
89
+ options={simpleOptions}
90
+ placeholder="Please select"
91
+ error="This field is required"
92
+ />
93
+ </section>
94
+ </div>
95
+ );
96
+ }
97
+
98
+ export default DropdownExample;