Wavetype commited on
Commit
17a9615
·
verified ·
1 Parent(s): 77d2e57

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +108 -45
index.html CHANGED
@@ -7,10 +7,11 @@
7
  <style>
8
  :root {
9
  --bg: #0a0a0a;
10
- --card: #1a1a1a;
11
  --accent: #7b2ff7;
12
  --text: #e0e0e0;
13
  --border: #333;
 
14
  }
15
 
16
  body {
@@ -35,39 +36,70 @@
35
  .module-box {
36
  background: var(--card);
37
  border: 2px solid var(--accent);
38
- border-radius: 8px;
39
- padding: 15px;
40
  position: relative;
41
- box-shadow: 0 4px 15px rgba(0,0,0,0.5);
42
  }
43
 
44
  .module-header {
45
  display: flex;
46
  justify-content: space-between;
47
- margin-bottom: 10px;
48
  font-size: 0.8rem;
49
- text-transform: uppercase;
50
- letter-spacing: 1px;
51
  color: var(--accent);
52
  }
53
 
 
 
 
 
 
 
54
  textarea {
55
  width: 100%;
56
- height: 100px;
57
  background: #000;
58
  color: #00ff41;
59
  border: 1px solid var(--border);
60
- border-radius: 4px;
61
- font-family: monospace;
62
- padding: 10px;
63
  box-sizing: border-box;
64
  resize: vertical;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
 
67
  .controls {
68
- margin-top: 10px;
69
  display: flex;
70
- gap: 10px;
71
  flex-wrap: wrap;
72
  }
73
 
@@ -75,40 +107,45 @@
75
  background: transparent;
76
  color: white;
77
  border: 1px solid var(--accent);
78
- padding: 8px 15px;
79
- border-radius: 4px;
80
  cursor: pointer;
81
- transition: 0.2s;
82
- font-size: 0.8rem;
 
 
83
  }
84
 
85
  button:hover {
86
  background: var(--accent);
 
87
  }
88
 
89
  .save-btn {
90
- border-color: #00ff41;
91
- color: #00ff41;
92
  }
93
 
94
  .save-btn:hover {
95
- background: #00ff41;
96
- color: black;
97
  }
98
 
99
  #library {
100
  width: 100%;
101
  max-width: 800px;
102
- margin-top: 30px;
103
- padding: 15px;
104
  background: #111;
105
- border-top: 1px solid var(--border);
 
106
  }
107
 
108
  .library-title {
109
  font-size: 0.9rem;
110
- margin-bottom: 10px;
111
  color: #888;
 
112
  }
113
 
114
  .library-grid {
@@ -118,22 +155,25 @@
118
  }
119
 
120
  .lib-item {
121
- background: #222;
122
- border: 1px solid #444;
123
- padding: 5px 10px;
124
- font-size: 0.75rem;
125
  cursor: pointer;
 
126
  }
127
 
128
  .lib-item:hover {
129
  border-color: var(--accent);
 
130
  }
131
 
132
  .add-module-trigger {
133
- margin: 20px;
134
- padding: 15px 40px;
135
- font-weight: bold;
136
  border-width: 2px;
 
137
  }
138
  </style>
139
  </head>
@@ -154,12 +194,13 @@
154
 
155
  function init() {
156
  renderLibrary();
157
- createModule(); // Start with one module
 
158
  }
159
 
160
  function createModule(initialContent = '') {
161
  const canvas = document.getElementById('canvas');
162
- const moduleId = 'mod_' + Date.now();
163
 
164
  const box = document.createElement('div');
165
  box.className = 'module-box';
@@ -168,17 +209,45 @@
168
  box.innerHTML = `
169
  <div class="module-header">
170
  <span>HTML NODE</span>
171
- <span style="cursor:pointer" onclick="document.getElementById('${moduleId}').remove()">[EXIT]</span>
172
  </div>
173
- <textarea placeholder="Paste or type HTML here..." id="text_${moduleId}">${initialContent}</textarea>
 
 
 
 
 
174
  <div class="controls">
175
- <button onclick="previewModule('${moduleId}')">RENDER PREVIEW</button>
176
  <button class="save-btn" onclick="saveToLibrary('${moduleId}')">SAVE TO LIBRARY</button>
177
  </div>
178
- <div id="preview_${moduleId}" style="margin-top:15px; display:none; padding:10px; border:1px dashed #444;"></div>
 
 
 
 
179
  `;
180
 
181
  canvas.appendChild(box);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  }
183
 
184
  function saveToLibrary(moduleId) {
@@ -200,18 +269,12 @@
200
  const btn = document.createElement('button');
201
  btn.className = 'lib-item';
202
  btn.innerText = item.name;
 
203
  btn.onclick = () => createModule(item.content);
204
  grid.appendChild(btn);
205
  });
206
  }
207
 
208
- function previewModule(moduleId) {
209
- const content = document.getElementById(`text_${moduleId}`).value;
210
- const prevDiv = document.getElementById(`preview_${moduleId}`);
211
- prevDiv.style.display = 'block';
212
- prevDiv.innerHTML = content;
213
- }
214
-
215
  init();
216
  </script>
217
  </body>
 
7
  <style>
8
  :root {
9
  --bg: #0a0a0a;
10
+ --card: #121212;
11
  --accent: #7b2ff7;
12
  --text: #e0e0e0;
13
  --border: #333;
14
+ --success: #4caf50;
15
  }
16
 
17
  body {
 
36
  .module-box {
37
  background: var(--card);
38
  border: 2px solid var(--accent);
39
+ border-radius: 12px;
40
+ padding: 20px;
41
  position: relative;
42
+ box-shadow: 0 8px 32px rgba(0,0,0,0.8);
43
  }
44
 
45
  .module-header {
46
  display: flex;
47
  justify-content: space-between;
48
+ margin-bottom: 15px;
49
  font-size: 0.8rem;
50
+ font-weight: bold;
 
51
  color: var(--accent);
52
  }
53
 
54
+ .exit-btn {
55
+ color: #ff4444;
56
+ cursor: pointer;
57
+ text-decoration: none;
58
+ }
59
+
60
  textarea {
61
  width: 100%;
62
+ height: 150px;
63
  background: #000;
64
  color: #00ff41;
65
  border: 1px solid var(--border);
66
+ border-radius: 6px;
67
+ font-family: 'Courier New', monospace;
68
+ padding: 12px;
69
  box-sizing: border-box;
70
  resize: vertical;
71
+ font-size: 0.9rem;
72
+ }
73
+
74
+ /* LIVE RENDER AREA */
75
+ .preview-container {
76
+ margin-top: 15px;
77
+ background: white; /* Default white background for rendered content */
78
+ color: black;
79
+ border-radius: 6px;
80
+ min-height: 50px;
81
+ overflow: hidden;
82
+ display: none; /* Shown only when rendered */
83
+ }
84
+
85
+ .preview-label {
86
+ background: #222;
87
+ color: #aaa;
88
+ font-size: 0.7rem;
89
+ padding: 4px 10px;
90
+ display: block;
91
+ }
92
+
93
+ iframe {
94
+ width: 100%;
95
+ border: none;
96
+ background: white;
97
  }
98
 
99
  .controls {
100
+ margin-top: 15px;
101
  display: flex;
102
+ gap: 12px;
103
  flex-wrap: wrap;
104
  }
105
 
 
107
  background: transparent;
108
  color: white;
109
  border: 1px solid var(--accent);
110
+ padding: 10px 20px;
111
+ border-radius: 6px;
112
  cursor: pointer;
113
+ transition: all 0.2s ease;
114
+ font-size: 0.85rem;
115
+ font-weight: 600;
116
+ text-transform: uppercase;
117
  }
118
 
119
  button:hover {
120
  background: var(--accent);
121
+ transform: translateY(-1px);
122
  }
123
 
124
  .save-btn {
125
+ border-color: var(--success);
126
+ color: var(--success);
127
  }
128
 
129
  .save-btn:hover {
130
+ background: var(--success);
131
+ color: white;
132
  }
133
 
134
  #library {
135
  width: 100%;
136
  max-width: 800px;
137
+ margin: 40px 0;
138
+ padding: 20px;
139
  background: #111;
140
+ border: 1px dashed #444;
141
+ border-radius: 12px;
142
  }
143
 
144
  .library-title {
145
  font-size: 0.9rem;
146
+ margin-bottom: 15px;
147
  color: #888;
148
+ letter-spacing: 1px;
149
  }
150
 
151
  .library-grid {
 
155
  }
156
 
157
  .lib-item {
158
+ background: #1a1a1a;
159
+ border: 1px solid #333;
160
+ padding: 8px 16px;
161
+ font-size: 0.8rem;
162
  cursor: pointer;
163
+ border-radius: 4px;
164
  }
165
 
166
  .lib-item:hover {
167
  border-color: var(--accent);
168
+ background: #222;
169
  }
170
 
171
  .add-module-trigger {
172
+ margin-top: 30px;
173
+ padding: 18px 50px;
174
+ font-size: 1rem;
175
  border-width: 2px;
176
+ background: rgba(123, 47, 247, 0.1);
177
  }
178
  </style>
179
  </head>
 
194
 
195
  function init() {
196
  renderLibrary();
197
+ // Start with one module automatically
198
+ createModule();
199
  }
200
 
201
  function createModule(initialContent = '') {
202
  const canvas = document.getElementById('canvas');
203
+ const moduleId = 'mod_' + Math.random().toString(36).substr(2, 9);
204
 
205
  const box = document.createElement('div');
206
  box.className = 'module-box';
 
209
  box.innerHTML = `
210
  <div class="module-header">
211
  <span>HTML NODE</span>
212
+ <span class="exit-btn" onclick="document.getElementById('${moduleId}').remove()">[EXIT]</span>
213
  </div>
214
+ <textarea
215
+ placeholder="Paste or type HTML/JS/CSS code here..."
216
+ id="text_${moduleId}"
217
+ spellcheck="false"
218
+ >${initialContent}</textarea>
219
+
220
  <div class="controls">
221
+ <button onclick="renderPreview('${moduleId}')">RENDER PREVIEW</button>
222
  <button class="save-btn" onclick="saveToLibrary('${moduleId}')">SAVE TO LIBRARY</button>
223
  </div>
224
+
225
+ <div class="preview-container" id="cont_${moduleId}">
226
+ <span class="preview-label">LIVE OUTPUT</span>
227
+ <iframe id="iframe_${moduleId}" sandbox="allow-scripts"></iframe>
228
+ </div>
229
  `;
230
 
231
  canvas.appendChild(box);
232
+ if(initialContent) renderPreview(moduleId);
233
+ }
234
+
235
+ function renderPreview(moduleId) {
236
+ const code = document.getElementById(`text_${moduleId}`).value;
237
+ const container = document.getElementById(`cont_${moduleId}`);
238
+ const iframe = document.getElementById(`iframe_${moduleId}`);
239
+
240
+ container.style.display = 'block';
241
+
242
+ const blob = new Blob([code], { type: 'text/html' });
243
+ iframe.src = URL.createObjectURL(blob);
244
+
245
+ // Auto-resize iframe height
246
+ iframe.onload = function() {
247
+ setTimeout(() => {
248
+ iframe.style.height = (iframe.contentWindow.document.body.scrollHeight + 20) + 'px';
249
+ }, 100);
250
+ };
251
  }
252
 
253
  function saveToLibrary(moduleId) {
 
269
  const btn = document.createElement('button');
270
  btn.className = 'lib-item';
271
  btn.innerText = item.name;
272
+ btn.title = "Click to open in new module";
273
  btn.onclick = () => createModule(item.content);
274
  grid.appendChild(btn);
275
  });
276
  }
277
 
 
 
 
 
 
 
 
278
  init();
279
  </script>
280
  </body>