Mousco commited on
Commit
d9be66f
·
verified ·
1 Parent(s): d05efe6

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +732 -18
index.html CHANGED
@@ -1,19 +1,733 @@
1
- <!doctype html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Générateur de Code IA | Interface Moderne</title>
7
+
8
+ <!-- Importation de polices modernes et d'icônes -->
9
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&family=Fira+Code:wght@400;500&display=swap" rel="stylesheet">
10
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
11
+
12
+ <style>
13
+ :root {
14
+ --primary: #3b82f6;
15
+ --primary-hover: #2563eb;
16
+ --secondary: #10b981;
17
+ --bg-dark: #0f172a;
18
+ --bg-card: #1e293b;
19
+ --bg-input: #334155;
20
+ --text-main: #f8fafc;
21
+ --text-muted: #94a3b8;
22
+ --border: #334155;
23
+ --code-bg: #0d1117;
24
+ --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
25
+ }
26
+
27
+ * {
28
+ box-sizing: border-box;
29
+ margin: 0;
30
+ padding: 0;
31
+ }
32
+
33
+ body {
34
+ font-family: 'Inter', sans-serif;
35
+ background-color: var(--bg-dark);
36
+ color: var(--text-main);
37
+ line-height: 1.6;
38
+ min-height: 100vh;
39
+ display: flex;
40
+ flex-direction: column;
41
+ }
42
+
43
+ /* Header */
44
+ header {
45
+ background: rgba(30, 41, 59, 0.8);
46
+ backdrop-filter: blur(10px);
47
+ border-bottom: 1px solid var(--border);
48
+ padding: 1rem 2rem;
49
+ display: flex;
50
+ justify-content: space-between;
51
+ align-items: center;
52
+ position: sticky;
53
+ top: 0;
54
+ z-index: 100;
55
+ }
56
+
57
+ .logo {
58
+ font-size: 1.25rem;
59
+ font-weight: 700;
60
+ display: flex;
61
+ align-items: center;
62
+ gap: 10px;
63
+ color: var(--primary);
64
+ }
65
+
66
+ .logo i {
67
+ font-size: 1.5rem;
68
+ }
69
+
70
+ .anycoder-link {
71
+ font-size: 0.875rem;
72
+ color: var(--text-muted);
73
+ text-decoration: none;
74
+ transition: color 0.3s;
75
+ border: 1px solid var(--border);
76
+ padding: 5px 12px;
77
+ border-radius: 20px;
78
+ }
79
+
80
+ .anycoder-link:hover {
81
+ color: var(--primary);
82
+ border-color: var(--primary);
83
+ }
84
+
85
+ /* Main Container */
86
+ main {
87
+ flex: 1;
88
+ max-width: 1200px;
89
+ width: 100%;
90
+ margin: 0 auto;
91
+ padding: 2rem;
92
+ display: grid;
93
+ grid-template-columns: 1fr;
94
+ gap: 2rem;
95
+ }
96
+
97
+ @media (min-width: 900px) {
98
+ main {
99
+ grid-template-columns: 350px 1fr;
100
+ align-items: start;
101
+ }
102
+ }
103
+
104
+ /* Input Section */
105
+ .input-section {
106
+ background: var(--bg-card);
107
+ padding: 1.5rem;
108
+ border-radius: 16px;
109
+ border: 1px solid var(--border);
110
+ box-shadow: var(--shadow);
111
+ position: relative;
112
+ overflow: hidden;
113
+ }
114
+
115
+ .input-section h2 {
116
+ font-size: 1.1rem;
117
+ margin-bottom: 1rem;
118
+ color: var(--text-main);
119
+ display: flex;
120
+ align-items: center;
121
+ gap: 8px;
122
+ }
123
+
124
+ .form-group {
125
+ margin-bottom: 1.5rem;
126
+ }
127
+
128
+ label {
129
+ display: block;
130
+ margin-bottom: 0.5rem;
131
+ font-size: 0.9rem;
132
+ color: var(--text-muted);
133
+ }
134
+
135
+ textarea {
136
+ width: 100%;
137
+ height: 120px;
138
+ background: var(--bg-input);
139
+ border: 2px solid transparent;
140
+ border-radius: 8px;
141
+ padding: 12px;
142
+ color: var(--text-main);
143
+ font-family: 'Inter', sans-serif;
144
+ font-size: 1rem;
145
+ resize: vertical;
146
+ transition: all 0.3s ease;
147
+ }
148
+
149
+ textarea:focus {
150
+ outline: none;
151
+ border-color: var(--primary);
152
+ background: #1e293b;
153
+ }
154
+
155
+ .btn-generate {
156
+ width: 100%;
157
+ padding: 14px;
158
+ background: linear-gradient(135deg, var(--primary), var(--primary-hover));
159
+ color: white;
160
+ border: none;
161
+ border-radius: 8px;
162
+ font-size: 1rem;
163
+ font-weight: 600;
164
+ cursor: pointer;
165
+ transition: transform 0.2s, box-shadow 0.2s;
166
+ display: flex;
167
+ justify-content: center;
168
+ align-items: center;
169
+ gap: 8px;
170
+ }
171
+
172
+ .btn-generate:hover {
173
+ transform: translateY(-2px);
174
+ box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
175
+ }
176
+
177
+ .btn-generate:active {
178
+ transform: translateY(0);
179
+ }
180
+
181
+ /* Suggestions Chips */
182
+ .suggestions {
183
+ display: flex;
184
+ flex-wrap: wrap;
185
+ gap: 8px;
186
+ margin-top: 1rem;
187
+ }
188
+
189
+ .chip {
190
+ background: rgba(59, 130, 246, 0.1);
191
+ color: var(--primary);
192
+ padding: 6px 12px;
193
+ border-radius: 20px;
194
+ font-size: 0.8rem;
195
+ cursor: pointer;
196
+ transition: background 0.2s;
197
+ border: 1px solid rgba(59, 130, 246, 0.2);
198
+ }
199
+
200
+ .chip:hover {
201
+ background: rgba(59, 130, 246, 0.2);
202
+ }
203
+
204
+ /* Output Section */
205
+ .output-section {
206
+ display: flex;
207
+ flex-direction: column;
208
+ gap: 1.5rem;
209
+ }
210
+
211
+ .tabs {
212
+ display: flex;
213
+ gap: 1rem;
214
+ border-bottom: 1px solid var(--border);
215
+ padding-bottom: 1px;
216
+ }
217
+
218
+ .tab {
219
+ background: none;
220
+ border: none;
221
+ color: var(--text-muted);
222
+ padding: 8px 16px;
223
+ cursor: pointer;
224
+ font-size: 0.95rem;
225
+ font-weight: 500;
226
+ position: relative;
227
+ transition: color 0.3s;
228
+ }
229
+
230
+ .tab.active {
231
+ color: var(--primary);
232
+ }
233
+
234
+ .tab.active::after {
235
+ content: '';
236
+ position: absolute;
237
+ bottom: -2px;
238
+ left: 0;
239
+ width: 100%;
240
+ height: 2px;
241
+ background: var(--primary);
242
+ }
243
+
244
+ .panel {
245
+ display: none;
246
+ background: var(--bg-card);
247
+ border-radius: 12px;
248
+ border: 1px solid var(--border);
249
+ overflow: hidden;
250
+ animation: fadeIn 0.3s ease;
251
+ }
252
+
253
+ .panel.active {
254
+ display: block;
255
+ }
256
+
257
+ @keyframes fadeIn {
258
+ from { opacity: 0; transform: translateY(5px); }
259
+ to { opacity: 1; transform: translateY(0); }
260
+ }
261
+
262
+ /* Code Viewer */
263
+ .code-container {
264
+ position: relative;
265
+ background: var(--code-bg);
266
+ }
267
+
268
+ .code-header {
269
+ display: flex;
270
+ justify-content: space-between;
271
+ align-items: center;
272
+ padding: 8px 16px;
273
+ background: #161b22;
274
+ border-bottom: 1px solid #30363d;
275
+ }
276
+
277
+ .lang-label {
278
+ font-size: 0.8rem;
279
+ color: var(--text-muted);
280
+ font-family: 'Fira Code', monospace;
281
+ }
282
+
283
+ .btn-copy {
284
+ background: transparent;
285
+ border: 1px solid var(--border);
286
+ color: var(--text-muted);
287
+ padding: 4px 10px;
288
+ border-radius: 4px;
289
+ font-size: 0.8rem;
290
+ cursor: pointer;
291
+ transition: all 0.2s;
292
+ display: flex;
293
+ align-items: center;
294
+ gap: 5px;
295
+ }
296
+
297
+ .btn-copy:hover {
298
+ color: var(--text-main);
299
+ border-color: var(--text-muted);
300
+ }
301
+
302
+ pre {
303
+ margin: 0;
304
+ padding: 1.5rem;
305
+ overflow-x: auto;
306
+ color: #e6edf3;
307
+ font-family: 'Fira Code', monospace;
308
+ font-size: 0.9rem;
309
+ white-space: pre-wrap;
310
+ }
311
+
312
+ /* Iframe Preview */
313
+ .preview-container {
314
+ width: 100%;
315
+ height: 400px;
316
+ background: white;
317
+ border: none;
318
+ }
319
+
320
+ /* Explanation */
321
+ .explanation-content {
322
+ padding: 1.5rem;
323
+ }
324
+
325
+ .explanation-content h4 {
326
+ color: var(--primary);
327
+ margin-bottom: 1rem;
328
+ }
329
+
330
+ .explanation-content ul {
331
+ padding-left: 1.5rem;
332
+ color: var(--text-muted);
333
+ }
334
+
335
+ .explanation-content li {
336
+ margin-bottom: 0.5rem;
337
+ }
338
+
339
+ /* Footer */
340
+ footer {
341
+ text-align: center;
342
+ padding: 2rem;
343
+ color: var(--text-muted);
344
+ font-size: 0.9rem;
345
+ margin-top: auto;
346
+ }
347
+
348
+ /* Utility for syntax highlighting simulation */
349
+ .tag { color: #7ee787; }
350
+ .attr { color: #79c0ff; }
351
+ .val { color: #a5d6ff; }
352
+ .keyword { color: #ff7b72; }
353
+ .func { color: #d2a8ff; }
354
+
355
+ </style>
356
+ </head>
357
+ <body>
358
+
359
+ <header>
360
+ <div class="logo">
361
+ <i class="fa-solid fa-code"></i>
362
+ <span>SimpleGen AI</span>
363
+ </div>
364
+ <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link">
365
+ Built with anycoder
366
+ </a>
367
+ </header>
368
+
369
+ <main>
370
+ <!-- Input Section -->
371
+ <section class="input-section">
372
+ <h2><i class="fa-solid fa-wand-magic-sparkles"></i> Configuration</h2>
373
+ <div class="form-group">
374
+ <label for="prompt">Décrivez votre application :</label>
375
+ <textarea id="prompt" placeholder="Ex: une calculatrice simple, un compte à rebours, une liste de tâches..."></textarea>
376
+ </div>
377
+
378
+ <button class="btn-generate" onclick="generate()">
379
+ <i class="fa-solid fa-bolt"></i> Générer le code
380
+ </button>
381
+
382
+ <div class="suggestions">
383
+ <span class="chip" onclick="setPrompt('compteur')">Compteur</span>
384
+ <span class="chip" onclick="setPrompt('calculatrice')">Calculatrice</span>
385
+ <span class="chip" onclick="setPrompt('liste de tâches')">To-Do List</span>
386
+ <span class="chip" onclick="setPrompt('générateur de couleur')">Couleurs</span>
387
+ <span class="chip" onclick="setPrompt('minuteur')">Minuteur</span>
388
+ </div>
389
+ </section>
390
+
391
+ <!-- Output Section -->
392
+ <section class="output-section">
393
+ <div class="tabs">
394
+ <button class="tab active" onclick="switchTab('preview')"><i class="fa-solid fa-eye"></i> Aperçu</button>
395
+ <button class="tab" onclick="switchTab('code')"><i class="fa-solid fa-file-code"></i> Code Source</button>
396
+ <button class="tab" onclick="switchTab('explain')"><i class="fa-solid fa-book-open"></i> Explications</button>
397
+ </div>
398
+
399
+ <!-- Tab: Preview -->
400
+ <div id="panel-preview" class="panel active">
401
+ <div class="code-header">
402
+ <span class="lang-label">Live Render</span>
403
+ </div>
404
+ <iframe id="previewFrame" class="preview-container" title="Aperçu"></iframe>
405
+ </div>
406
+
407
+ <!-- Tab: Code -->
408
+ <div id="panel-code" class="panel">
409
+ <div class="code-container">
410
+ <div class="code-header">
411
+ <span class="lang-label">index.html</span>
412
+ <button class="btn-copy" onclick="copyCode()">
413
+ <i class="fa-regular fa-copy"></i> Copier
414
+ </button>
415
+ </div>
416
+ <pre id="code"></pre>
417
+ </div>
418
+ </div>
419
+
420
+ <!-- Tab: Explanation -->
421
+ <div id="panel-explain" class="panel">
422
+ <div class="explanation-content" id="explain">
423
+ <p style="color: var(--text-muted); font-style: italic;">Générez du code pour voir les explications détaillées ici.</p>
424
+ </div>
425
+ </div>
426
+ </section>
427
+ </main>
428
+
429
+ <footer>
430
+ <p>&copy; 2023 SimpleGen AI. Interface démonstrative en HTML/CSS/JS pur.</p>
431
+ </footer>
432
+
433
+ <script>
434
+ // --- Templates et Logique de Génération ---
435
+
436
+ const templates = {
437
+ counter: {
438
+ keywords: ['compteur', 'counter', 'incrémenter', 'compte'],
439
+ code: `<!DOCTYPE html>
440
  <html>
441
+ <head>
442
+ <style>
443
+ body { font-family: sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; background: #f0f2f5; }
444
+ .card { background: white; padding: 2rem; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); text-align: center; }
445
+ h1 { color: #333; }
446
+ #count { font-size: 4rem; font-weight: bold; color: #2563eb; margin: 20px 0; }
447
+ button { padding: 10px 20px; font-size: 1.2rem; cursor: pointer; border: none; border-radius: 6px; margin: 0 5px; transition: opacity 0.2s; }
448
+ .btn-inc { background: #2563eb; color: white; }
449
+ .btn-dec { background: #ef4444; color: white; }
450
+ button:hover { opacity: 0.9; }
451
+ </style>
452
+ </head>
453
+ <body>
454
+ <div class="card">
455
+ <h1>Compteur</h1>
456
+ <div id="count">0</div>
457
+ <button class="btn-dec" onclick="update(-1)">-</button>
458
+ <button class="btn-inc" onclick="update(1)">+</button>
459
+ </div>
460
+ <script>
461
+ let count = 0;
462
+ function update(val) {
463
+ count += val;
464
+ document.getElementById('count').innerText = count;
465
+ }
466
+ <\/script>
467
+ </body>
468
+ </html>`,
469
+ explanation: `
470
+ <h4><i class="fa-solid fa-list-ol"></i> Fonctionnement du Compteur</h4>
471
+ <ul>
472
+ <li><strong>Structure HTML :</strong> Une carte (div) centrée contenant le titre, l'affichage du nombre et deux boutons.</li>
473
+ <li><strong>Style CSS :</strong> Utilisation de Flexbox pour centrer le contenu verticalement et horizontalement. Les boutons ont des couleurs distinctes pour l'action positive (+) et négative (-).</li>
474
+ <li><strong>Logique JS :</strong> Une variable <code>count</code> stocke la valeur. La fonction <code>update(val)</code> modifie cette valeur et met à jour le texte de l'élément avec l'ID "count".</li>
475
+ </ul>
476
+ `
477
+ },
478
+ calculator: {
479
+ keywords: ['calculatrice', 'calcul', 'math', 'calculator'],
480
+ code: `<!DOCTYPE html>
481
+ <html>
482
+ <head>
483
+ <style>
484
+ body { font-family: 'Segoe UI', sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background: #222; }
485
+ .calc { background: #333; padding: 20px; border-radius: 15px; box-shadow: 0 10px 20px rgba(0,0,0,0.5); width: 260px; }
486
+ #display { width: 100%; height: 50px; background: #444; color: white; border: none; text-align: right; font-size: 24px; padding: 10px; border-radius: 5px; margin-bottom: 15px; box-sizing: border-box; }
487
+ .grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
488
+ button { padding: 15px; font-size: 18px; border: none; border-radius: 5px; cursor: pointer; background: #555; color: white; transition: 0.1s; }
489
+ button:hover { background: #666; }
490
+ .op { background: #f39c12; }
491
+ .eq { background: #27ae60; grid-column: span 2; }
492
+ .clr { background: #c0392b; }
493
+ </style>
494
+ </head>
495
+ <body>
496
+ <div class="calc">
497
+ <input type="text" id="display" readonly>
498
+ <div class="grid">
499
+ <button class="clr" onclick="clearD()">C</button>
500
+ <button class="op" onclick="append('/')">/</button>
501
+ <button class="op" onclick="append('*')">×</button>
502
+ <button onclick="append('7')">7</button>
503
+ <button onclick="append('8')">8</button>
504
+ <button onclick="append('9')">9</button>
505
+ <button class="op" onclick="append('-')">-</button>
506
+ <button onclick="append('4')">4</button>
507
+ <button onclick="append('5')">5</button>
508
+ <button onclick="append('6')">6</button>
509
+ <button class="op" onclick="append('+')">+</button>
510
+ <button onclick="append('1')">1</button>
511
+ <button onclick="append('2')">2</button>
512
+ <button onclick="append('3')">3</button>
513
+ <button class="eq" onclick="calc()">=</button>
514
+ <button onclick="append('0')">0</button>
515
+ <button onclick="append('.')">.</button>
516
+ </div>
517
+ </div>
518
+ <script>
519
+ const display = document.getElementById('display');
520
+ function append(v) { display.value += v; }
521
+ function clearD() { display.value = ''; }
522
+ function calc() {
523
+ try { display.value = eval(display.value); }
524
+ catch { display.value = 'Erreur'; }
525
+ }
526
+ <\/script>
527
+ </body>
528
+ </html>`,
529
+ explanation: `
530
+ <h4><i class="fa-solid fa-calculator"></i> Logique de la Calculatrice</h4>
531
+ <ul>
532
+ <li><strong>Affichage :</strong> Un champ input en lecture seule affiche la chaîne de calcul.</li>
533
+ <li><strong>Grille CSS :</strong> Le pavé numérique utilise CSS Grid pour aligner parfaitement les boutons.</li>
534
+ <li><strong>Fonctions JS :</strong>
535
+ <ul>
536
+ <li><code>append(v)</code> : Ajoute le chiffre ou l'opérateur à la chaîne.</li>
537
+ <li><code>clearD()</code> : Efface tout le contenu.</li>
538
+ <li><code>calc()</code> : Utilise <code>eval()</code> pour calculer le résultat mathématique de la chaîne (avec gestion d'erreur simple).</li>
539
+ </ul>
540
+ </li>
541
+ </ul>
542
+ `
543
+ },
544
+ todo: {
545
+ keywords: ['tâche', 'todo', 'liste', 'task'],
546
+ code: `<!DOCTYPE html>
547
+ <html>
548
+ <head>
549
+ <style>
550
+ body { font-family: sans-serif; background: #eef2f3; padding: 20px; }
551
+ .container { max-width: 400px; margin: 0 auto; background: white; padding: 20px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
552
+ h2 { text-align: center; color: #333; }
553
+ input[type="text"] { width: 70%; padding: 10px; border: 1px solid #ddd; border-radius: 5px; }
554
+ button { padding: 10px 15px; background: #28a745; color: white; border: none; border-radius: 5px; cursor: pointer; }
555
+ ul { list-style: none; padding: 0; }
556
+ li { background: #f9f9f9; margin: 8px 0; padding: 10px; display: flex; justify-content: space-between; align-items: center; border-radius: 5px; }
557
+ li.done span { text-decoration: line-through; color: #888; }
558
+ .del-btn { background: #dc3545; padding: 5px 10px; font-size: 12px; }
559
+ </style>
560
+ </head>
561
+ <body>
562
+ <div class="container">
563
+ <h2>Ma Liste</h2>
564
+ <div style="display:flex; gap:5px; margin-bottom: 20px;">
565
+ <input type="text" id="taskInput" placeholder="Nouvelle tâche...">
566
+ <button onclick="add()">Ajouter</button>
567
+ </div>
568
+ <ul id="list"></ul>
569
+ </div>
570
+ <script>
571
+ function add() {
572
+ const txt = document.getElementById('taskInput').value;
573
+ if(!txt) return;
574
+
575
+ const li = document.createElement('li');
576
+ li.innerHTML = '<span onclick="this.parentElement.classList.toggle(\\'done\\')">' + txt + '</span> <button class="del-btn" onclick="this.parentElement.remove()">X</button>';
577
+ document.getElementById('list').appendChild(li);
578
+ document.getElementById('taskInput').value = '';
579
+ }
580
+ <\/script>
581
+ </body>
582
+ </html>`,
583
+ explanation: `
584
+ <h4><i class="fa-solid fa-check-square"></i> Gestion de Liste de Tâches</h4>
585
+ <ul>
586
+ <li><strong>Ajout dynamique :</strong> La fonction <code>add()</code> crée un nouvel élément <code>li</code> via <code>document.createElement</code> et l'ajoute à la liste <code>ul</code>.</li>
587
+ <li><strong>Interaction :</strong> Cliquer sur le texte de la tâche bascule la classe CSS <code>done</code>, qui applique un style barré via <code>text-decoration: line-through</code>.</li>
588
+ <li><strong>Suppression :</strong> Chaque tâche possède un bouton "X" qui appelle <code>this.parentElement.remove()</code> pour supprimer l'élément du DOM.</li>
589
+ </ul>
590
+ `
591
+ },
592
+ color: {
593
+ keywords: ['couleur', 'color', 'background', 'thème'],
594
+ code: `<!DOCTYPE html>
595
+ <html>
596
+ <head>
597
+ <style>
598
+ body { font-family: sans-serif; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; margin: 0; transition: background 0.5s; text-align: center; }
599
+ .card { background: rgba(255,255,255,0.9); padding: 30px; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }
600
+ h1 { margin-bottom: 20px; }
601
+ button { padding: 15px 30px; font-size: 18px; cursor: pointer; background: #333; color: white; border: none; border-radius: 50px; transition: transform 0.2s; }
602
+ button:hover { transform: scale(1.05); }
603
+ #hex { font-size: 24px; font-family: monospace; margin-top: 20px; color: #333; font-weight: bold; }
604
+ </style>
605
+ </head>
606
+ <body>
607
+ <div class="card">
608
+ <h1>Générateur de Couleur</h1>
609
+ <button onclick="changeColor()">Changer la couleur</button>
610
+ <div id="hex">#FFFFFF</div>
611
+ </div>
612
+ <script>
613
+ function changeColor() {
614
+ const randomColor = '#' + Math.floor(Math.random()*16777215).toString(16).padStart(6, '0');
615
+ document.body.style.background = randomColor;
616
+ document.getElementById('hex').innerText = randomColor.toUpperCase();
617
+
618
+ // Ajuster la couleur du texte si fond trop sombre (simplifié)
619
+ document.getElementById('hex').style.color = randomColor;
620
+ }
621
+ <\/script>
622
+ </body>
623
+ </html>`,
624
+ explanation: `
625
+ <h4><i class="fa-solid fa-palette"></i> Générateur Aléatoire</h4>
626
+ <ul>
627
+ <li><strong>Math.random :</strong> Génère un nombre hexadécimal aléatoire pour créer une couleur RGB.</li>
628
+ <li><strong>Manipulation du DOM :</strong> La fonction modifie directement le style <code>background</code> du <code>body</code> pour changer la couleur de toute la page.</li>
629
+ <li><strong>Interaction :</strong> Un bouton déclenche la fonction, offrant un retour visuel immédiat.</li>
630
+ </ul>
631
+ `
632
+ }
633
+ };
634
+
635
+ const defaultTemplate = {
636
+ code: `<!DOCTYPE html>
637
+ <html>
638
+ <head>
639
+ <style>
640
+ body { font-family: sans-serif; display: flex; justify-content: center; align-items: center; height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); margin: 0; }
641
+ .card { background: white; padding: 40px; border-radius: 12px; text-align: center; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
642
+ h1 { color: #333; margin-bottom: 10px; }
643
+ p { color: #666; }
644
+ </style>
645
+ </head>
646
+ <body>
647
+ <div class="card">
648
+ <h1>Hello World!</h1>
649
+ <p>Je n'ai pas compris votre demande, mais voici une belle carte par défaut.</p>
650
+ </div>
651
+ </body>
652
+ </html>`,
653
+ explanation: `<p>Aucun modèle spécifique n'a été détecté dans votre demande. Essayez des mots-clés comme "compteur", "calculatrice" ou "liste".</p>`
654
+ };
655
+
656
+ // --- Fonctions Principales ---
657
+
658
+ function setPrompt(text) {
659
+ const textarea = document.getElementById('prompt');
660
+ textarea.value = text;
661
+ textarea.focus();
662
+ generate();
663
+ }
664
+
665
+ function switchTab(tabName) {
666
+ // Mettre à jour les boutons
667
+ document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
668
+ const index = ['preview', 'code', 'explain'].indexOf(tabName);
669
+ document.querySelectorAll('.tab')[index].classList.add('active');
670
+
671
+ // Mettre à jour les panneaux
672
+ document.querySelectorAll('.panel').forEach(p => p.classList.remove('active'));
673
+ document.getElementById('panel-' + tabName).classList.add('active');
674
+ }
675
+
676
+ function generate() {
677
+ const prompt = document.getElementById('prompt').value.toLowerCase();
678
+ let result = defaultTemplate;
679
+ let found = false;
680
+
681
+ // Recherche simple de mots-clés
682
+ for (const key in templates) {
683
+ const t = templates[key];
684
+ if (t.keywords.some(k => prompt.includes(k))) {
685
+ result = t;
686
+ found = true;
687
+ break;
688
+ }
689
+ }
690
+
691
+ // Affichage du code brut
692
+ document.getElementById('code').textContent = result.code;
693
+
694
+ // Affichage des explications
695
+ document.getElementById('explain').innerHTML = result.explanation;
696
+
697
+ // Mise à jour de l'iframe (Preview)
698
+ const iframe = document.getElementById('previewFrame');
699
+ const doc = iframe.contentDocument || iframe.contentWindow.document;
700
+ doc.open();
701
+ doc.write(result.code);
702
+ doc.close();
703
+
704
+ // Switch automatique vers l'onglet preview si on vient de cliquer sur générer
705
+ switchTab('preview');
706
+ }
707
+
708
+ function copyCode() {
709
+ const codeText = document.getElementById('code').textContent;
710
+ navigator.clipboard.writeText(codeText).then(() => {
711
+ const btn = document.querySelector('.btn-copy');
712
+ const originalHTML = btn.innerHTML;
713
+ btn.innerHTML = '<i class="fa-solid fa-check"></i> Copié !';
714
+ btn.style.color = 'var(--secondary)';
715
+ btn.style.borderColor = 'var(--secondary)';
716
+
717
+ setTimeout(() => {
718
+ btn.innerHTML = originalHTML;
719
+ btn.style.color = '';
720
+ btn.style.borderColor = '';
721
+ }, 2000);
722
+ });
723
+ }
724
+
725
+ // Générer un "Hello World" au chargement initial
726
+ window.onload = function() {
727
+ document.getElementById('prompt').value = "";
728
+ // On peut pré-remplir ou laisser vide. Laissons vide pour inviter à l'action.
729
+ };
730
+
731
+ </script>
732
+ </body>
733
+ </html>