Examups commited on
Commit
86ce656
·
verified ·
1 Parent(s): e89906e

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +1470 -19
index.html CHANGED
@@ -1,19 +1,1470 @@
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="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Advanced Component Builder</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
9
+ <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">
10
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
11
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
12
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"></script>
13
+ <script src="https://cdn.ckeditor.com/ckeditor5/41.4.2/classic/ckeditor.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
+ --background-color: #f9fafb;
23
+ --font-family: 'Inter', sans-serif;
24
+ }
25
+
26
+ body {
27
+ font-family: var(--font-family);
28
+ color: var(--text-color);
29
+ background-color: var(--background-color);
30
+ }
31
+ h1, h2, h3, h4, h5, h6 {
32
+ color: var(--heading-color);
33
+ }
34
+ /* Custom scrollbar for webkit browsers */
35
+ ::-webkit-scrollbar {
36
+ width: 8px;
37
+ height: 8px;
38
+ }
39
+ ::-webkit-scrollbar-track {
40
+ background: #f1f1f1;
41
+ }
42
+ ::-webkit-scrollbar-thumb {
43
+ background: #888;
44
+ border-radius: 10px;
45
+ }
46
+ ::-webkit-scrollbar-thumb:hover {
47
+ background: #555;
48
+ }
49
+ .preview-iframe {
50
+ width: 100%;
51
+ height: 100%;
52
+ border: 0;
53
+ transition: all 0.3s ease-in-out;
54
+ }
55
+ #preview-container.preview-desktop .preview-iframe { width: 100%; }
56
+ #preview-container.preview-tablet .preview-iframe { width: 768px; margin: 0 auto; }
57
+ #preview-container.preview-mobile .preview-iframe { width: 375px; margin: 0 auto; }
58
+
59
+ .toast {
60
+ visibility: hidden;
61
+ min-width: 250px;
62
+ background-color: #333;
63
+ color: #fff;
64
+ text-align: center;
65
+ border-radius: 8px;
66
+ padding: 16px;
67
+ position: fixed;
68
+ z-index: 100;
69
+ left: 50%;
70
+ bottom: 30px;
71
+ transform: translateX(-50%);
72
+ opacity: 0;
73
+ transition: opacity 0.3s, visibility 0.3s;
74
+ }
75
+ .toast.show {
76
+ visibility: visible;
77
+ opacity: 1;
78
+ }
79
+
80
+ /* New Professional Controls UI Styles */
81
+ #controls-layout {
82
+ display: flex;
83
+ height: 100%;
84
+ }
85
+ #controls-nav {
86
+ width: 180px;
87
+ flex-shrink: 0;
88
+ background-color: #f8fafc;
89
+ border-right: 1px solid #e5e7eb;
90
+ padding: 0.5rem;
91
+ overflow-y: auto;
92
+ }
93
+ .control-nav-button {
94
+ display: flex;
95
+ align-items: center;
96
+ width: 100%;
97
+ padding: 0.75rem;
98
+ border-radius: 0.375rem;
99
+ font-weight: 500;
100
+ color: var(--text-color);
101
+ transition: background-color 0.2s, color 0.2s;
102
+ text-align: left;
103
+ }
104
+ .control-nav-button:hover {
105
+ background-color: #e5e7eb;
106
+ }
107
+ .control-nav-button.active {
108
+ background-color: var(--primary-color);
109
+ color: white;
110
+ box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
111
+ }
112
+ .control-nav-button i {
113
+ margin-right: 0.75rem;
114
+ width: 20px;
115
+ text-align: center;
116
+ }
117
+ #controls-panels {
118
+ flex-grow: 1;
119
+ padding: 1.5rem;
120
+ overflow-y: auto;
121
+ }
122
+ .control-panel {
123
+ display: none;
124
+ }
125
+ .control-panel.active {
126
+ display: block;
127
+ }
128
+ .control-panel h3 {
129
+ font-size: 1.25rem;
130
+ font-weight: 600;
131
+ margin-bottom: 1.5rem;
132
+ border-bottom: 1px solid #e5e7eb;
133
+ padding-bottom: 0.75rem;
134
+ }
135
+ .control-group-label {
136
+ font-weight: 600;
137
+ font-size: 0.875rem;
138
+ color: #4b5563;
139
+ margin-top: 1.25rem;
140
+ margin-bottom: 0.75rem;
141
+ padding-bottom: 0.25rem;
142
+ border-bottom: 1px solid #e5e7eb;
143
+ }
144
+ .item-toolbar {
145
+ display: flex;
146
+ justify-content: flex-end;
147
+ gap: 0.25rem;
148
+ margin-bottom: 0.5rem;
149
+ }
150
+ .item-toolbar button {
151
+ line-height: 1;
152
+ }
153
+ .layout-item {
154
+ cursor: move;
155
+ }
156
+ .code-modal-pre {
157
+ background-color: #2d3748;
158
+ color: #e2e8f0;
159
+ padding: 1rem;
160
+ border-radius: 0.375rem;
161
+ max-height: 200px;
162
+ overflow-y: auto;
163
+ position: relative;
164
+ }
165
+ /* CKEditor Styles */
166
+ .ck-editor__editable_inline {
167
+ min-height: 150px;
168
+ }
169
+ .info-card-item-controls .controls-header {
170
+ display: flex;
171
+ justify-content: space-between;
172
+ align-items: center;
173
+ padding: 0.75rem;
174
+ background-color: #f3f4f6;
175
+ border: 1px solid #e5e7eb;
176
+ border-radius: 0.375rem;
177
+ cursor: pointer;
178
+ }
179
+ .info-card-item-controls .controls-body {
180
+ display: none;
181
+ padding: 1.25rem;
182
+ border: 1px solid #e5e7eb;
183
+ border-top: 0;
184
+ border-radius: 0 0 0.375rem 0.375rem;
185
+ }
186
+ .info-card-item-controls.open .controls-body {
187
+ display: block;
188
+ }
189
+ </style>
190
+ </head>
191
+ <body class="text-gray-800">
192
+
193
+ <div id="app" class="flex flex-col h-screen">
194
+
195
+ <header class="bg-white shadow-md p-4 flex justify-between items-center z-20">
196
+ <h1 class="text-xl font-bold text-gray-700">Component Builder</h1>
197
+ <div class="flex items-center space-x-4">
198
+
199
+ <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">
200
+ <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
201
+ <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>
202
+ <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>
203
+ </svg>
204
+ <span>Import</span>
205
+ </button>
206
+ <input type="file" id="import-file-input" class="hidden" accept=".html">
207
+
208
+ <div id="export-menu-container" class="relative">
209
+ <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">
210
+ <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>
211
+ <span>Export Page</span>
212
+ </button>
213
+ <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">
214
+ <div class="py-1" role="menu" aria-orientation="vertical" aria-labelledby="export-menu-btn">
215
+ <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">
216
+ <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>
217
+ <span>Copy Combined Code</span>
218
+ </a>
219
+ <a href="#" id="copy-html" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem">
220
+ <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- savaşmak-14V5zM3 8h18v10a2 2 0 01-2 2H5a2 2 0 01-2-2V8z"></path></svg>
221
+ <span>Copy Page HTML</span>
222
+ </a>
223
+ <a href="#" id="copy-css" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem">
224
+ <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>
225
+ <span>Copy Page CSS</span>
226
+ </a>
227
+ <a href="#" id="copy-js" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem">
228
+ <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>
229
+ <span>Copy Page JS</span>
230
+ </a>
231
+ <div class="border-t border-gray-100"></div>
232
+ <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">
233
+ <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>
234
+ <span>Download Page .zip</span>
235
+ </a>
236
+ </div>
237
+ </div>
238
+ </div>
239
+
240
+ <div class="flex items-center space-x-2">
241
+ <span class="text-sm font-medium text-gray-500">Preview:</span>
242
+ <button id="desktop-btn" class="p-2 rounded-md bg-blue-500 text-white shadow" title="Desktop View">
243
+ <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>
244
+ </button>
245
+ <button id="tablet-btn" class="p-2 rounded-md bg-gray-200 text-gray-700" title="Tablet View">
246
+ <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>
247
+ </button>
248
+ <button id="mobile-btn" class="p-2 rounded-md bg-gray-200 text-gray-700" title="Mobile View">
249
+ <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>
250
+ </button>
251
+ </div>
252
+ </div>
253
+ </header>
254
+
255
+ <div class="flex flex-1 overflow-hidden">
256
+ <aside class="w-1/3 bg-white shadow-lg overflow-hidden">
257
+ <div id="controls-layout">
258
+ <nav id="controls-nav" class="space-y-2">
259
+ <button class="control-nav-button" data-target="#panel-global-settings"><i class="fas fa-cog"></i>Global</button>
260
+ <button class="control-nav-button" data-target="#panel-layout"><i class="fas fa-layer-group"></i>Layout</button>
261
+ <button class="control-nav-button" data-target="#panel-page-title"><i class="fas fa-heading"></i>Page Title</button>
262
+ <button class="control-nav-button" data-target="#panel-info-cards"><i class="fas fa-info-circle"></i>Info Cards</button>
263
+ <button class="control-nav-button" data-target="#panel-custom-html"><i class="fas fa-code"></i>Custom HTML</button>
264
+ </nav>
265
+
266
+ <div id="controls-panels">
267
+ <div id="panel-global-settings" class="control-panel">
268
+ <h3>⚙️ Global Settings</h3>
269
+ <div class="space-y-4">
270
+ <div class="space-y-2 border-b pb-4">
271
+ <label class="font-medium text-sm">Color Palette</label>
272
+ <div class="grid grid-cols-2 gap-2 text-xs">
273
+ <div>
274
+ <label for="global-color-primary">Primary</label>
275
+ <input type="color" id="global-color-primary" class="w-full p-0 h-8 border-none rounded-md">
276
+ </div>
277
+ <div>
278
+ <label for="global-color-secondary">Secondary</label>
279
+ <input type="color" id="global-color-secondary" class="w-full p-0 h-8 border-none rounded-md">
280
+ </div>
281
+ <div>
282
+ <label for="global-color-text">Text</label>
283
+ <input type="color" id="global-color-text" class="w-full p-0 h-8 border-none rounded-md">
284
+ </div>
285
+ <div>
286
+ <label for="global-color-heading">Heading</label>
287
+ <input type="color" id="global-color-heading" class="w-full p-0 h-8 border-none rounded-md">
288
+ </div>
289
+ </div>
290
+ </div>
291
+ <div class="space-y-2 border-b pb-4">
292
+ <label class="font-medium text-sm">Typography</label>
293
+ <div>
294
+ <label for="global-font-family" class="text-xs">Font Family</label>
295
+ <select id="global-font-family" class="w-full p-1 border rounded-md text-sm">
296
+ <option value="'Inter', sans-serif">Inter</option>
297
+ <option value="'Roboto', sans-serif">Roboto</option>
298
+ <option value="'Open Sans', sans-serif">Open Sans</option>
299
+ <option value="'Lato', sans-serif">Lato</option>
300
+ <option value="'Montserrat', sans-serif">Montserrat</option>
301
+ <option value="'Poppins', sans-serif">Poppins</option>
302
+ </select>
303
+ </div>
304
+ </div>
305
+ <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>
306
+ </div>
307
+ </div>
308
+
309
+ <div id="panel-layout" class="control-panel">
310
+ <h3>↕️ Component Layout</h3>
311
+ <p class="text-xs text-gray-500 mb-4">Drag and drop to change the vertical order of the components on your page.</p>
312
+ <div id="layout-builder-container" class="space-y-2"></div>
313
+ </div>
314
+
315
+ <div id="panel-page-title" class="control-panel">
316
+ <div class="flex justify-between items-center mb-4">
317
+ <h3 class="mb-0 pb-0 border-b-0">✏️ Page Title</h3>
318
+ <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="pageTitle">
319
+ <i class="fas fa-code mr-1"></i> Get Code
320
+ </button>
321
+ </div>
322
+ <div class="space-y-4">
323
+ <div class="flex items-center space-x-2 border-b pb-4">
324
+ <input type="checkbox" id="page-title-toggle" class="h-4 w-4 rounded">
325
+ <label for="page-title-toggle" class="font-medium">Enable Page Title Section</label>
326
+ </div>
327
+ <div id="page-title-builder" class="space-y-4">
328
+ <div>
329
+ <label for="page-title-text" class="text-sm font-medium">Main Title</label>
330
+ <input type="text" id="page-title-text" class="w-full p-2 border rounded-md mt-1">
331
+ </div>
332
+ <div>
333
+ <label for="page-subtitle-text" class="text-sm font-medium">Subtitle</label>
334
+ <textarea id="page-subtitle-text" rows="3" class="w-full p-2 border rounded-md mt-1"></textarea>
335
+ </div>
336
+ <div class="grid grid-cols-2 gap-4">
337
+ <div>
338
+ <label for="page-title-size" class="text-sm font-medium">Title Size</label>
339
+ <select id="page-title-size" class="w-full p-2 border rounded-md mt-1">
340
+ <option value="text-2xl">Small</option>
341
+ <option value="text-3xl">Medium</option>
342
+ <option value="text-4xl">Large</option>
343
+ <option value="text-5xl">XL</option>
344
+ <option value="text-6xl">2XL</option>
345
+ </select>
346
+ </div>
347
+ <div>
348
+ <label for="page-subtitle-size" class="text-sm font-medium">Subtitle Size</label>
349
+ <select id="page-subtitle-size" class="w-full p-2 border rounded-md mt-1">
350
+ <option value="text-base">Small</option>
351
+ <option value="text-lg">Medium</option>
352
+ <option value="text-xl">Large</option>
353
+ <option value="text-2xl">XL</option>
354
+ </select>
355
+ </div>
356
+ </div>
357
+ <div>
358
+ <label class="text-sm font-medium">Text Alignment</label>
359
+ <div id="page-title-alignment" class="flex items-center space-x-4 mt-2 p-1 bg-gray-100 rounded-lg">
360
+ <label class="flex-1 text-center p-1 rounded-md cursor-pointer has-[:checked]:bg-white has-[:checked]:shadow-sm">
361
+ <input type="radio" name="alignment" value="left" class="sr-only"> Left
362
+ </label>
363
+ <label class="flex-1 text-center p-1 rounded-md cursor-pointer has-[:checked]:bg-white has-[:checked]:shadow-sm">
364
+ <input type="radio" name="alignment" value="center" class="sr-only"> Center
365
+ </label>
366
+ <label class="flex-1 text-center p-1 rounded-md cursor-pointer has-[:checked]:bg-white has-[:checked]:shadow-sm">
367
+ <input type="radio" name="alignment" value="right" class="sr-only"> Right
368
+ </label>
369
+ </div>
370
+ </div>
371
+ </div>
372
+ </div>
373
+ </div>
374
+
375
+ <div id="panel-info-cards" class="control-panel">
376
+ <div class="flex justify-between items-center mb-4">
377
+ <h3 class="mb-0 pb-0 border-b-0">ℹ️ Information Cards</h3>
378
+ <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="infoCards">
379
+ <i class="fas fa-code mr-1"></i> Get Code
380
+ </button>
381
+ </div>
382
+ <div class="flex items-center space-x-2 mb-4 border-b pb-4">
383
+ <input type="checkbox" id="info-cards-toggle" class="h-4 w-4 rounded">
384
+ <label for="info-cards-toggle" class="font-medium">Enable Info Cards Section</label>
385
+ </div>
386
+
387
+ <div id="info-cards-list" class="space-y-3"></div>
388
+
389
+ <button id="add-info-card-btn" class="mt-4 w-full flex items-center justify-center space-x-2 bg-green-600 text-white font-bold py-2 px-4 rounded-md hover:bg-green-700 transition">
390
+ <i class="fas fa-plus"></i>
391
+ <span>Add New Info Card</span>
392
+ </button>
393
+ </div>
394
+
395
+
396
+ <div id="panel-custom-html" class="control-panel">
397
+ <div class="flex justify-between items-center mb-6">
398
+ <h3 class="mb-0 pb-0 border-b-0"> </> Custom HTML</h3>
399
+ <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">
400
+ <i class="fas fa-code mr-1"></i> Get Code
401
+ </button>
402
+ </div>
403
+ <div class="space-y-4">
404
+ <div class="flex items-center space-x-2 border-b pb-4">
405
+ <input type="checkbox" id="custom-html-toggle" class="h-4 w-4 rounded">
406
+ <label for="custom-html-toggle" class="font-medium">Enable Custom HTML Section</label>
407
+ </div>
408
+ <div id="custom-html-builder">
409
+ <label for="custom-html-content" class="text-sm font-medium">HTML Content</label>
410
+ <p class="text-xs text-gray-500 mb-2">Paste any valid HTML. Be cautious, as invalid code can break the page layout.</p>
411
+ <textarea id="custom-html-content" rows="10" class="w-full p-2 border rounded-md font-mono text-sm"></textarea>
412
+ </div>
413
+ </div>
414
+ </div>
415
+
416
+ </div>
417
+ </div>
418
+ </aside>
419
+
420
+
421
+ <main class="w-2/3 bg-gray-200 p-4 flex flex-col items-center justify-center overflow-hidden">
422
+ <div id="preview-container" class="bg-white shadow-lg rounded-lg w-full h-full overflow-hidden">
423
+ <iframe id="preview-iframe" class="preview-iframe"></iframe>
424
+ </div>
425
+ </main>
426
+
427
+ </div>
428
+ </div>
429
+ <div id="toast-notification" class="toast"></div>
430
+
431
+ <div id="code-modal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-75 overflow-y-auto h-full w-full z-50">
432
+ <div class="relative top-10 mx-auto p-5 border w-11/12 md:w-2/3 shadow-lg rounded-md bg-white">
433
+ <div class="flex justify-between items-center border-b pb-3">
434
+ <h3 id="code-modal-title" class="text-lg leading-6 font-medium text-gray-900">Component Code</h3>
435
+ <button id="close-code-modal-btn" class="text-gray-400 hover:text-gray-600">&times;</button>
436
+ </div>
437
+ <div class="mt-4 space-y-4">
438
+ <div>
439
+ <label class="font-semibold text-gray-700">HTML</label>
440
+ <pre id="code-modal-html" class="code-modal-pre"><code></code></pre>
441
+ </div>
442
+ <div>
443
+ <label class="font-semibold text-gray-700">CSS</label>
444
+ <pre id="code-modal-css" class="code-modal-pre"><code></code></pre>
445
+ </div>
446
+ <div>
447
+ <label class="font-semibold text-gray-700">JavaScript</label>
448
+ <pre id="code-modal-js" class="code-modal-pre"><code></code></pre>
449
+ </div>
450
+ </div>
451
+ <div class="items-center px-4 py-3 mt-4 text-right bg-gray-50 -mx-5 -mb-5 rounded-b-md">
452
+ <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">
453
+ Download .zip
454
+ </button>
455
+ <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">
456
+ Close
457
+ </button>
458
+ </div>
459
+ </div>
460
+ </div>
461
+
462
+
463
+ <script>
464
+ document.addEventListener('DOMContentLoaded', () => {
465
+ // State object to hold all configurations
466
+ const config = {
467
+ globalSettings: {
468
+ colors: {
469
+ primary: '#3b82f6',
470
+ secondary: '#10b981',
471
+ text: '#374151',
472
+ heading: '#111827',
473
+ },
474
+ typography: {
475
+ fontFamily: "'Inter', sans-serif",
476
+ }
477
+ },
478
+ componentOrder: [
479
+ 'pageTitle',
480
+ 'infoCards',
481
+ 'customHtml'
482
+ ],
483
+ pageTitle: {
484
+ enabled: true,
485
+ title: 'Welcome to Our Page',
486
+ subtitle: 'This is a subtitle describing the page content. You can edit this text in the control panel.',
487
+ alignment: 'center',
488
+ titleSize: 'text-4xl',
489
+ subtitleSize: 'text-lg'
490
+ },
491
+ infoCards: {
492
+ enabled: true,
493
+ items: [
494
+ {
495
+ id: Date.now(),
496
+ imageUrl: 'https://images.unsplash.com/photo-1517694712202-14dd9538aa97?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=60',
497
+ title: 'Enhanced Information Card',
498
+ date: '2025-08-15',
499
+ batch: 'New',
500
+ summary: 'This card is now more powerful with new features like image positioning, a CTA button, and smooth animations.',
501
+ content: '<p>This is the <strong>detailed information</strong> that appears when you expand the card. It supports <em>rich text</em>, lists, and more, thanks to CKEditor.</p><ul><li>Easy to edit.</li><li>Visually appealing.</li><li>Fully customizable.</li></ul>',
502
+ button: {
503
+ enabled: true,
504
+ text: 'Learn More',
505
+ url: '#',
506
+ },
507
+ imagePosition: 'left',
508
+ defaultExpanded: false,
509
+ },
510
+ {
511
+ id: Date.now() + 1,
512
+ imageUrl: 'https://images.unsplash.com/photo-1499951360447-b19be8fe80f5?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=800&q=60',
513
+ title: 'Older Post Example',
514
+ date: '2025-08-10',
515
+ batch: 'Hot',
516
+ summary: 'This is an example of an older card to demonstrate the sorting functionality.',
517
+ content: '<p>This content belongs to the older card.</p>',
518
+ button: {
519
+ enabled: true,
520
+ text: 'Read Story',
521
+ url: '#',
522
+ },
523
+ imagePosition: 'right',
524
+ defaultExpanded: false,
525
+ }
526
+ ]
527
+ },
528
+ customHtml: {
529
+ enabled: false,
530
+ content: ''
531
+ }
532
+ };
533
+
534
+ const componentNames = {
535
+ pageTitle: 'Page Title',
536
+ infoCards: 'Info Cards',
537
+ customHtml: 'Custom HTML'
538
+ };
539
+
540
+ // UI Element References
541
+ let editors = {};
542
+ const ui = {
543
+ previewIframe: document.getElementById('preview-iframe'),
544
+ controls: {
545
+ nav: document.getElementById('controls-nav'),
546
+ panels: document.getElementById('controls-panels'),
547
+ },
548
+ globalSettings: {
549
+ primaryColor: document.getElementById('global-color-primary'),
550
+ secondaryColor: document.getElementById('global-color-secondary'),
551
+ textColor: document.getElementById('global-color-text'),
552
+ headingColor: document.getElementById('global-color-heading'),
553
+ fontFamily: document.getElementById('global-font-family'),
554
+ applyBtn: document.getElementById('apply-global-settings'),
555
+ },
556
+ layout: {
557
+ container: document.getElementById('layout-builder-container'),
558
+ panel: document.getElementById('panel-layout')
559
+ },
560
+ pageTitle: {
561
+ toggle: document.getElementById('page-title-toggle'),
562
+ title: document.getElementById('page-title-text'),
563
+ subtitle: document.getElementById('page-subtitle-text'),
564
+ alignment: document.getElementById('page-title-alignment'),
565
+ titleSize: document.getElementById('page-title-size'),
566
+ subtitleSize: document.getElementById('page-subtitle-size'),
567
+ },
568
+ infoCards: {
569
+ toggle: document.getElementById('info-cards-toggle'),
570
+ listContainer: document.getElementById('info-cards-list'),
571
+ addBtn: document.getElementById('add-info-card-btn'),
572
+ },
573
+ customHtml: {
574
+ toggle: document.getElementById('custom-html-toggle'),
575
+ content: document.getElementById('custom-html-content'),
576
+ },
577
+ buttons: {
578
+ desktop: document.getElementById('desktop-btn'),
579
+ tablet: document.getElementById('tablet-btn'),
580
+ mobile: document.getElementById('mobile-btn'),
581
+ import: document.getElementById('import-btn'),
582
+ importFile: document.getElementById('import-file-input'),
583
+ },
584
+ exportMenu: {
585
+ container: document.getElementById('export-menu-container'),
586
+ button: document.getElementById('export-menu-btn'),
587
+ dropdown: document.getElementById('export-dropdown'),
588
+ copyCombined: document.getElementById('copy-combined-code'),
589
+ copyHtml: document.getElementById('copy-html'),
590
+ copyCss: document.getElementById('copy-css'),
591
+ copyJs: document.getElementById('copy-js'),
592
+ downloadZip: document.getElementById('download-zip-btn'),
593
+ },
594
+ codeModal: {
595
+ modal: document.getElementById('code-modal'),
596
+ title: document.getElementById('code-modal-title'),
597
+ htmlContainer: document.getElementById('code-modal-html'),
598
+ cssContainer: document.getElementById('code-modal-css'),
599
+ jsContainer: document.getElementById('code-modal-js'),
600
+ htmlCode: document.querySelector('#code-modal-html code'),
601
+ cssCode: document.querySelector('#code-modal-css code'),
602
+ jsCode: document.querySelector('#code-modal-js code'),
603
+ downloadBtn: document.getElementById('download-component-zip-btn'),
604
+ closeBtns: [document.getElementById('close-code-modal-btn'), document.getElementById('close-code-modal-btn-2')],
605
+ },
606
+ previewContainer: document.getElementById('preview-container'),
607
+ };
608
+
609
+ // --- Event Listeners ---
610
+ function setupEventListeners() {
611
+ ui.controls.nav.addEventListener('click', (e) => {
612
+ const button = e.target.closest('.control-nav-button');
613
+ if (!button) return;
614
+ const targetPanelId = button.dataset.target;
615
+ ui.controls.nav.querySelectorAll('.control-nav-button').forEach(btn => btn.classList.remove('active'));
616
+ button.classList.add('active');
617
+ ui.controls.panels.querySelectorAll('.control-panel').forEach(panel => {
618
+ panel.classList.toggle('active', `#${panel.id}` === targetPanelId);
619
+ });
620
+ });
621
+
622
+ // Global Settings Listeners
623
+ ui.globalSettings.primaryColor.addEventListener('input', e => { config.globalSettings.colors.primary = e.target.value; renderAll(); });
624
+ ui.globalSettings.secondaryColor.addEventListener('input', e => { config.globalSettings.colors.secondary = e.target.value; renderAll(); });
625
+ ui.globalSettings.textColor.addEventListener('input', e => { config.globalSettings.colors.text = e.target.value; renderAll(); });
626
+ ui.globalSettings.headingColor.addEventListener('input', e => { config.globalSettings.colors.heading = e.target.value; renderAll(); });
627
+ ui.globalSettings.fontFamily.addEventListener('change', e => { config.globalSettings.typography.fontFamily = e.target.value; renderAll(); });
628
+ ui.globalSettings.applyBtn.addEventListener('click', () => {
629
+ renderAll();
630
+ showToast('Global styles applied!');
631
+ });
632
+
633
+ // Layout Controls
634
+ ui.layout.panel.addEventListener('click', handleLayoutControlsClick);
635
+ setupDragAndDrop();
636
+
637
+ // --- Component Listeners: Page Title ---
638
+ ui.pageTitle.toggle.addEventListener('change', e => { config.pageTitle.enabled = e.target.checked; renderAll(); });
639
+ ui.pageTitle.title.addEventListener('input', e => { config.pageTitle.title = e.target.value; renderAll(); });
640
+ ui.pageTitle.subtitle.addEventListener('input', e => { config.pageTitle.subtitle = e.target.value; renderAll(); });
641
+ ui.pageTitle.alignment.addEventListener('change', e => {
642
+ if (e.target.name === 'alignment') {
643
+ config.pageTitle.alignment = e.target.value;
644
+ renderAll();
645
+ }
646
+ });
647
+ ui.pageTitle.titleSize.addEventListener('change', e => { config.pageTitle.titleSize = e.target.value; renderAll(); });
648
+ ui.pageTitle.subtitleSize.addEventListener('change', e => { config.pageTitle.subtitleSize = e.target.value; renderAll(); });
649
+
650
+ // --- Component Listeners: Info Cards ---
651
+ ui.infoCards.toggle.addEventListener('change', e => { config.infoCards.enabled = e.target.checked; renderAll(); });
652
+ ui.infoCards.addBtn.addEventListener('click', handleAddInfoCard);
653
+ ui.infoCards.listContainer.addEventListener('click', handleInfoCardListClick);
654
+ ui.infoCards.listContainer.addEventListener('input', handleInfoCardInputChange);
655
+ setupInfoCardDragAndDrop();
656
+
657
+ // --- Component Listeners: Custom HTML ---
658
+ ui.customHtml.toggle.addEventListener('change', e => { config.customHtml.enabled = e.target.checked; renderAll(); });
659
+ ui.customHtml.content.addEventListener('input', e => { config.customHtml.content = e.target.value; renderAll(); });
660
+
661
+ // Preview & Export
662
+ ui.buttons.desktop.addEventListener('click', () => setPreviewMode('desktop'));
663
+ ui.buttons.tablet.addEventListener('click', () => setPreviewMode('tablet'));
664
+ ui.buttons.mobile.addEventListener('click', () => setPreviewMode('mobile'));
665
+ ui.exportMenu.button.addEventListener('click', (e) => { e.stopPropagation(); ui.exportMenu.dropdown.classList.toggle('hidden'); });
666
+ window.addEventListener('click', (e) => { if (!ui.exportMenu.container.contains(e.target)) { ui.exportMenu.dropdown.classList.add('hidden'); } });
667
+
668
+ const copyAction = (e, dataGetter, message) => {
669
+ e.preventDefault();
670
+ navigator.clipboard.writeText(dataGetter()).then(() => showToast(message));
671
+ ui.exportMenu.dropdown.classList.add('hidden');
672
+ };
673
+
674
+ ui.exportMenu.copyCombined.addEventListener('click', (e) => copyAction(e, getCombinedCode, 'Combined code copied!'));
675
+ ui.exportMenu.copyHtml.addEventListener('click', (e) => copyAction(e, getAllHtml, 'All HTML copied!'));
676
+ ui.exportMenu.copyCss.addEventListener('click', (e) => copyAction(e, getFullCSS, 'All CSS copied!'));
677
+ ui.exportMenu.copyJs.addEventListener('click', (e) => copyAction(e, getFullJS, 'All JS copied!'));
678
+ ui.exportMenu.downloadZip.addEventListener('click', (e) => { e.preventDefault(); generatePageZip(); ui.exportMenu.dropdown.classList.add('hidden'); });
679
+
680
+ // Import
681
+ ui.buttons.import.addEventListener('click', () => ui.buttons.importFile.click());
682
+ ui.buttons.importFile.addEventListener('change', handleFileImport);
683
+
684
+ // Code Modal Listeners
685
+ ui.controls.panels.addEventListener('click', handleGetCodeClick);
686
+ ui.codeModal.closeBtns.forEach(btn => btn.addEventListener('click', () => ui.codeModal.modal.classList.add('hidden')));
687
+ }
688
+
689
+ // --- LAYOUT CONTROLS ---
690
+ function renderLayoutControls() {
691
+ ui.layout.container.innerHTML = config.componentOrder.map((key, index) => {
692
+ const total = config.componentOrder.length;
693
+ return `
694
+ <div class="layout-item p-3 border rounded-md bg-white flex items-center justify-between" draggable="true" data-key="${key}">
695
+ <span class="font-medium text-sm"><i class="fas fa-grip-vertical mr-3 text-gray-400"></i> ${componentNames[key]}</span>
696
+ <div class="item-toolbar mb-0">
697
+ <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>
698
+ <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>
699
+ </div>
700
+ </div>`;
701
+ }).join('');
702
+ }
703
+
704
+ function handleLayoutControlsClick(e) {
705
+ const button = e.target.closest('button');
706
+ if (!button) return;
707
+ const index = parseInt(button.dataset.index, 10);
708
+ const order = config.componentOrder;
709
+ if (button.classList.contains('reorder-layout-up-btn') && index > 0) {
710
+ [order[index], order[index - 1]] = [order[index - 1], order[index]];
711
+ } else if (button.classList.contains('reorder-layout-down-btn') && index < order.length - 1) {
712
+ [order[index], order[index + 1]] = [order[index + 1], order[index]];
713
+ }
714
+ renderLayoutControls();
715
+ renderAll();
716
+ }
717
+
718
+ function setupDragAndDrop() {
719
+ let draggedItem = null;
720
+ ui.layout.container.addEventListener('dragstart', e => {
721
+ draggedItem = e.target;
722
+ setTimeout(() => e.target.style.display = 'none', 0);
723
+ });
724
+ ui.layout.container.addEventListener('dragend', () => {
725
+ setTimeout(() => {
726
+ draggedItem.style.display = 'flex';
727
+ draggedItem = null;
728
+ }, 0);
729
+ });
730
+ ui.layout.container.addEventListener('dragover', e => {
731
+ e.preventDefault();
732
+ const afterElement = [...ui.layout.container.querySelectorAll('.layout-item:not(.dragging)')].reduce((closest, child) => {
733
+ const box = child.getBoundingClientRect();
734
+ const offset = e.clientY - box.top - box.height / 2;
735
+ return (offset < 0 && offset > closest.offset) ? { offset: offset, element: child } : closest;
736
+ }, { offset: Number.NEGATIVE_INFINITY }).element;
737
+ if (afterElement == null) {
738
+ ui.layout.container.appendChild(draggedItem);
739
+ } else {
740
+ ui.layout.container.insertBefore(draggedItem, afterElement);
741
+ }
742
+ });
743
+ ui.layout.container.addEventListener('drop', e => {
744
+ e.preventDefault();
745
+ config.componentOrder = [...ui.layout.container.querySelectorAll('.layout-item')].map(item => item.dataset.key);
746
+ renderLayoutControls();
747
+ renderAll();
748
+ });
749
+ }
750
+
751
+ // --- Info Cards UI & Logic ---
752
+ function renderInfoCardControls() {
753
+ ui.infoCards.listContainer.innerHTML = config.infoCards.items.map((card, index) => {
754
+ const cardId = `info-card-${card.id}`;
755
+ return `
756
+ <div class="info-card-item-controls border border-gray-300 rounded-md" data-id="${card.id}" draggable="true">
757
+ <div class="controls-header bg-gray-100 p-2 rounded-t-md cursor-pointer flex justify-between items-center">
758
+ <span class="font-semibold text-sm flex items-center">
759
+ <i class="fas fa-grip-vertical mr-2 text-gray-400"></i>
760
+ ${card.title || 'New Card'}
761
+ </span>
762
+ <div>
763
+ <button class="text-red-500 hover:text-red-700 remove-info-card-btn p-1"><i class="fas fa-trash-alt"></i></button>
764
+ <button class="text-gray-500 toggle-accordion-btn p-1"><i class="fas fa-chevron-down"></i></button>
765
+ </div>
766
+ </div>
767
+ <div class="controls-body p-4 space-y-4">
768
+ <h4 class="control-group-label">Content</h4>
769
+ <div class="grid grid-cols-2 gap-4">
770
+ <div>
771
+ <label class="text-sm font-medium">Title</label>
772
+ <input type="text" data-prop="title" value="${card.title}" class="w-full p-2 border rounded-md mt-1">
773
+ </div>
774
+ <div>
775
+ <label class="text-sm font-medium">Date</label>
776
+ <input type="date" data-prop="date" value="${card.date}" class="w-full p-2 border rounded-md mt-1">
777
+ </div>
778
+ </div>
779
+ <div>
780
+ <label class="text-sm font-medium">Image URL</label>
781
+ <input type="text" data-prop="imageUrl" value="${card.imageUrl}" class="w-full p-2 border rounded-md mt-1" placeholder="https://example.com/image.jpg">
782
+ </div>
783
+ <div>
784
+ <label class="text-sm font-medium">Summary</label>
785
+ <textarea data-prop="summary" rows="3" class="w-full p-2 border rounded-md mt-1">${card.summary}</textarea>
786
+ </div>
787
+ <div>
788
+ <label class="text-sm font-medium">Full Content (Details)</label>
789
+ <div class="mt-1"><textarea id="${cardId}-content">${card.content}</textarea></div>
790
+ </div>
791
+ <h4 class="control-group-label">Button (Optional)</h4>
792
+ <div class="space-y-4">
793
+ <div class="flex items-center space-x-2">
794
+ <input type="checkbox" data-prop="button.enabled" ${card.button.enabled ? 'checked' : ''} class="h-4 w-4 rounded">
795
+ <label class="text-sm font-medium">Enable Button</label>
796
+ </div>
797
+ <div class="grid grid-cols-2 gap-4">
798
+ <div>
799
+ <label class="text-sm font-medium">Button Text</label>
800
+ <input type="text" data-prop="button.text" value="${card.button.text}" class="w-full p-2 border rounded-md mt-1">
801
+ </div>
802
+ <div>
803
+ <label class="text-sm font-medium">Button URL</label>
804
+ <input type="text" data-prop="button.url" value="${card.button.url}" class="w-full p-2 border rounded-md mt-1" placeholder="#">
805
+ </div>
806
+ </div>
807
+ </div>
808
+ <h4 class="control-group-label">Appearance & Behavior</h4>
809
+ <div class="grid grid-cols-2 gap-4">
810
+ <div>
811
+ <label class="text-sm font-medium">Image Position</label>
812
+ <select data-prop="imagePosition" class="w-full p-2 border rounded-md mt-1">
813
+ <option value="left" ${card.imagePosition === 'left' ? 'selected' : ''}>Left</option>
814
+ <option value="right" ${card.imagePosition === 'right' ? 'selected' : ''}>Right</option>
815
+ <option value="top" ${card.imagePosition === 'top' ? 'selected' : ''}>Top</option>
816
+ </select>
817
+ </div>
818
+ <div>
819
+ <label class="text-sm font-medium">Batch</label>
820
+ <select data-prop="batch" class="w-full p-2 border rounded-md mt-1">
821
+ <option value="">None</option>
822
+ <option value="New" ${card.batch === 'New' ? 'selected' : ''}>New</option>
823
+ <option value="Hot" ${card.batch === 'Hot' ? 'selected' : ''}>Hot</option>
824
+ <option value="Premium" ${card.batch === 'Premium' ? 'selected' : ''}>Premium</option>
825
+ <option value="Live" ${card.batch === 'Live' ? 'selected' : ''}>Live</option>
826
+ <option value="Latest" ${card.batch === 'Latest' ? 'selected' : ''}>Latest</option>
827
+ </select>
828
+ </div>
829
+ </div>
830
+ <div class="flex items-center space-x-2">
831
+ <input type="checkbox" data-prop="defaultExpanded" ${card.defaultExpanded ? 'checked' : ''} class="h-4 w-4 rounded">
832
+ <label class="text-sm font-medium">Expanded by default</label>
833
+ </div>
834
+ </div>
835
+ </div>
836
+ `;
837
+ }).join('');
838
+ initEditorsForInfoCards();
839
+ }
840
+
841
+ function initEditorsForInfoCards() {
842
+ Object.values(editors).forEach(editor => editor.destroy());
843
+ editors = {};
844
+ config.infoCards.items.forEach(card => {
845
+ const textarea = document.getElementById(`info-card-${card.id}-content`);
846
+ if (textarea) {
847
+ ClassicEditor
848
+ .create(textarea)
849
+ .then(editor => {
850
+ editors[card.id] = editor;
851
+ editor.model.document.on('change:data', () => {
852
+ const cardToUpdate = config.infoCards.items.find(c => c.id === card.id);
853
+ if (cardToUpdate) {
854
+ cardToUpdate.content = editor.getData();
855
+ renderAll();
856
+ }
857
+ });
858
+ })
859
+ .catch(error => console.error('CKEditor initialization error:', error));
860
+ }
861
+ });
862
+ }
863
+
864
+ function handleAddInfoCard() {
865
+ const newCard = {
866
+ id: Date.now(),
867
+ imageUrl: '',
868
+ title: 'New Information Card',
869
+ date: '',
870
+ batch: '',
871
+ summary: 'A brief summary of the new card.',
872
+ content: '<p>Detailed content goes here.</p>',
873
+ button: { enabled: false, text: 'Click Me', url: '#' },
874
+ imagePosition: 'left',
875
+ defaultExpanded: false,
876
+ };
877
+ config.infoCards.items.push(newCard);
878
+ renderInfoCardControls();
879
+ renderAll();
880
+ }
881
+
882
+ function handleInfoCardListClick(e) {
883
+ const removeBtn = e.target.closest('.remove-info-card-btn');
884
+ const toggleBtn = e.target.closest('.toggle-accordion-btn');
885
+
886
+ if (removeBtn) {
887
+ const cardElement = removeBtn.closest('.info-card-item-controls');
888
+ const cardId = parseInt(cardElement.dataset.id, 10);
889
+ if (confirm('Are you sure you want to delete this card?')) {
890
+ config.infoCards.items = config.infoCards.items.filter(card => card.id !== cardId);
891
+ renderInfoCardControls();
892
+ renderAll();
893
+ }
894
+ } else if (toggleBtn) {
895
+ const cardElement = toggleBtn.closest('.info-card-item-controls');
896
+ cardElement.classList.toggle('open');
897
+ const icon = toggleBtn.querySelector('i');
898
+ icon.classList.toggle('fa-chevron-down');
899
+ icon.classList.toggle('fa-chevron-up');
900
+ }
901
+ }
902
+
903
+ function handleInfoCardInputChange(e) {
904
+ const input = e.target;
905
+ const propPath = input.dataset.prop;
906
+ if (!propPath) return;
907
+
908
+ const cardElement = input.closest('.info-card-item-controls');
909
+ const cardId = parseInt(cardElement.dataset.id, 10);
910
+ const card = config.infoCards.items.find(c => c.id === cardId);
911
+ if (!card) return;
912
+
913
+ let value = input.type === 'checkbox' ? input.checked : input.value;
914
+
915
+ const props = propPath.split('.');
916
+ let current = card;
917
+ for (let i = 0; i < props.length - 1; i++) {
918
+ current = current[props[i]];
919
+ }
920
+ current[props[props.length - 1]] = value;
921
+
922
+ if (propPath === 'title') {
923
+ cardElement.querySelector('.controls-header span').textContent = value || 'New Card';
924
+ }
925
+
926
+ renderAll();
927
+ }
928
+
929
+ function setupInfoCardDragAndDrop() {
930
+ let draggedItem = null;
931
+ ui.infoCards.listContainer.addEventListener('dragstart', e => {
932
+ if (e.target.classList.contains('info-card-item-controls')) {
933
+ draggedItem = e.target;
934
+ setTimeout(() => e.target.style.opacity = '0.5', 0);
935
+ }
936
+ });
937
+ ui.infoCards.listContainer.addEventListener('dragend', () => {
938
+ if(draggedItem) {
939
+ setTimeout(() => {
940
+ draggedItem.style.opacity = '1';
941
+ draggedItem = null;
942
+ }, 0);
943
+ }
944
+ });
945
+ ui.infoCards.listContainer.addEventListener('dragover', e => {
946
+ e.preventDefault();
947
+ if (!draggedItem) return;
948
+ const afterElement = [...ui.infoCards.listContainer.querySelectorAll('.info-card-item-controls:not(.dragging)')].reduce((closest, child) => {
949
+ const box = child.getBoundingClientRect();
950
+ const offset = e.clientY - box.top - box.height / 2;
951
+ return (offset < 0 && offset > closest.offset) ? { offset: offset, element: child } : closest;
952
+ }, { offset: Number.NEGATIVE_INFINITY }).element;
953
+ if (afterElement == null) {
954
+ ui.infoCards.listContainer.appendChild(draggedItem);
955
+ } else {
956
+ ui.infoCards.listContainer.insertBefore(draggedItem, afterElement);
957
+ }
958
+ });
959
+ ui.infoCards.listContainer.addEventListener('drop', e => {
960
+ e.preventDefault();
961
+ if (!draggedItem) return;
962
+ const newOrder = [...ui.infoCards.listContainer.querySelectorAll('.info-card-item-controls')].map(item => parseInt(item.dataset.id, 10));
963
+ config.infoCards.items.sort((a, b) => newOrder.indexOf(a.id) - newOrder.indexOf(b.id));
964
+ renderAll();
965
+ });
966
+ }
967
+
968
+
969
+ // --- HTML Generation Logic ---
970
+ const componentGenerators = {
971
+ pageTitle: generatePageTitleHTML,
972
+ infoCards: generateInfoCardsHTML,
973
+ customHtml: generateCustomHtmlHTML
974
+ };
975
+
976
+ function getAllHtml() {
977
+ return config.componentOrder
978
+ .map(key => componentGenerators[key] ? componentGenerators[key]() : '')
979
+ .filter(Boolean)
980
+ .join('\n\n');
981
+ }
982
+
983
+ function generatePageTitleHTML() {
984
+ if (!config.pageTitle.enabled) return '';
985
+ const { title, subtitle, alignment, titleSize, subtitleSize } = config.pageTitle;
986
+ return `
987
+ <div class="page-title-container" data-alignment="${alignment}">
988
+ <h1 class="page-main-title ${titleSize}">${title}</h1>
989
+ <p class="page-subtitle ${subtitleSize}">${subtitle}</p>
990
+ </div>`;
991
+ }
992
+
993
+ function generateInfoCardsHTML() {
994
+ if (!config.infoCards.enabled) return '';
995
+ const cardsHtml = config.infoCards.items.map(card => {
996
+ const { imageUrl, title, summary, content, button, imagePosition, defaultExpanded, date, batch } = card;
997
+ const expandedClass = defaultExpanded ? 'expanded' : '';
998
+ const buttonHtml = button.enabled ? `<a href="${button.url}" class="info-card-cta">${button.text}</a>` : '';
999
+ const dateHtml = date ? `<p class="info-card-date">${date}</p>` : '';
1000
+ const batchHtml = batch ? `<div class="info-card-batch batch-${batch.toLowerCase()}">${batch}</div>` : '';
1001
+
1002
+ return `
1003
+ <div class="info-card ${expandedClass}" data-image-position="${imagePosition}">
1004
+ ${batchHtml}
1005
+ <div class="info-card-header">
1006
+ <img src="${imageUrl}" alt="${title}" class="info-card-image">
1007
+ <div class="info-card-summary-content">
1008
+ <h4 class="info-card-title">${title}</h4>
1009
+ ${dateHtml}
1010
+ <p class="info-card-summary">${summary}</p>
1011
+ </div>
1012
+ <i class="fas fa-chevron-down info-card-icon"></i>
1013
+ </div>
1014
+ <div class="info-card-body">
1015
+ <div class="info-card-body-content">
1016
+ ${content}
1017
+ ${buttonHtml}
1018
+ </div>
1019
+ </div>
1020
+ </div>`;
1021
+ }).join('');
1022
+
1023
+ const viewToggleHtml = `
1024
+ <div class="info-card-view-toggle">
1025
+ <button class="active" data-view="card" title="Card View"><i class="fas fa-th-large"></i></button>
1026
+ <button data-view="list" title="List View"><i class="fas fa-list"></i></button>
1027
+ </div>
1028
+ `;
1029
+ return `<div class="info-cards-container p-4"> ${viewToggleHtml} <div class="space-y-4">${cardsHtml}</div></div>`;
1030
+ }
1031
+
1032
+
1033
+ function generateCustomHtmlHTML() {
1034
+ if (!config.customHtml.enabled) return '';
1035
+ return `<div class="custom-html-section">${config.customHtml.content}</div>`;
1036
+ }
1037
+
1038
+ function generateComponentCSS(targetKey = null) {
1039
+ const { colors, typography } = config.globalSettings;
1040
+ const css = {};
1041
+
1042
+ css.global = `
1043
+ /* --- Global --- */
1044
+ :root {
1045
+ --primary-color: ${colors.primary};
1046
+ --secondary-color: ${colors.secondary};
1047
+ --text-color: ${colors.text};
1048
+ --heading-color: ${colors.heading};
1049
+ --font-family: ${typography.fontFamily};
1050
+ }
1051
+ body {
1052
+ font-family: var(--font-family);
1053
+ color: var(--text-color);
1054
+ margin: 0;
1055
+ background-color: #f0f2f5;
1056
+ }
1057
+ h1,h2,h3,h4,h5,h6 { color: var(--heading-color); }
1058
+ `;
1059
+ if(config.pageTitle.enabled) css.pageTitle = `
1060
+ /* --- Page Title Section --- */
1061
+ .page-title-container { padding: 2.5rem 1rem; }
1062
+ .page-title-container[data-alignment="left"] { text-align: left; }
1063
+ .page-title-container[data-alignment="center"] { text-align: center; }
1064
+ .page-title-container[data-alignment="right"] { text-align: right; }
1065
+ .page-main-title { font-weight: 800; color: var(--heading-color); line-height: 1.2; margin-bottom: 0.75rem; }
1066
+ .page-subtitle { color: var(--text-color); max-width: 650px; opacity: 0.9; }
1067
+ .page-title-container[data-alignment="center"] .page-subtitle { margin-left: auto; margin-right: auto; }
1068
+ .page-title-container[data-alignment="right"] .page-subtitle { margin-left: auto; }
1069
+ `;
1070
+ if(config.infoCards.enabled) css.infoCards = `
1071
+ /* --- Info Card Section --- */
1072
+ .info-card { position: relative; background-color: white; border-radius: 0.5rem; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1); overflow: hidden; }
1073
+ .info-card-header { display: flex; align-items: center; gap: 1rem; padding: 1rem; cursor: pointer; transition: background-color 0.2s; }
1074
+ .info-card-header:hover { background-color: #f9fafb; }
1075
+ .info-card-summary-content { flex-grow: 1; }
1076
+ .info-card-title { font-size: 1.125rem; font-weight: 600; color: var(--heading-color); margin-bottom: 0.25rem; }
1077
+ .info-card-date { font-size: 0.75rem; color: #6b7280; margin-bottom: 0.5rem; }
1078
+ .info-card-summary { font-size: 0.875rem; color: var(--text-color); opacity: 0.9; }
1079
+ .info-card-icon { transition: transform 0.4s ease; }
1080
+ .info-card.expanded .info-card-icon { transform: rotate(180deg); }
1081
+
1082
+ /* Batch Styles */
1083
+ .info-card-batch { position: absolute; top: 0.75rem; right: 0.75rem; padding: 0.25rem 0.6rem; font-size: 0.7rem; font-weight: bold; color: white; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.5px; }
1084
+ .batch-new { background-color: #3b82f6; }
1085
+ .batch-hot { background-color: #ef4444; }
1086
+ .batch-premium { background-color: #a855f7; }
1087
+ .batch-live { background-color: #22c55e; }
1088
+ .batch-latest { background-color: #f97316; }
1089
+
1090
+ /* Image Positions */
1091
+ .info-card[data-image-position="right"] .info-card-header { flex-direction: row-reverse; }
1092
+ .info-card[data-image-position="top"] .info-card-header { flex-direction: column; align-items: flex-start; }
1093
+ .info-card[data-image-position="top"] .info-card-image { width: 100%; height: auto; margin-bottom: 0.75rem; }
1094
+ .info-card[data-image-position="top"] .info-card-icon { align-self: flex-end; margin-top: -2.5rem; padding-right: 0.5rem; color: white; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }
1095
+
1096
+ .info-card-image {
1097
+ width: 128px;
1098
+ aspect-ratio: 16 / 9;
1099
+ object-fit: cover;
1100
+ border-radius: 0.375rem;
1101
+ flex-shrink: 0;
1102
+ }
1103
+
1104
+ /* Body Animation */
1105
+ .info-card-body {
1106
+ max-height: 0;
1107
+ overflow: hidden;
1108
+ transition: max-height 0.5s ease-in-out, padding 0.5s ease-in-out;
1109
+ padding: 0 1rem;
1110
+ }
1111
+ .info-card.expanded .info-card-body {
1112
+ max-height: 1500px; /* Should be larger than any possible content */
1113
+ padding: 1rem 1rem;
1114
+ border-top: 1px solid #e5e7eb;
1115
+ }
1116
+ .info-card-body-content { line-height: 1.6; }
1117
+
1118
+ /* CTA Button */
1119
+ .info-card-cta {
1120
+ display: inline-block;
1121
+ margin-top: 1.25rem;
1122
+ padding: 0.6rem 1.5rem;
1123
+ background-color: #ede9fe; /* Light Violet */
1124
+ color: #5b21b6; /* Dark Violet */
1125
+ text-decoration: none;
1126
+ border-radius: 9999px;
1127
+ font-weight: 600;
1128
+ transition: background-color 0.2s;
1129
+ }
1130
+ .info-card-cta:hover {
1131
+ background-color: #ddd6fe; /* Slightly darker violet on hover */
1132
+ }
1133
+
1134
+ /* CKEditor Content Styles */
1135
+ .info-card-body-content h1, .info-card-body-content h2, .info-card-body-content h3 { margin-top: 1rem; margin-bottom: 0.5rem; font-weight: 600; color: var(--heading-color); }
1136
+ .info-card-body-content p { margin-bottom: 1rem; }
1137
+ .info-card-body-content ul, .info-card-body-content ol { margin-left: 1.5rem; margin-bottom: 1rem; }
1138
+ .info-card-body-content ul { list-style-type: disc; }
1139
+ .info-card-body-content ol { list-style-type: decimal; }
1140
+ .info-card-body-content a:not(.info-card-cta) { text-decoration: underline; color: var(--primary-color); }
1141
+ .info-card-body-content blockquote { border-left: 4px solid #e5e7eb; padding-left: 1rem; margin: 1rem 0; font-style: italic; }
1142
+
1143
+ /* Mobile View Toggle */
1144
+ .info-card-view-toggle {
1145
+ display: none; /* Hidden by default */
1146
+ justify-content: center;
1147
+ margin-bottom: 1rem;
1148
+ background-color: #e5e7eb;
1149
+ padding: 0.25rem;
1150
+ border-radius: 999px;
1151
+ width: -moz-fit-content;
1152
+ width: fit-content;
1153
+ margin-left: auto;
1154
+ margin-right: auto;
1155
+ }
1156
+ .info-card-view-toggle button {
1157
+ border: none;
1158
+ background-color: transparent;
1159
+ border-radius: 999px;
1160
+ cursor: pointer;
1161
+ color: #4b5563;
1162
+ transition: all 0.2s;
1163
+ display: flex;
1164
+ align-items: center;
1165
+ justify-content: center;
1166
+ width: 38px;
1167
+ height: 38px;
1168
+ font-size: 1rem;
1169
+ }
1170
+ .info-card-view-toggle button.active {
1171
+ background-color: white;
1172
+ color: var(--primary-color);
1173
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
1174
+ }
1175
+
1176
+ /* Responsive adjustments */
1177
+ @media (max-width: 640px) {
1178
+ .info-card-view-toggle { display: flex; }
1179
+ .info-card-cta { width: 100%; text-align: center; }
1180
+
1181
+ /* Default Mobile View: Card Layout */
1182
+ .info-card[data-image-position="right"] .info-card-header,
1183
+ .info-card[data-image-position="left"] .info-card-header,
1184
+ .info-card-header {
1185
+ flex-direction: column;
1186
+ align-items: flex-start;
1187
+ }
1188
+ .info-card-image {
1189
+ width: 100%;
1190
+ height: auto;
1191
+ margin-bottom: 0.75rem;
1192
+ }
1193
+ .info-card-icon {
1194
+ align-self: flex-end;
1195
+ margin-top: -2.5rem;
1196
+ padding-right: 0.5rem;
1197
+ color: white;
1198
+ text-shadow: 0 1px 3px rgba(0,0,0,0.5);
1199
+ }
1200
+
1201
+ /* Optional Mobile View: List Layout */
1202
+ .info-cards-container.list-view-active .info-card-header {
1203
+ flex-direction: row;
1204
+ align-items: center;
1205
+ }
1206
+ .info-cards-container.list-view-active .info-card-image {
1207
+ width: 64px;
1208
+ height: 64px;
1209
+ aspect-ratio: 1/1;
1210
+ margin-bottom: 0;
1211
+ }
1212
+ .info-cards-container.list-view-active .info-card-icon {
1213
+ align-self: center;
1214
+ margin-top: 0;
1215
+ padding-right: 0;
1216
+ color: var(--text-color);
1217
+ text-shadow: none;
1218
+ }
1219
+ .info-cards-container.list-view-active .info-card-summary {
1220
+ display: -webkit-box;
1221
+ -webkit-line-clamp: 2;
1222
+ -webkit-box-orient: vertical;
1223
+ overflow: hidden;
1224
+ }
1225
+ }
1226
+ `;
1227
+ if(config.customHtml.enabled) css.customHtml = `/* --- Custom HTML Section --- */ .custom-html-section { padding: 1rem 0; }`;
1228
+
1229
+ return targetKey ? { global: css.global, component: css[targetKey] || '' } : css;
1230
+ }
1231
+
1232
+ function getFullCSS() {
1233
+ const cssObject = generateComponentCSS();
1234
+ const orderedCSS = config.componentOrder.map(key => cssObject[key]).filter(Boolean);
1235
+ return [cssObject.global, ...orderedCSS].join('\n\n');
1236
+ }
1237
+
1238
+ function generateComponentJavaScript(targetKey = null) {
1239
+ const js = {};
1240
+
1241
+ js.pageTitle = `/* No JS needed for Page Title */`;
1242
+
1243
+ js.infoCards = `
1244
+ /* --- Info Card Accordion Logic --- */
1245
+ document.querySelectorAll('.info-card-header').forEach(header => {
1246
+ header.addEventListener('click', () => {
1247
+ header.parentElement.classList.toggle('expanded');
1248
+ });
1249
+ });
1250
+
1251
+ /* --- Info Card View Toggle (Mobile) --- */
1252
+ const viewToggle = document.querySelector('.info-card-view-toggle');
1253
+ if (viewToggle) {
1254
+ const container = document.querySelector('.info-cards-container');
1255
+ const buttons = viewToggle.querySelectorAll('button');
1256
+
1257
+ viewToggle.addEventListener('click', (e) => {
1258
+ const button = e.target.closest('button');
1259
+ if (!button || button.classList.contains('active')) return;
1260
+
1261
+ const view = button.dataset.view;
1262
+
1263
+ buttons.forEach(btn => btn.classList.remove('active'));
1264
+ button.classList.add('active');
1265
+
1266
+ if (view === 'list') {
1267
+ container.classList.add('list-view-active');
1268
+ } else {
1269
+ container.classList.remove('list-view-active');
1270
+ }
1271
+ });
1272
+ }
1273
+ `;
1274
+ return targetKey ? (js[targetKey] || '') : js;
1275
+ }
1276
+
1277
+ function getFullJS() {
1278
+ const jsObject = generateComponentJavaScript();
1279
+ return config.componentOrder.map(key => jsObject[key] || '').filter(Boolean).join('\n\n');
1280
+ }
1281
+
1282
+ function getCombinedCode() {
1283
+ const htmlBody = getAllHtml();
1284
+ const css = getFullCSS();
1285
+ let js = getFullJS();
1286
+ if (js.trim()) {
1287
+ js = `document.addEventListener('DOMContentLoaded', () => { \n${js.trim()} \n});`;
1288
+ }
1289
+
1290
+ return `<!DOCTYPE html>
1291
+ <html lang="en">
1292
+ <head>
1293
+ <meta charset="UTF-8">
1294
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
1295
+ <title>Exported Page</title>
1296
+ <script src="https://cdn.tailwindcss.com"><\/script>
1297
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
1298
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
1299
+ <style> ${css} </style>
1300
+ </head>
1301
+ <body>
1302
+ ${htmlBody}
1303
+ ${js ? `<script>${js}<\/script>` : ''}
1304
+ </body>
1305
+ </html>`;
1306
+ }
1307
+
1308
+ // --- Rendering ---
1309
+ function renderAll() {
1310
+ const fullJs = getFullJS();
1311
+ const previewContent = `<!DOCTYPE html><html><head><title>Preview</title>
1312
+ <script src="https://cdn.tailwindcss.com"><\/script>
1313
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
1314
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
1315
+ <style>${getFullCSS()}</style></head><body>
1316
+ <div class="site-wrapper">${getAllHtml()}</div>
1317
+ <script>
1318
+ ${fullJs ? `document.addEventListener('DOMContentLoaded', () => { \n${fullJs} \n});` : ''}
1319
+ <\/script></body></html>`;
1320
+ ui.previewIframe.srcdoc = previewContent;
1321
+ }
1322
+
1323
+ // --- Utility Functions ---
1324
+ function setPreviewMode(mode) {
1325
+ ui.previewContainer.className = `bg-white shadow-lg rounded-lg w-full h-full overflow-hidden transition-all duration-300 preview-${mode}`;
1326
+ ['desktop', 'tablet', 'mobile'].forEach(m => {
1327
+ const btn = ui.buttons[m];
1328
+ btn.classList.toggle('bg-blue-500', m === mode);
1329
+ btn.classList.toggle('text-white', m === mode);
1330
+ btn.classList.toggle('bg-gray-200', m !== mode);
1331
+ });
1332
+ }
1333
+ function showToast(message) {
1334
+ const toast = document.getElementById('toast-notification');
1335
+ toast.textContent = message;
1336
+ toast.classList.add('show');
1337
+ setTimeout(() => { toast.classList.remove('show'); }, 3000);
1338
+ }
1339
+
1340
+ function generatePageZip() {
1341
+ const zip = new JSZip();
1342
+ const html = `<!DOCTYPE html>
1343
+ <html lang="en"><head>
1344
+ <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
1345
+ <title>Exported Page</title>
1346
+ <script src="https://cdn.tailwindcss.com"><\/script>
1347
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
1348
+ <link rel="stylesheet" href="style.css">
1349
+ </head>
1350
+ <body>
1351
+ ${getAllHtml()}
1352
+ <script src="script.js"><\/script>
1353
+ </body></html>`;
1354
+ const css = getFullCSS();
1355
+ const js = getFullJS();
1356
+
1357
+ zip.file("index.html", html);
1358
+ zip.file("style.css", css);
1359
+ if (js.trim()) {
1360
+ zip.file("script.js", `document.addEventListener('DOMContentLoaded', () => { \n${js} \n});`);
1361
+ }
1362
+ zip.generateAsync({type:"blob"}).then(content => saveAs(content, "exported-page.zip"));
1363
+ }
1364
+
1365
+ function handleFileImport(event) {
1366
+ const file = event.target.files[0];
1367
+ if (!file) return;
1368
+ const reader = new FileReader();
1369
+ reader.onload = e => {
1370
+ try {
1371
+ const doc = new DOMParser().parseFromString(e.target.result, 'text/html');
1372
+ parseImportedDocument(doc);
1373
+ showToast('Import successful!');
1374
+ } catch (error) {
1375
+ showToast('Error: Could not parse file.');
1376
+ }
1377
+ event.target.value = null;
1378
+ };
1379
+ reader.readAsText(file);
1380
+ }
1381
+ function parseImportedDocument(doc) { /* Placeholder for future import logic */ }
1382
+
1383
+ function handleGetCodeClick(e) {
1384
+ const button = e.target.closest('.get-component-code-btn');
1385
+ if (!button) return;
1386
+ const key = button.dataset.componentKey;
1387
+ const html = componentGenerators[key] ? componentGenerators[key]() : 'N/A';
1388
+ const { global, component: css } = generateComponentCSS(key);
1389
+ const js = generateComponentJavaScript(key);
1390
+ ui.codeModal.title.textContent = `${componentNames[key]} Component Code`;
1391
+ ui.codeModal.htmlCode.textContent = html;
1392
+ ui.codeModal.cssCode.textContent = (global + '\n\n' + css).trim();
1393
+ ui.codeModal.jsCode.textContent = js.trim() ? `document.addEventListener('DOMContentLoaded', () => { \n${js.trim()}\n });` : '// No JS';
1394
+ [ui.codeModal.htmlContainer, ui.codeModal.cssContainer, ui.codeModal.jsContainer].forEach(el => {
1395
+ const code = el.querySelector('code').textContent;
1396
+ el.style.display = (code.trim() === '' || code.startsWith('// No JS')) ? 'none' : 'block';
1397
+ });
1398
+ ui.codeModal.downloadBtn.onclick = () => generateComponentZip(key);
1399
+ ui.codeModal.modal.classList.remove('hidden');
1400
+ }
1401
+
1402
+ function generateComponentZip(key) {
1403
+ const zip = new JSZip();
1404
+ const { global, component: css } = generateComponentCSS(key);
1405
+ const js = generateComponentJavaScript(key);
1406
+ const htmlBody = componentGenerators[key] ? componentGenerators[key]() : '';
1407
+
1408
+ const html = `<!DOCTYPE html>
1409
+ <html lang="en"><head>
1410
+ <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
1411
+ <title>${componentNames[key]} Component</title>
1412
+ <script src="https://cdn.tailwindcss.com"><\/script>
1413
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
1414
+ <link rel="stylesheet" href="style.css">
1415
+ </head><body>
1416
+ ${htmlBody}
1417
+ ${js.trim() && !js.trim().startsWith('/*') ? '<script src="script.js"><\/script>' : ''}
1418
+ </body></html>`;
1419
+ zip.file("index.html", html);
1420
+ zip.file("style.css", (global + '\n\n' + css).trim());
1421
+ if (js.trim() && !js.trim().startsWith('/*')) {
1422
+ zip.file("script.js", `document.addEventListener('DOMContentLoaded', () => { \n${js} \n});`);
1423
+ }
1424
+ zip.generateAsync({type:"blob"}).then(content => saveAs(content, `${key}-component.zip`));
1425
+ }
1426
+
1427
+ // --- Initial Load ---
1428
+ function init() {
1429
+ const { pageTitle, infoCards, customHtml, globalSettings } = config;
1430
+
1431
+ // Init Global Settings
1432
+ ui.globalSettings.primaryColor.value = globalSettings.colors.primary;
1433
+ ui.globalSettings.secondaryColor.value = globalSettings.colors.secondary;
1434
+ ui.globalSettings.textColor.value = globalSettings.colors.text;
1435
+ ui.globalSettings.headingColor.value = globalSettings.colors.heading;
1436
+ ui.globalSettings.fontFamily.value = globalSettings.typography.fontFamily;
1437
+
1438
+ // Init Page Title
1439
+ ui.pageTitle.toggle.checked = pageTitle.enabled;
1440
+ ui.pageTitle.title.value = pageTitle.title;
1441
+ ui.pageTitle.subtitle.value = pageTitle.subtitle;
1442
+ ui.pageTitle.alignment.querySelector(`input[value="${pageTitle.alignment}"]`).checked = true;
1443
+ ui.pageTitle.titleSize.value = pageTitle.titleSize;
1444
+ ui.pageTitle.subtitleSize.value = pageTitle.subtitleSize;
1445
+
1446
+ // Init Info Cards
1447
+ ui.infoCards.toggle.checked = infoCards.enabled;
1448
+
1449
+ // Sort info cards by date in descending order
1450
+ config.infoCards.items.sort((a, b) => new Date(b.date) - new Date(a.date));
1451
+
1452
+ renderInfoCardControls();
1453
+
1454
+ // Init Custom HTML
1455
+ ui.customHtml.toggle.checked = customHtml.enabled;
1456
+ ui.customHtml.content.value = customHtml.content;
1457
+
1458
+ setupEventListeners();
1459
+ renderLayoutControls();
1460
+ renderAll();
1461
+ if(!document.querySelector('.control-nav-button.active')){
1462
+ ui.controls.nav.querySelector('.control-nav-button').click();
1463
+ }
1464
+ }
1465
+
1466
+ init();
1467
+ });
1468
+ </script>
1469
+ </body>
1470
+ </html>