Spaces:
Running
Running
| class CodePreview extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| :host { | |
| display: block; | |
| height: 100%; | |
| background: #1e1e2e; | |
| border-radius: 8px; | |
| overflow: hidden; | |
| box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); | |
| } | |
| .preview-container { | |
| height: 100%; | |
| display: flex; | |
| flex-direction: column; | |
| } | |
| .preview-toolbar { | |
| display: flex; | |
| gap: 0.5rem; | |
| padding: 1rem; | |
| background: #2a2a3a; | |
| border-bottom: 1px solid #44475a; | |
| } | |
| button { | |
| background: #6272a4; | |
| color: #f8f8f2; | |
| border: none; | |
| border-radius: 4px; | |
| padding: 0.5rem 1rem; | |
| cursor: pointer; | |
| transition: background 0.2s; | |
| } | |
| button:hover { | |
| background: #7f8fb1; | |
| } | |
| .preview-content { | |
| flex: 1; | |
| display: flex; | |
| } | |
| iframe { | |
| flex: 1; | |
| border: none; | |
| background: white; | |
| } | |
| </style> | |
| <div class="preview-container"> | |
| <div class="preview-toolbar"> | |
| <button id="deploy-btn">Deploy</button> | |
| <button id="export-github">Export to GitHub</button> | |
| <button id="download-zip">Download ZIP</button> | |
| <button id="file-explorer">File Explorer</button> | |
| </div> | |
| <div class="preview-content"> | |
| <iframe id="preview-frame" sandbox="allow-scripts allow-same-origin"></iframe> | |
| </div> | |
| </div> | |
| `; | |
| } | |
| } | |
| customElements.define('code-preview', CodePreview); |