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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8" />
|
| 5 |
+
<title>Mini CodePen – Live Preview</title>
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
| 7 |
+
<style>
|
| 8 |
+
* {
|
| 9 |
+
box-sizing: border-box;
|
| 10 |
+
margin: 0;
|
| 11 |
+
padding: 0;
|
| 12 |
+
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
body {
|
| 16 |
+
background: #0f172a;
|
| 17 |
+
color: #e5e7eb;
|
| 18 |
+
min-height: 100vh;
|
| 19 |
+
display: flex;
|
| 20 |
+
flex-direction: column;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
header {
|
| 24 |
+
padding: 12px 20px;
|
| 25 |
+
border-bottom: 1px solid #1f2937;
|
| 26 |
+
display: flex;
|
| 27 |
+
align-items: center;
|
| 28 |
+
justify-content: space-between;
|
| 29 |
+
gap: 12px;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
header h1 {
|
| 33 |
+
font-size: 1.1rem;
|
| 34 |
+
font-weight: 600;
|
| 35 |
+
color: #f9fafb;
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
header span {
|
| 39 |
+
font-size: 0.8rem;
|
| 40 |
+
color: #9ca3af;
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
.actions {
|
| 44 |
+
display: flex;
|
| 45 |
+
gap: 8px;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
button {
|
| 49 |
+
border: none;
|
| 50 |
+
padding: 8px 14px;
|
| 51 |
+
border-radius: 999px;
|
| 52 |
+
font-size: 0.85rem;
|
| 53 |
+
cursor: pointer;
|
| 54 |
+
background: #22c55e;
|
| 55 |
+
color: #022c22;
|
| 56 |
+
font-weight: 600;
|
| 57 |
+
transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
button:hover {
|
| 61 |
+
transform: translateY(-1px);
|
| 62 |
+
box-shadow: 0 8px 20px rgba(34, 197, 94, 0.35);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
button.secondary {
|
| 66 |
+
background: #111827;
|
| 67 |
+
color: #e5e7eb;
|
| 68 |
+
border: 1px solid #374151;
|
| 69 |
+
box-shadow: none;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
button.secondary:hover {
|
| 73 |
+
background: #020617;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
main {
|
| 77 |
+
flex: 1;
|
| 78 |
+
display: grid;
|
| 79 |
+
grid-template-columns: 1.1fr 1fr;
|
| 80 |
+
min-height: 0;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
@media (max-width: 900px) {
|
| 84 |
+
main {
|
| 85 |
+
grid-template-columns: 1fr;
|
| 86 |
+
grid-template-rows: minmax(300px, 1fr) minmax(250px, 1fr);
|
| 87 |
+
}
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.panes {
|
| 91 |
+
display: grid;
|
| 92 |
+
grid-template-rows: repeat(3, minmax(0, 1fr));
|
| 93 |
+
border-right: 1px solid #1f2937;
|
| 94 |
+
min-height: 0;
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
.editor {
|
| 98 |
+
display: flex;
|
| 99 |
+
flex-direction: column;
|
| 100 |
+
border-bottom: 1px solid #1f2937;
|
| 101 |
+
min-height: 0;
|
| 102 |
+
background: #020617;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.editor-header {
|
| 106 |
+
display: flex;
|
| 107 |
+
align-items: center;
|
| 108 |
+
justify-content: space-between;
|
| 109 |
+
padding: 6px 10px;
|
| 110 |
+
font-size: 0.75rem;
|
| 111 |
+
border-bottom: 1px solid #111827;
|
| 112 |
+
background: linear-gradient(to right, #020617, #0f172a);
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.editor-header span.label {
|
| 116 |
+
text-transform: uppercase;
|
| 117 |
+
letter-spacing: 0.08em;
|
| 118 |
+
font-weight: 600;
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
.editor-header span.badge {
|
| 122 |
+
font-size: 0.65rem;
|
| 123 |
+
padding: 2px 8px;
|
| 124 |
+
border-radius: 999px;
|
| 125 |
+
background: #111827;
|
| 126 |
+
border: 1px solid #1f2937;
|
| 127 |
+
color: #9ca3af;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
textarea {
|
| 131 |
+
flex: 1;
|
| 132 |
+
width: 100%;
|
| 133 |
+
border: none;
|
| 134 |
+
resize: none;
|
| 135 |
+
padding: 10px 12px;
|
| 136 |
+
font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
| 137 |
+
font-size: 0.8rem;
|
| 138 |
+
line-height: 1.4;
|
| 139 |
+
color: #e5e7eb;
|
| 140 |
+
background: #020617;
|
| 141 |
+
outline: none;
|
| 142 |
+
overflow: auto;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
textarea::placeholder {
|
| 146 |
+
color: #4b5563;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
.preview-pane {
|
| 150 |
+
display: flex;
|
| 151 |
+
flex-direction: column;
|
| 152 |
+
min-height: 0;
|
| 153 |
+
background: #020617;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.preview-header {
|
| 157 |
+
padding: 6px 10px;
|
| 158 |
+
font-size: 0.75rem;
|
| 159 |
+
border-bottom: 1px solid #111827;
|
| 160 |
+
display: flex;
|
| 161 |
+
align-items: center;
|
| 162 |
+
justify-content: space-between;
|
| 163 |
+
background: linear-gradient(to right, #111827, #1f2937);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.preview-header span {
|
| 167 |
+
text-transform: uppercase;
|
| 168 |
+
letter-spacing: 0.08em;
|
| 169 |
+
font-weight: 600;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
iframe {
|
| 173 |
+
flex: 1;
|
| 174 |
+
border: none;
|
| 175 |
+
background: white;
|
| 176 |
+
}
|
| 177 |
+
|
| 178 |
+
footer {
|
| 179 |
+
font-size: 0.7rem;
|
| 180 |
+
padding: 6px 12px;
|
| 181 |
+
text-align: right;
|
| 182 |
+
color: #6b7280;
|
| 183 |
+
border-top: 1px solid #111827;
|
| 184 |
+
}
|
| 185 |
+
</style>
|
| 186 |
+
</head>
|
| 187 |
+
<body>
|
| 188 |
+
<header>
|
| 189 |
+
<div>
|
| 190 |
+
<h1>Mini Code Preview</h1>
|
| 191 |
+
<span>Paste HTML, CSS, JS and click “Run” to preview</span>
|
| 192 |
+
</div>
|
| 193 |
+
<div class="actions">
|
| 194 |
+
<button id="run-btn">Run ▶</button>
|
| 195 |
+
<button id="reset-btn" class="secondary">Reset</button>
|
| 196 |
+
</div>
|
| 197 |
+
</header>
|
| 198 |
+
|
| 199 |
+
<main>
|
| 200 |
+
<!-- Left: Editors -->
|
| 201 |
+
<section class="panes">
|
| 202 |
+
<div class="editor">
|
| 203 |
+
<div class="editor-header">
|
| 204 |
+
<span class="label">HTML</span>
|
| 205 |
+
<span class="badge">Markup</span>
|
| 206 |
+
</div>
|
| 207 |
+
<textarea id="html-input" placeholder="<h1>Hello World</h1>">
|
| 208 |
+
<div class="card">
|
| 209 |
+
<h1>Hello Mini CodePen 👋</h1>
|
| 210 |
+
<p>Edit HTML, CSS, and JS, then press <strong>Run</strong>.</p>
|
| 211 |
+
<button onclick="alert('JS is working!')">Click Me</button>
|
| 212 |
+
</div>
|
| 213 |
+
</textarea>
|
| 214 |
+
</div>
|
| 215 |
+
|
| 216 |
+
<div class="editor">
|
| 217 |
+
<div class="editor-header">
|
| 218 |
+
<span class="label">CSS</span>
|
| 219 |
+
<span class="badge">Styles</span>
|
| 220 |
+
</div>
|
| 221 |
+
<textarea id="css-input" placeholder="body { font-family: sans-serif; }">
|
| 222 |
+
body {
|
| 223 |
+
display: flex;
|
| 224 |
+
align-items: center;
|
| 225 |
+
justify-content: center;
|
| 226 |
+
min-height: 100vh;
|
| 227 |
+
margin: 0;
|
| 228 |
+
background: linear-gradient(135deg, #22c55e, #0ea5e9);
|
| 229 |
+
font-family: system-ui, sans-serif;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
.card {
|
| 233 |
+
background: white;
|
| 234 |
+
padding: 24px 28px;
|
| 235 |
+
border-radius: 16px;
|
| 236 |
+
box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
|
| 237 |
+
max-width: 360px;
|
| 238 |
+
text-align: center;
|
| 239 |
+
}
|
| 240 |
+
|
| 241 |
+
.card h1 {
|
| 242 |
+
margin-bottom: 10px;
|
| 243 |
+
color: #111827;
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
.card p {
|
| 247 |
+
margin-bottom: 16px;
|
| 248 |
+
color: #4b5563;
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
.card button {
|
| 252 |
+
border: none;
|
| 253 |
+
background: #22c55e;
|
| 254 |
+
color: #022c22;
|
| 255 |
+
padding: 8px 18px;
|
| 256 |
+
border-radius: 999px;
|
| 257 |
+
font-weight: 600;
|
| 258 |
+
cursor: pointer;
|
| 259 |
+
}
|
| 260 |
+
</textarea>
|
| 261 |
+
</div>
|
| 262 |
+
|
| 263 |
+
<div class="editor">
|
| 264 |
+
<div class="editor-header">
|
| 265 |
+
<span class="label">JavaScript</span>
|
| 266 |
+
<span class="badge">Logic</span>
|
| 267 |
+
</div>
|
| 268 |
+
<textarea id="js-input" placeholder="console.log('Hello');">
|
| 269 |
+
console.log("Mini CodePen ready!");
|
| 270 |
+
|
| 271 |
+
</textarea>
|
| 272 |
+
</div>
|
| 273 |
+
</section>
|
| 274 |
+
|
| 275 |
+
<!-- Right: Preview -->
|
| 276 |
+
<section class="preview-pane">
|
| 277 |
+
<div class="preview-header">
|
| 278 |
+
<span>Preview</span>
|
| 279 |
+
<small id="status-text">Idle</small>
|
| 280 |
+
</div>
|
| 281 |
+
<iframe id="preview-frame" title="Live Preview"></iframe>
|
| 282 |
+
</section>
|
| 283 |
+
</main>
|
| 284 |
+
|
| 285 |
+
<footer>
|
| 286 |
+
Mini Code Preview • Pure HTML + CSS + JavaScript
|
| 287 |
+
</footer>
|
| 288 |
+
|
| 289 |
+
<script>
|
| 290 |
+
const htmlInput = document.getElementById("html-input");
|
| 291 |
+
const cssInput = document.getElementById("css-input");
|
| 292 |
+
const jsInput = document.getElementById("js-input");
|
| 293 |
+
const previewFrame = document.getElementById("preview-frame");
|
| 294 |
+
const runBtn = document.getElementById("run-btn");
|
| 295 |
+
const resetBtn = document.getElementById("reset-btn");
|
| 296 |
+
const statusText = document.getElementById("status-text");
|
| 297 |
+
|
| 298 |
+
function runPreview() {
|
| 299 |
+
const html = htmlInput.value || "";
|
| 300 |
+
const css = cssInput.value || "";
|
| 301 |
+
const js = jsInput.value || "";
|
| 302 |
+
|
| 303 |
+
const finalCode = `
|
| 304 |
+
<!DOCTYPE html>
|
| 305 |
+
<html lang="en">
|
| 306 |
+
<head>
|
| 307 |
+
<meta charset="UTF-8">
|
| 308 |
+
<style>
|
| 309 |
+
${css}
|
| 310 |
+
</style>
|
| 311 |
+
</head>
|
| 312 |
+
<body>
|
| 313 |
+
${html}
|
| 314 |
+
<script>
|
| 315 |
+
${js.replace(/<\/script>/gi, "<\\/script>")}
|
| 316 |
+
</script>
|
| 317 |
+
</body>
|
| 318 |
+
</html>`;
|
| 319 |
+
|
| 320 |
+
previewFrame.srcdoc = finalCode;
|
| 321 |
+
statusText.textContent = "Last run: " + new Date().toLocaleTimeString();
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
function resetEditors() {
|
| 325 |
+
htmlInput.value = "<h1>Hello World</h1>";
|
| 326 |
+
cssInput.value = "body { font-family: system-ui, sans-serif; }";
|
| 327 |
+
jsInput.value = "console.log('Reset!');";
|
| 328 |
+
runPreview();
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
runBtn.addEventListener("click", runPreview);
|
| 332 |
+
resetBtn.addEventListener("click", resetEditors);
|
| 333 |
+
|
| 334 |
+
// Optional: auto-run on Ctrl+Enter in any editor
|
| 335 |
+
[htmlInput, cssInput, jsInput].forEach((area) => {
|
| 336 |
+
area.addEventListener("keydown", (e) => {
|
| 337 |
+
if (e.ctrlKey && e.key === "Enter") {
|
| 338 |
+
e.preventDefault();
|
| 339 |
+
runPreview();
|
| 340 |
+
}
|
| 341 |
+
});
|
| 342 |
+
});
|
| 343 |
+
|
| 344 |
+
// Initial load
|
| 345 |
+
runPreview();
|
| 346 |
+
</script>
|
| 347 |
+
</body>
|
| 348 |
+
</html>
|