Spaces:
Running
Running
File size: 1,713 Bytes
a4658bb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
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); |