Examups commited on
Commit
ee8225a
·
verified ·
1 Parent(s): db5638a

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +934 -19
index.html CHANGED
@@ -1,19 +1,934 @@
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
+
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Advanced Component Builder</title>
8
+ <script src="https://cdn.tailwindcss.com"></script>
9
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
10
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
11
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
12
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
13
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"></script>
14
+ <style>
15
+ :root {
16
+ --primary-color: #3b82f6;
17
+ --primary-hover-color: #2563eb;
18
+ --secondary-color: #10b981;
19
+ --secondary-hover-color: #059669;
20
+ --text-color: #374151;
21
+ --heading-color: #111827;
22
+ --font-family: 'Inter', sans-serif;
23
+ }
24
+
25
+ body {
26
+ font-family: var(--font-family);
27
+ color: var(--text-color);
28
+ background-color: var(--background-color);
29
+ }
30
+ h1, h2, h3, h4, h5, h6 {
31
+ color: var(--heading-color);
32
+ }
33
+ /* Custom scrollbar for webkit browsers */
34
+ ::-webkit-scrollbar {
35
+ width: 8px;
36
+ height: 8px;
37
+ }
38
+ ::-webkit-scrollbar-track {
39
+ background: #f1f1f1;
40
+ }
41
+ ::-webkit-scrollbar-thumb {
42
+ background: #888;
43
+ border-radius: 10px;
44
+ }
45
+ ::-webkit-scrollbar-thumb:hover {
46
+ background: #555;
47
+ }
48
+ .preview-iframe {
49
+ width: 100%;
50
+ height: 100%;
51
+ border: 0;
52
+ transition: all 0.3s ease-in-out;
53
+ }
54
+ #preview-container.preview-desktop .preview-iframe { width: 100%; }
55
+ #preview-container.preview-tablet .preview-iframe { width: 768px; margin: 0 auto; }
56
+ #preview-container.preview-mobile .preview-iframe { width: 375px; margin: 0 auto; }
57
+
58
+ .toast {
59
+ visibility: hidden;
60
+ min-width: 250px;
61
+ background-color: #333;
62
+ color: #fff;
63
+ text-align: center;
64
+ border-radius: 8px;
65
+ padding: 16px;
66
+ position: fixed;
67
+ z-index: 100;
68
+ left: 50%;
69
+ bottom: 30px;
70
+ transform: translateX(-50%);
71
+ opacity: 0;
72
+ transition: opacity 0.3s, visibility 0.3s;
73
+ }
74
+ .toast.show {
75
+ visibility: visible;
76
+ opacity: 1;
77
+ }
78
+
79
+ /* New Professional Controls UI Styles */
80
+ #controls-layout {
81
+ display: flex;
82
+ height: 100%;
83
+ }
84
+ #controls-nav {
85
+ width: 180px;
86
+ flex-shrink: 0;
87
+ background-color: #f8fafc;
88
+ border-right: 1px solid #e5e7eb;
89
+ padding: 0.5rem;
90
+ overflow-y: auto;
91
+ }
92
+ .control-nav-button {
93
+ display: flex;
94
+ align-items: center;
95
+ width: 100%;
96
+ padding: 0.75rem;
97
+ border-radius: 0.375rem;
98
+ font-weight: 500;
99
+ color: var(--text-color);
100
+ transition: background-color 0.2s, color 0.2s;
101
+ text-align: left;
102
+ }
103
+ .control-nav-button:hover {
104
+ background-color: #e5e7eb;
105
+ }
106
+ .control-nav-button.active {
107
+ background-color: var(--primary-color);
108
+ color: white;
109
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
110
+ }
111
+ .control-nav-button i {
112
+ margin-right: 0.75rem;
113
+ width: 20px;
114
+ text-align: center;
115
+ }
116
+ #controls-panels {
117
+ flex-grow: 1;
118
+ padding: 1.5rem;
119
+ overflow-y: auto;
120
+ }
121
+ .control-panel {
122
+ display: none;
123
+ }
124
+ .control-panel.active {
125
+ display: block;
126
+ }
127
+ .control-panel h3 {
128
+ font-size: 1.25rem;
129
+ font-weight: 600;
130
+ margin-bottom: 1.5rem;
131
+ border-bottom: 1px solid #e5e7eb;
132
+ padding-bottom: 0.75rem;
133
+ }
134
+ .nested-builder {
135
+ margin-left: 1rem;
136
+ padding-left: 1rem;
137
+ border-left: 2px solid #e5e7eb;
138
+ margin-top: 1rem;
139
+ padding-top: 1rem;
140
+ }
141
+ .item-toolbar {
142
+ display: flex;
143
+ justify-content: flex-end;
144
+ gap: 0.25rem;
145
+ margin-bottom: 0.5rem;
146
+ }
147
+ .item-toolbar button {
148
+ line-height: 1;
149
+ }
150
+ .layout-item {
151
+ cursor: move;
152
+ }
153
+ .code-modal-pre {
154
+ background-color: #2d3748;
155
+ color: #e2e8f0;
156
+ padding: 1rem;
157
+ border-radius: 0.375rem;
158
+ max-height: 200px;
159
+ overflow-y: auto;
160
+ position: relative;
161
+ }
162
+ /* Feature: Hide/Show Sidebar */
163
+ #controls-sidebar {
164
+ flex-shrink: 0;
165
+ }
166
+ #main-container.sidebar-collapsed #controls-sidebar {
167
+ width: 0;
168
+ padding: 0;
169
+ overflow: hidden;
170
+ }
171
+ #main-container.sidebar-collapsed #preview-main {
172
+ width: 100%;
173
+ }
174
+ </style>
175
+ </head>
176
+ <body class="text-gray-800">
177
+
178
+ <div id="app" class="flex flex-col h-screen">
179
+
180
+ <header class="bg-white shadow-md p-4 flex justify-between items-center z-20">
181
+ <div class="flex items-center space-x-3">
182
+ <h1 class="text-xl font-bold text-gray-700">Component Builder</h1>
183
+ <button id="toggle-sidebar-btn" class="p-2 rounded-md hover:bg-gray-200 text-gray-600" title="Hide Controls">
184
+ <i class="fas fa-chevron-left"></i>
185
+ </button>
186
+ </div>
187
+ <div class="flex items-center space-x-4">
188
+
189
+ <button id="import-btn" class="flex items-center space-x-2 bg-blue-600 text-white font-bold py-2 px-4 rounded-md hover:bg-blue-700 transition">
190
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
191
+ <path d="M10 2a1 1 0 00-1 1v5.586l-1.293-1.293a1 1 0 00-1.414 1.414l3 3a1 1 0 001.414 0l3-3a1 1 0 00-1.414-1.414L11 8.586V3a1 1 0 00-1-1z"></path>
192
+ <path d="M4 14a1 1 0 011 1v1a1 1 0 001 1h8a1 1 0 001-1v-1a1 1 0 112 0v1a3 3 0 01-3 3H6a3 3 0 01-3-3v-1a1 1 0 011-1z"></path>
193
+ </svg>
194
+ <span>Import</span>
195
+ </button>
196
+ <input type="file" id="import-file-input" class="hidden" accept=".html">
197
+
198
+ <div id="export-menu-container" class="relative">
199
+ <button id="export-menu-btn" class="flex items-center space-x-2 bg-green-600 text-white font-bold py-2 px-4 rounded-md hover:bg-green-700 transition">
200
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM6.293 6.707a1 1 0 010-1.414l3-3a1 1 0 011.414 0l3 3a1 1 0 01-1.414 1.414L11 5.414V13a1 1 0 11-2 0V5.414L7.707 6.707a1 1 0 01-1.414 0z" clip-rule="evenodd"></path></svg>
201
+ <span>Export Page</span>
202
+ </button>
203
+ <div id="export-dropdown" class="hidden absolute right-0 mt-2 w-64 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 z-30">
204
+ <div class="py-1" role="menu" aria-orientation="vertical" aria-labelledby="export-menu-btn">
205
+ <a href="#" id="copy-combined-code" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem">
206
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"></path></svg>
207
+ <span>Copy Combined Code</span>
208
+ </a>
209
+ <a href="#" id="copy-html" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem">
210
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path d="M5 5a2 2 0 012-2h10a2 2 0 012 2v1h-14V5zM3 8h18v10a2 2 0 01-2 2H5a2 2 0 01-2-2V8z"></path></svg>
211
+ <span>Copy Page HTML</span>
212
+ </a>
213
+ <a href="#" id="copy-css" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem">
214
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01"></path></svg>
215
+ <span>Copy Page CSS</span>
216
+ </a>
217
+ <a href="#" id="copy-js" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem">
218
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3 text-gray-500" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 2a1 1 0 011 1v1h1a1 1 0 010 2h-1v1a1 1 0 01-2 0V6H8a1 1 0 010-2h1V3a1 1 0 011-1zM5 5a3 3 0 013-3h4a3 3 0 013 3v1h-1V5a2 2 0 00-2-2H8a2 2 0 00-2 2v1H5V5zm2 5a1 1 0 011-1h4a1 1 0 110 2H8a1 1 0 01-1-1zm-1 4a1 1 0 100 2h8a1 1 0 100-2H6z" clip-rule="evenodd" /></svg>
219
+ <span>Copy Page JS</span>
220
+ </a>
221
+ <div class="border-t border-gray-100"></div>
222
+ <a href="#" id="download-zip-btn" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem">
223
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-3 text-gray-500" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M4 2a2 2 0 00-2 2v12a2 2 0 002 2h12a2 2 0 002-2V4a2 2 0 00-2-2H4zm1 3a1 1 0 000 2h10a1 1 0 100-2H5zM5 13a1 1 0 100 2h10a1 1 0 100-2H5z" clip-rule="evenodd"></path></svg>
224
+ <span>Download Page .zip</span>
225
+ </a>
226
+ </div>
227
+ </div>
228
+ </div>
229
+
230
+ <div class="flex items-center space-x-2">
231
+ <span class="text-sm font-medium text-gray-500">Preview:</span>
232
+ <button id="desktop-btn" class="p-2 rounded-md bg-blue-500 text-white shadow" title="Desktop View">
233
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 2a2 2 0 00-2 2v1H6a2 2 0 00-2 2v7a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2V4a2 2 0 00-2-2zm-1 3V4a1 1 0 112 0v1h-2zM6 7v7h8V7H6z" clip-rule="evenodd"></path></svg>
234
+ </button>
235
+ <button id="tablet-btn" class="p-2 rounded-md bg-gray-200 text-gray-700" title="Tablet View">
236
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M4 2a2 2 0 00-2 2v12a2 2 0 002 2h12a2 2 0 002-2V4a2 2 0 00-2-2H4zm1 2a1 1 0 00-1 1v10a1 1 0 001 1h10a1 1 0 001-1V5a1 1 0 00-1-1H5z" clip-rule="evenodd"></path></svg>
237
+ </button>
238
+ <button id="mobile-btn" class="p-2 rounded-md bg-gray-200 text-gray-700" title="Mobile View">
239
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor"><path d="M5 2a2 2 0 00-2 2v12a2 2 0 002 2h6a2 2 0 002-2V4a2 2 0 00-2-2H5z"></path></svg>
240
+ </button>
241
+ </div>
242
+ </div>
243
+ </header>
244
+
245
+ <div class="flex flex-1 overflow-hidden" id="main-container">
246
+ <aside id="controls-sidebar" class="w-1/3 bg-white shadow-lg overflow-hidden transition-all duration-300 ease-in-out">
247
+ <div id="controls-layout">
248
+ <nav id="controls-nav" class="space-y-2">
249
+ <button class="control-nav-button" data-target="#panel-global-settings"><i class="fas fa-cog"></i>Global</button>
250
+ <button class="control-nav-button" data-target="#panel-layout"><i class="fas fa-layer-group"></i>Layout</button>
251
+ <button class="control-nav-button" data-target="#panel-custom-html"><i class="fas fa-code"></i>Custom HTML</button>
252
+ </nav>
253
+
254
+ <div id="controls-panels">
255
+ <div id="panel-global-settings" class="control-panel">
256
+ <h3>⚙️ Global Settings</h3>
257
+ <div class="space-y-4">
258
+ <div class="space-y-2 border-b pb-4">
259
+ <label class="font-medium text-sm">Color Palette</label>
260
+ <div class="grid grid-cols-2 gap-2 text-xs">
261
+ <div>
262
+ <label for="global-color-primary">Primary</label>
263
+ <input type="color" id="global-color-primary" class="w-full p-0 h-8 border-none rounded-md">
264
+ </div>
265
+ <div>
266
+ <label for="global-color-secondary">Secondary</label>
267
+ <input type="color" id="global-color-secondary" class="w-full p-0 h-8 border-none rounded-md">
268
+ </div>
269
+ <div>
270
+ <label for="global-color-text">Text</label>
271
+ <input type="color" id="global-color-text" class="w-full p-0 h-8 border-none rounded-md">
272
+ </div>
273
+ <div>
274
+ <label for="global-color-heading">Heading</label>
275
+ <input type="color" id="global-color-heading" class="w-full p-0 h-8 border-none rounded-md">
276
+ </div>
277
+ </div>
278
+ </div>
279
+ <div class="space-y-2 border-b pb-4">
280
+ <label class="font-medium text-sm">Typography</label>
281
+ <div>
282
+ <label for="global-font-family" class="text-xs">Font Family</label>
283
+ <select id="global-font-family" class="w-full p-1 border rounded-md text-sm">
284
+ <option value="'Inter', sans-serif">Inter</option>
285
+ <option value="'Roboto', sans-serif">Roboto</option>
286
+ <option value="'Open Sans', sans-serif">Open Sans</option>
287
+ <option value="'Lato', sans-serif">Lato</option>
288
+ <option value="'Montserrat', sans-serif">Montserrat</option>
289
+ <option value="'Poppins', sans-serif">Poppins</option>
290
+ </select>
291
+ </div>
292
+ </div>
293
+ <button id="apply-global-settings" class="w-full bg-blue-600 text-white font-bold py-2 px-4 rounded-md hover:bg-blue-700 transition">Apply Global Styles</button>
294
+ </div>
295
+ </div>
296
+
297
+ <div id="panel-layout" class="control-panel">
298
+ <h3>↕️ Component Layout</h3>
299
+ <p class="text-xs text-gray-500 mb-4">Drag and drop to change the vertical order of the components on your page.</p>
300
+ <div id="layout-builder-container" class="space-y-2"></div>
301
+ </div>
302
+
303
+ <div id="panel-custom-html" class="control-panel">
304
+ <div class="flex justify-between items-center mb-6">
305
+ <h3 class="mb-0 pb-0 border-b-0"> </> Custom HTML</h3>
306
+ <button class="get-component-code-btn text-sm bg-indigo-500 text-white py-1 px-3 rounded-md hover:bg-indigo-600" data-component-key="customHtml">
307
+ <i class="fas fa-code mr-1"></i> Get Code
308
+ </button>
309
+ </div>
310
+ <div class="space-y-4">
311
+ <div class="flex items-center space-x-2 border-b pb-4">
312
+ <input type="checkbox" id="custom-html-toggle" class="h-4 w-4 rounded">
313
+ <label for="custom-html-toggle" class="font-medium">Enable Custom HTML Section</label>
314
+ </div>
315
+ <div id="custom-html-builder">
316
+ <label for="custom-html-content" class="text-sm font-medium">HTML Content</label>
317
+ <p class="text-xs text-gray-500 mb-2">Paste any valid HTML. Be cautious, as invalid code can break the page layout.</p>
318
+ <textarea id="custom-html-content" rows="10" class="w-full p-2 border rounded-md font-mono text-sm"></textarea>
319
+ </div>
320
+ </div>
321
+ </div>
322
+
323
+ </div>
324
+ </div>
325
+ </aside>
326
+
327
+
328
+ <main id="preview-main" class="w-2/3 bg-gray-200 p-4 flex flex-col items-center justify-center overflow-hidden transition-all duration-300 ease-in-out">
329
+ <div id="preview-container" class="bg-white shadow-lg rounded-lg w-full h-full overflow-hidden">
330
+ <iframe id="preview-iframe" class="preview-iframe"></iframe>
331
+ </div>
332
+ </main>
333
+
334
+ </div>
335
+ </div>
336
+ <div id="toast-notification" class="toast"></div>
337
+
338
+ <div id="code-modal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-75 overflow-y-auto h-full w-full z-50">
339
+ <div class="relative top-10 mx-auto p-5 border w-11/12 md:w-2/3 shadow-lg rounded-md bg-white">
340
+ <div class="flex justify-between items-center border-b pb-3">
341
+ <h3 id="code-modal-title" class="text-lg leading-6 font-medium text-gray-900">Component Code</h3>
342
+ <button id="close-code-modal-btn" class="text-gray-400 hover:text-gray-600">&times;</button>
343
+ </div>
344
+ <div class="mt-4 space-y-4">
345
+ <div>
346
+ <label class="font-semibold text-gray-700">HTML</label>
347
+ <pre id="code-modal-html" class="code-modal-pre"><code></code></pre>
348
+ </div>
349
+ <div>
350
+ <label class="font-semibold text-gray-700">CSS</label>
351
+ <pre id="code-modal-css" class="code-modal-pre"><code></code></pre>
352
+ </div>
353
+ <div>
354
+ <label class="font-semibold text-gray-700">JavaScript</label>
355
+ <pre id="code-modal-js" class="code-modal-pre"><code></code></pre>
356
+ </div>
357
+ </div>
358
+ <div class="items-center px-4 py-3 mt-4 text-right bg-gray-50 -mx-5 -mb-5 rounded-b-md">
359
+ <button id="download-component-zip-btn" class="px-4 py-2 bg-green-600 text-white text-base font-medium rounded-md shadow-sm hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-green-300">
360
+ Download .zip
361
+ </button>
362
+ <button id="close-code-modal-btn-2" class="px-4 py-2 bg-gray-200 text-gray-800 text-base font-medium rounded-md shadow-sm hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-gray-300 ml-2">
363
+ Close
364
+ </button>
365
+ </div>
366
+ </div>
367
+ </div>
368
+
369
+
370
+ <script>
371
+ document.addEventListener('DOMContentLoaded', () => {
372
+ // State object to hold all configurations
373
+ const config = {
374
+ globalSettings: {
375
+ colors: {
376
+ primary: '#3b82f6',
377
+ secondary: '#10b981',
378
+ text: '#374151',
379
+ heading: '#111827',
380
+ },
381
+ typography: {
382
+ fontFamily: "'Inter', sans-serif",
383
+ }
384
+ },
385
+ componentOrder: [
386
+ 'customHtml'
387
+ ],
388
+ customHtml: {
389
+ enabled: false,
390
+ content: ''
391
+ }
392
+ };
393
+
394
+ const componentNames = {
395
+ customHtml: 'Custom HTML'
396
+ };
397
+
398
+ // UI Element References
399
+ const ui = {
400
+ previewIframe: document.getElementById('preview-iframe'),
401
+ mainContainer: document.getElementById('main-container'),
402
+ toggleSidebarBtn: document.getElementById('toggle-sidebar-btn'),
403
+ controls: {
404
+ nav: document.getElementById('controls-nav'),
405
+ panels: document.getElementById('controls-panels'),
406
+ },
407
+ globalSettings: {
408
+ primaryColor: document.getElementById('global-color-primary'),
409
+ secondaryColor: document.getElementById('global-color-secondary'),
410
+ textColor: document.getElementById('global-color-text'),
411
+ headingColor: document.getElementById('global-color-heading'),
412
+ fontFamily: document.getElementById('global-font-family'),
413
+ applyBtn: document.getElementById('apply-global-settings'),
414
+ },
415
+ layout: {
416
+ container: document.getElementById('layout-builder-container'),
417
+ panel: document.getElementById('panel-layout')
418
+ },
419
+ customHtml: {
420
+ toggle: document.getElementById('custom-html-toggle'),
421
+ content: document.getElementById('custom-html-content'),
422
+ },
423
+ buttons: {
424
+ desktop: document.getElementById('desktop-btn'),
425
+ tablet: document.getElementById('tablet-btn'),
426
+ mobile: document.getElementById('mobile-btn'),
427
+ import: document.getElementById('import-btn'),
428
+ importFile: document.getElementById('import-file-input'),
429
+ },
430
+ exportMenu: {
431
+ container: document.getElementById('export-menu-container'),
432
+ button: document.getElementById('export-menu-btn'),
433
+ dropdown: document.getElementById('export-dropdown'),
434
+ copyCombined: document.getElementById('copy-combined-code'),
435
+ copyHtml: document.getElementById('copy-html'),
436
+ copyCss: document.getElementById('copy-css'),
437
+ copyJs: document.getElementById('copy-js'),
438
+ downloadZip: document.getElementById('download-zip-btn'),
439
+ },
440
+ codeModal: {
441
+ modal: document.getElementById('code-modal'),
442
+ title: document.getElementById('code-modal-title'),
443
+ htmlContainer: document.getElementById('code-modal-html'),
444
+ cssContainer: document.getElementById('code-modal-css'),
445
+ jsContainer: document.getElementById('code-modal-js'),
446
+ htmlCode: document.querySelector('#code-modal-html code'),
447
+ cssCode: document.querySelector('#code-modal-css code'),
448
+ jsCode: document.querySelector('#code-modal-js code'),
449
+ downloadBtn: document.getElementById('download-component-zip-btn'),
450
+ closeBtns: [document.getElementById('close-code-modal-btn'), document.getElementById('close-code-modal-btn-2')],
451
+ },
452
+ previewContainer: document.getElementById('preview-container'),
453
+ };
454
+
455
+ // --- Event Listeners ---
456
+ function setupEventListeners() {
457
+ ui.controls.nav.addEventListener('click', (e) => {
458
+ const button = e.target.closest('.control-nav-button');
459
+ if (!button) return;
460
+ const targetPanelId = button.dataset.target;
461
+ ui.controls.nav.querySelectorAll('.control-nav-button').forEach(btn => btn.classList.remove('active'));
462
+ button.classList.add('active');
463
+ ui.controls.panels.querySelectorAll('.control-panel').forEach(panel => {
464
+ panel.classList.toggle('active', `#${panel.id}` === targetPanelId);
465
+ });
466
+ });
467
+
468
+ // Global Settings Listeners
469
+ ui.globalSettings.primaryColor.addEventListener('input', e => config.globalSettings.colors.primary = e.target.value);
470
+ ui.globalSettings.secondaryColor.addEventListener('input', e => config.globalSettings.colors.secondary = e.target.value);
471
+ ui.globalSettings.textColor.addEventListener('input', e => config.globalSettings.colors.text = e.target.value);
472
+ ui.globalSettings.headingColor.addEventListener('input', e => config.globalSettings.colors.heading = e.target.value);
473
+ ui.globalSettings.fontFamily.addEventListener('change', e => config.globalSettings.typography.fontFamily = e.target.value);
474
+ ui.globalSettings.applyBtn.addEventListener('click', () => {
475
+ renderAll();
476
+ showToast('Global styles applied!');
477
+ });
478
+
479
+
480
+ // Layout Controls
481
+ ui.layout.panel.addEventListener('click', handleLayoutControlsClick);
482
+ setupDragAndDrop();
483
+
484
+ // Component Listeners
485
+ ui.customHtml.toggle.addEventListener('change', e => { config.customHtml.enabled = e.target.checked; renderAll(); });
486
+ ui.customHtml.content.addEventListener('input', e => { config.customHtml.content = e.target.value; renderAll(); });
487
+
488
+ // Preview & Export
489
+ ui.buttons.desktop.addEventListener('click', () => setPreviewMode('desktop'));
490
+ ui.buttons.tablet.addEventListener('click', () => setPreviewMode('tablet'));
491
+ ui.buttons.mobile.addEventListener('click', () => setPreviewMode('mobile'));
492
+ ui.exportMenu.button.addEventListener('click', (e) => { e.stopPropagation(); ui.exportMenu.dropdown.classList.toggle('hidden'); });
493
+ window.addEventListener('click', (e) => { if (!ui.exportMenu.container.contains(e.target)) { ui.exportMenu.dropdown.classList.add('hidden'); } });
494
+
495
+ const copyAction = (e, dataGetter, message) => {
496
+ e.preventDefault();
497
+ navigator.clipboard.writeText(dataGetter()).then(() => showToast(message));
498
+ ui.exportMenu.dropdown.classList.add('hidden');
499
+ };
500
+
501
+ ui.exportMenu.copyCombined.addEventListener('click', (e) => copyAction(e, getCombinedCode, 'Combined code copied!'));
502
+ ui.exportMenu.copyHtml.addEventListener('click', (e) => copyAction(e, getAllHtml, 'All HTML copied!'));
503
+ ui.exportMenu.copyCss.addEventListener('click', (e) => copyAction(e, getFullCSS, 'All CSS copied!'));
504
+ ui.exportMenu.copyJs.addEventListener('click', (e) => copyAction(e, getFullJS, 'All JS copied!'));
505
+ ui.exportMenu.downloadZip.addEventListener('click', (e) => { e.preventDefault(); generatePageZip(); ui.exportMenu.dropdown.classList.add('hidden'); });
506
+
507
+ // Import
508
+ ui.buttons.import.addEventListener('click', () => ui.buttons.importFile.click());
509
+ ui.buttons.importFile.addEventListener('change', handleFileImport);
510
+
511
+ // Code Modal Listeners
512
+ ui.controls.panels.addEventListener('click', handleGetCodeClick);
513
+ ui.codeModal.closeBtns.forEach(btn => btn.addEventListener('click', () => ui.codeModal.modal.classList.add('hidden')));
514
+ ui.codeModal.modal.addEventListener('click', (e) => {
515
+ if (e.target.id === 'code-modal-html' || e.target.id === 'code-modal-css' || e.target.id === 'code-modal-js') {
516
+ const code = e.target.querySelector('code').innerText;
517
+ navigator.clipboard.writeText(code).then(() => showToast('Copied to clipboard!'));
518
+ }
519
+ });
520
+
521
+ // Sidebar Toggle Listener
522
+ ui.toggleSidebarBtn.addEventListener('click', () => {
523
+ ui.mainContainer.classList.toggle('sidebar-collapsed');
524
+ const isCollapsed = ui.mainContainer.classList.contains('sidebar-collapsed');
525
+ const icon = ui.toggleSidebarBtn.querySelector('i');
526
+ icon.classList.toggle('fa-chevron-left', !isCollapsed);
527
+ icon.classList.toggle('fa-chevron-right', isCollapsed);
528
+ ui.toggleSidebarBtn.title = isCollapsed ? 'Show Controls' : 'Hide Controls';
529
+ });
530
+ }
531
+
532
+ // --- LAYOUT CONTROLS ---
533
+ function renderLayoutControls() {
534
+ ui.layout.container.innerHTML = config.componentOrder.map((key, index) => {
535
+ const total = config.componentOrder.length;
536
+ return `
537
+ <div class="layout-item p-3 border rounded-md bg-white flex items-center justify-between" draggable="true" data-key="${key}">
538
+ <span class="font-medium text-sm"><i class="fas fa-grip-vertical mr-3 text-gray-400"></i> ${componentNames[key]}</span>
539
+ <div class="item-toolbar mb-0">
540
+ <button class="reorder-layout-up-btn text-xs bg-gray-200 text-gray-700 p-1 rounded-md hover:bg-gray-300" data-index="${index}" ${index === 0 ? 'disabled' : ''}><i class="fas fa-arrow-up fa-fw"></i></button>
541
+ <button class="reorder-layout-down-btn text-xs bg-gray-200 text-gray-700 p-1 rounded-md hover:bg-gray-300" data-index="${index}" ${index === total - 1 ? 'disabled' : ''}><i class="fas fa-arrow-down fa-fw"></i></button>
542
+ </div>
543
+ </div>`;
544
+ }).join('');
545
+ }
546
+
547
+ function handleLayoutControlsClick(e) {
548
+ const button = e.target.closest('button');
549
+ if (!button) return;
550
+
551
+ const index = parseInt(button.dataset.index, 10);
552
+ const order = config.componentOrder;
553
+ let changed = false;
554
+
555
+ if (button.classList.contains('reorder-layout-up-btn') && index > 0) {
556
+ [order[index], order[index - 1]] = [order[index - 1], order[index]];
557
+ changed = true;
558
+ } else if (button.classList.contains('reorder-layout-down-btn') && index < order.length - 1) {
559
+ [order[index], order[index + 1]] = [order[index + 1], order[index]];
560
+ changed = true;
561
+ }
562
+
563
+ if(changed) {
564
+ renderLayoutControls();
565
+ renderAll();
566
+ }
567
+ }
568
+
569
+ function setupDragAndDrop() {
570
+ let draggedItem = null;
571
+
572
+ ui.layout.container.addEventListener('dragstart', e => {
573
+ draggedItem = e.target;
574
+ setTimeout(() => {
575
+ e.target.style.display = 'none';
576
+ }, 0);
577
+ });
578
+
579
+ ui.layout.container.addEventListener('dragend', e => {
580
+ setTimeout(() => {
581
+ draggedItem.style.display = 'flex';
582
+ draggedItem = null;
583
+ }, 0);
584
+ });
585
+
586
+ ui.layout.container.addEventListener('dragover', e => {
587
+ e.preventDefault();
588
+ const afterElement = getDragAfterElement(ui.layout.container, e.clientY);
589
+ if (afterElement == null) {
590
+ ui.layout.container.appendChild(draggedItem);
591
+ } else {
592
+ ui.layout.container.insertBefore(draggedItem, afterElement);
593
+ }
594
+ });
595
+
596
+ ui.layout.container.addEventListener('drop', e => {
597
+ e.preventDefault();
598
+ const newOrderKeys = [...ui.layout.container.querySelectorAll('.layout-item')].map(item => item.dataset.key);
599
+ config.componentOrder = newOrderKeys;
600
+ renderLayoutControls();
601
+ renderAll();
602
+ });
603
+ }
604
+
605
+ function getDragAfterElement(container, y) {
606
+ const draggableElements = [...container.querySelectorAll('.layout-item:not(.dragging)')];
607
+
608
+ return draggableElements.reduce((closest, child) => {
609
+ const box = child.getBoundingClientRect();
610
+ const offset = y - box.top - box.height / 2;
611
+ if (offset < 0 && offset > closest.offset) {
612
+ return { offset: offset, element: child };
613
+ } else {
614
+ return closest;
615
+ }
616
+ }, { offset: Number.NEGATIVE_INFINITY }).element;
617
+ }
618
+
619
+
620
+ // --- HTML Generation Logic ---
621
+ const componentGenerators = {
622
+ customHtml: generateCustomHtmlHTML
623
+ };
624
+
625
+ function getAllHtml() {
626
+ return config.componentOrder
627
+ .map(key => componentGenerators[key] ? componentGenerators[key]() : '')
628
+ .filter(Boolean)
629
+ .join('\n\n');
630
+ }
631
+
632
+ function generateCustomHtmlHTML() {
633
+ if (!config.customHtml.enabled) return '';
634
+ return `<div class="custom-html-section">${config.customHtml.content}</div>`;
635
+ }
636
+
637
+ function generateComponentCSS(targetKey = null) {
638
+ const { colors, typography } = config.globalSettings;
639
+ const css = {};
640
+
641
+ css.global = `
642
+ /* --- Global --- */
643
+ :root {
644
+ --primary-color: ${colors.primary};
645
+ --secondary-color: ${colors.secondary};
646
+ --text-color: ${colors.text};
647
+ --heading-color: ${colors.heading};
648
+ --font-family: ${typography.fontFamily};
649
+ }
650
+ body {
651
+ font-family: var(--font-family);
652
+ color: var(--text-color);
653
+ margin: 0;
654
+ background-color: #f0f2f5;
655
+ }
656
+ h1,h2,h3,h4,h5,h6 {
657
+ color: var(--heading-color);
658
+ }
659
+ .container { max-width: 1280px; }
660
+ a { text-decoration: none; transition: color 0.2s; color: var(--primary-color); }
661
+ .section-title { text-align: center; font-size: 1.8rem; font-weight: 700; margin: 0 0 2rem 0; }
662
+ .button-primary {
663
+ background-color: var(--primary-color);
664
+ color: white;
665
+ }
666
+ .button-primary:hover {
667
+ opacity: 0.9;
668
+ }
669
+ `;
670
+
671
+
672
+ if(config.customHtml.enabled) css.customHtml = `
673
+ /* --- Custom HTML Section --- */
674
+ .custom-html-section { padding: 1rem 0; }`;
675
+
676
+ if (targetKey) {
677
+ return {
678
+ global: css.global,
679
+ component: css[targetKey] || ''
680
+ }
681
+ }
682
+ return css;
683
+ }
684
+
685
+ function getFullCSS() {
686
+ const cssObject = generateComponentCSS();
687
+ const orderedCSS = config.componentOrder.map(key => cssObject[key]).filter(Boolean);
688
+ return [cssObject.global, ...orderedCSS].join('\n\n');
689
+ }
690
+
691
+ function generateComponentJavaScript(targetKey = null) {
692
+ const js = {};
693
+
694
+ if (targetKey) {
695
+ return js[targetKey] || '';
696
+ }
697
+ return js;
698
+ }
699
+
700
+ function getFullJS() {
701
+ const jsObject = generateComponentJavaScript();
702
+ return config.componentOrder.map(key => {
703
+ let script = jsObject[key] || '';
704
+ return script;
705
+ }).filter(Boolean).join('\n\n');
706
+ }
707
+
708
+ function getCombinedCode() {
709
+ const htmlBody = getAllHtml();
710
+ const css = getFullCSS();
711
+ let js = getFullJS();
712
+ if (js.trim()) {
713
+ js = `document.addEventListener('DOMContentLoaded', () => { \n${js.trim()} \n});`;
714
+ }
715
+
716
+ return `<!DOCTYPE html>
717
+ <html lang="en">
718
+ <head>
719
+ <meta charset="UTF-8">
720
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
721
+ <title>Exported Page</title>
722
+ <script src="https://cdn.tailwindcss.com"><\/script>
723
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
724
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
725
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
726
+ <style>
727
+ ${css}
728
+ </style>
729
+ </head>
730
+ <body class="bg-gray-100">
731
+ ${htmlBody}
732
+ ${js ? `<script>${js}<\/script>` : ''}
733
+ </body>
734
+ </html>`;
735
+ }
736
+
737
+ // --- Rendering ---
738
+ function renderAll() {
739
+ const fullJs = getFullJS();
740
+ const previewContent = `<!DOCTYPE html><html><head><title>Preview</title>
741
+ <script src="https://cdn.tailwindcss.com"><\/script>
742
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
743
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
744
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
745
+ <style>${getFullCSS()}</style></head><body>
746
+ <div class="site-wrapper">
747
+ ${getAllHtml()}
748
+ <div style="min-height: 400px; padding: 40px; text-align: center; color: #6b7280; font-family: 'Inter', sans-serif;"></div>
749
+ </div>
750
+ <script>
751
+ ${fullJs ? `document.addEventListener('DOMContentLoaded', () => { \n${fullJs} \n});` : ''}
752
+ <\/script></body></html>`;
753
+
754
+ ui.previewIframe.srcdoc = previewContent;
755
+ }
756
+
757
+ // --- Utility Functions ---
758
+ function setPreviewMode(mode) {
759
+ ui.previewContainer.className = `bg-white shadow-lg rounded-lg w-full h-full overflow-hidden transition-all duration-300 preview-${mode}`;
760
+ ['desktop', 'tablet', 'mobile'].forEach(m => {
761
+ const btn = ui.buttons[m];
762
+ btn.classList.toggle('bg-blue-500', m === mode);
763
+ btn.classList.toggle('text-white', m === mode);
764
+ btn.classList.toggle('shadow', m === mode);
765
+ btn.classList.toggle('bg-gray-200', m !== mode);
766
+ btn.classList.toggle('text-gray-700', m !== mode);
767
+ });
768
+ }
769
+
770
+ function showToast(message) {
771
+ const toast = document.getElementById('toast-notification');
772
+ toast.textContent = message;
773
+ toast.classList.add('show');
774
+ setTimeout(() => { toast.classList.remove('show'); }, 3000);
775
+ }
776
+
777
+ function generatePageZip() {
778
+ const zip = new JSZip();
779
+ const html = `<!DOCTYPE html>
780
+ <html lang="en">
781
+ <head>
782
+ <meta charset="UTF-8">
783
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
784
+ <title>Exported Page</title>
785
+ <script src="https://cdn.tailwindcss.com"><\/script>
786
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
787
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
788
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
789
+ <link rel="stylesheet" href="style.css">
790
+ </head>
791
+ <body>
792
+ ${getAllHtml()}
793
+ <script src="script.js"><\/script>
794
+ </body>
795
+ </html>`;
796
+ const css = getFullCSS();
797
+ const js = getFullJS();
798
+
799
+ zip.file("index.html", html);
800
+ zip.file("style.css", css);
801
+ if (js.trim()) {
802
+ zip.file("script.js", `document.addEventListener('DOMContentLoaded', () => { \n${js} \n});`);
803
+ }
804
+
805
+ zip.generateAsync({type:"blob"}).then(function(content) {
806
+ saveAs(content, "exported-page.zip");
807
+ showToast("ZIP file generated!");
808
+ });
809
+ }
810
+
811
+ function handleFileImport(event) {
812
+ const file = event.target.files[0];
813
+ if (!file) return;
814
+
815
+ const reader = new FileReader();
816
+ reader.onload = function(e) {
817
+ const content = e.target.result;
818
+ try {
819
+ const parser = new DOMParser();
820
+ const doc = parser.parseFromString(content, 'text/html');
821
+ parseImportedDocument(doc);
822
+ showToast('Import successful!');
823
+ } catch (error) {
824
+ console.error('Error parsing imported file:', error);
825
+ showToast('Error: Could not parse file.');
826
+ }
827
+ event.target.value = null; // Reset file input
828
+ };
829
+ reader.readAsText(file);
830
+ }
831
+
832
+ function parseImportedDocument(doc) {
833
+ console.log("Parsing imported document...");
834
+ }
835
+
836
+ function handleGetCodeClick(e) {
837
+ const button = e.target.closest('.get-component-code-btn');
838
+ if (!button) return;
839
+
840
+ const key = button.dataset.componentKey;
841
+ if (!key) return;
842
+
843
+ const html = componentGenerators[key] ? componentGenerators[key]() : 'Not available';
844
+ const { global, component: css } = generateComponentCSS(key);
845
+ const js = generateComponentJavaScript(key);
846
+
847
+ ui.codeModal.title.textContent = `${componentNames[key]} Component Code`;
848
+
849
+ ui.codeModal.htmlCode.textContent = html;
850
+ ui.codeModal.cssCode.textContent = (global + '\n\n' + css).trim();
851
+
852
+ let jsWithWrapper = js.trim();
853
+ if (jsWithWrapper) {
854
+ jsWithWrapper = `document.addEventListener('DOMContentLoaded', () => { \n${jsWithWrapper}\n });`;
855
+ }
856
+ ui.codeModal.jsCode.textContent = jsWithWrapper || '// No JavaScript for this component';
857
+
858
+
859
+ [ui.codeModal.htmlContainer, ui.codeModal.cssContainer, ui.codeModal.jsContainer].forEach(el => {
860
+ if (el.querySelector('code').textContent.trim() === '' || el.querySelector('code').textContent.startsWith('//')) {
861
+ el.style.display = 'none';
862
+ } else {
863
+ el.style.display = 'block';
864
+ }
865
+ });
866
+
867
+ ui.codeModal.downloadBtn.onclick = () => generateComponentZip(key);
868
+ ui.codeModal.modal.classList.remove('hidden');
869
+ }
870
+
871
+ function generateComponentZip(key) {
872
+ const zip = new JSZip();
873
+ const { global, component: css } = generateComponentCSS(key);
874
+ const js = generateComponentJavaScript(key);
875
+ const htmlBody = componentGenerators[key] ? componentGenerators[key]() : '';
876
+
877
+ const html = `<!DOCTYPE html>
878
+ <html lang="en">
879
+ <head>
880
+ <meta charset="UTF-8">
881
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
882
+ <title>${componentNames[key]} Component</title>
883
+ <script src="https://cdn.tailwindcss.com"><\/script>
884
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
885
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
886
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
887
+ <link rel="stylesheet" href="style.css">
888
+ </head>
889
+ <body>
890
+ ${htmlBody}
891
+ ${js.trim() ? '<script src="script.js"><\/script>' : ''}
892
+ </body>
893
+ </html>`;
894
+ zip.file("index.html", html);
895
+ zip.file("style.css", (global + '\n\n' + css).trim());
896
+ if (js.trim()) {
897
+ let jsWithWrapper = `document.addEventListener('DOMContentLoaded', () => { \n${js} \n});`;
898
+ zip.file("script.js", jsWithWrapper);
899
+ }
900
+ zip.generateAsync({type:"blob"}).then(function(content) {
901
+ saveAs(content, `${key}-component.zip`);
902
+ showToast("Component ZIP generated!");
903
+ });
904
+ }
905
+
906
+ // Initial Load
907
+ function init() {
908
+ const { customHtml, globalSettings } = config;
909
+
910
+ // Init Global Settings
911
+ ui.globalSettings.primaryColor.value = globalSettings.colors.primary;
912
+ ui.globalSettings.secondaryColor.value = globalSettings.colors.secondary;
913
+ ui.globalSettings.textColor.value = globalSettings.colors.text;
914
+ ui.globalSettings.headingColor.value = globalSettings.colors.heading;
915
+ ui.globalSettings.fontFamily.value = globalSettings.typography.fontFamily;
916
+
917
+ // Init Custom HTML
918
+ ui.customHtml.toggle.checked = customHtml.enabled;
919
+ ui.customHtml.content.value = customHtml.content;
920
+
921
+ setupEventListeners();
922
+
923
+ renderLayoutControls();
924
+ renderAll();
925
+ if(!document.querySelector('.control-nav-button.active')){
926
+ ui.controls.nav.querySelector('.control-nav-button').click();
927
+ }
928
+ }
929
+
930
+ init();
931
+ });
932
+ </script>
933
+ </body>
934
+ </html>