Files
lit-examples/lit-showcase/index.html
rodydavis b6d4d53b50
Build and Deploy / build-and-deploy (push) Successful in 1m51s
update title
2026-05-17 00:59:58 -07:00

1022 lines
34 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lit Web Components Showcase</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Plus+Jakarta+Sans:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<style>
:root {
--bg-gradient: linear-gradient(135deg, #090d16 0%, #111827 100%);
--glass-bg: rgba(17, 24, 39, 0.7);
--glass-border: rgba(255, 255, 255, 0.08);
--text-primary: #f3f4f6;
--text-secondary: #9ca3af;
--accent: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
--accent-hover: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
--shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
--font-main: 'Plus Jakarta Sans', 'Outfit', sans-serif;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: var(--font-main);
background: var(--bg-gradient);
color: var(--text-primary);
min-height: 100vh;
display: flex;
overflow: hidden;
}
/* Sidebar Styles */
.sidebar {
width: 320px;
flex-shrink: 0;
background: var(--glass-bg);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border-right: 1px solid var(--glass-border);
display: flex;
flex-direction: column;
height: 100vh;
z-index: 10;
}
.sidebar-header {
padding: 24px;
border-bottom: 1px solid var(--glass-border);
}
.sidebar-header h1 {
font-size: 20px;
font-weight: 700;
background: var(--accent);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin-bottom: 8px;
}
.sidebar-header p {
font-size: 12px;
color: var(--text-secondary);
font-weight: 500;
text-transform: uppercase;
letter-spacing: 1px;
}
.search-box {
padding: 16px 24px;
border-bottom: 1px solid var(--glass-border);
}
.search-input {
width: 100%;
padding: 12px 16px;
border-radius: 12px;
border: 1px solid var(--glass-border);
background: rgba(0, 0, 0, 0.2);
color: var(--text-primary);
font-family: var(--font-main);
font-size: 14px;
outline: none;
transition: all 0.3s ease;
}
.search-input:focus {
border-color: #6366f1;
box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}
.project-list {
flex: 1;
overflow-y: auto;
padding: 16px;
}
/* Custom Scrollbar */
.project-list::-webkit-scrollbar {
width: 6px;
}
.project-list::-webkit-scrollbar-track {
background: transparent;
}
.project-list::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.1);
border-radius: 3px;
}
.project-item {
display: flex;
align-items: center;
padding: 12px 16px;
border-radius: 12px;
margin-bottom: 8px;
cursor: pointer;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
border: 1px solid transparent;
text-decoration: none;
}
.project-item:hover {
background: rgba(255, 255, 255, 0.03);
border-color: rgba(255, 255, 255, 0.05);
transform: translateX(4px);
}
.project-item.active {
background: var(--accent);
box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
transform: translateX(6px);
}
.project-emoji {
font-size: 22px;
margin-right: 16px;
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
background: rgba(255, 255, 255, 0.05);
border-radius: 10px;
transition: all 0.3s ease;
}
.project-item.active .project-emoji {
background: rgba(255, 255, 255, 0.2);
}
.project-info {
flex: 1;
}
.project-title {
font-size: 14px;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 2px;
}
.project-meta {
font-size: 11px;
color: var(--text-secondary);
}
.project-item.active .project-title {
color: #ffffff;
}
.project-item.active .project-meta {
color: rgba(255, 255, 255, 0.8);
}
/* Main Area Styles */
.main-content {
flex: 1;
height: 100vh;
display: flex;
flex-direction: column;
position: relative;
min-width: 0;
}
/* Empty/Hero State */
.hero-state {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 40px;
text-align: center;
animation: fadeIn 0.6s ease;
}
.hero-card {
background: var(--glass-bg);
backdrop-filter: blur(24px);
border: 1px solid var(--glass-border);
border-radius: 24px;
padding: 48px;
max-width: 600px;
box-shadow: var(--shadow);
position: relative;
overflow: hidden;
}
.hero-card::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(99,102,241,0.15) 0%, transparent 60%);
pointer-events: none;
}
.hero-icon {
font-size: 64px;
margin-bottom: 24px;
display: inline-block;
animation: float 4s ease-in-out infinite;
}
.hero-title {
font-size: 32px;
font-weight: 800;
margin-bottom: 16px;
background: var(--accent);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.hero-desc {
font-size: 16px;
color: var(--text-secondary);
line-height: 1.6;
margin-bottom: 32px;
}
.hero-stats {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 16px;
}
.stat-item {
background: rgba(255, 255, 255, 0.02);
border: 1px solid var(--glass-border);
border-radius: 16px;
padding: 16px;
}
.stat-val {
font-size: 24px;
font-weight: 700;
color: #6366f1;
margin-bottom: 4px;
}
.stat-lbl {
font-size: 11px;
color: var(--text-secondary);
text-transform: uppercase;
letter-spacing: 0.5px;
}
/* Viewport Styles */
.viewport {
display: none;
flex-direction: column;
flex: 1;
height: 100vh;
animation: fadeIn 0.4s ease;
min-width: 0;
overflow: hidden;
}
.viewport-header {
background: rgba(17, 24, 39, 0.9);
backdrop-filter: blur(8px);
border-bottom: 1px solid var(--glass-border);
padding: 16px 24px;
display: flex;
align-items: center;
justify-content: space-between;
}
.viewport-title-area {
display: flex;
align-items: center;
}
.back-btn {
background: rgba(255, 255, 255, 0.05);
border: 1px solid var(--glass-border);
color: var(--text-primary);
width: 36px;
height: 36px;
border-radius: 10px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
margin-right: 16px;
transition: all 0.2s ease;
}
.back-btn:hover {
background: rgba(255, 255, 255, 0.1);
transform: scale(1.05);
}
.viewport-title {
font-size: 18px;
font-weight: 700;
}
.viewport-controls {
display: flex;
align-items: center;
gap: 12px;
}
.size-btn {
background: rgba(255, 255, 255, 0.05);
border: 1px solid var(--glass-border);
color: var(--text-secondary);
padding: 8px 12px;
border-radius: 8px;
cursor: pointer;
font-size: 12px;
font-weight: 600;
transition: all 0.2s ease;
display: flex;
align-items: center;
gap: 6px;
}
.size-btn:hover, .size-btn.active {
background: rgba(255, 255, 255, 0.12);
color: var(--text-primary);
border-color: rgba(255, 255, 255, 0.2);
}
.external-link-btn {
background: var(--accent);
border: none;
color: #ffffff;
padding: 8px 16px;
border-radius: 8px;
cursor: pointer;
font-size: 12px;
font-weight: 600;
text-decoration: none;
display: flex;
align-items: center;
gap: 6px;
transition: all 0.2s ease;
}
.external-link-btn:hover {
background: var(--accent-hover);
box-shadow: 0 4px 12px rgba(168, 85, 247, 0.25);
}
/* Preview Content Container */
.viewport-content {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
background: #05070c;
overflow: auto;
padding: 24px;
position: relative;
}
/* Container for direct Lit component rendering */
.render-container {
background: #0d1117;
display: flex;
flex-direction: column;
padding: 24px;
overflow: auto;
position: relative;
min-width: 0;
min-height: 0;
box-sizing: border-box;
}
/* Fallback Iframe container for Standalone previews */
.iframe-wrapper {
display: none;
justify-content: center;
align-items: center;
overflow: hidden;
}
.iframe-wrapper.show {
display: flex;
}
iframe {
width: 100%;
height: 100%;
border: none;
background: #ffffff;
}
/* Sizing transitions */
.render-container, .iframe-wrapper {
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
width: 100%;
height: 100%;
max-width: 100%;
max-height: 100%;
}
/* Desktop Viewport */
.render-container.desktop, .iframe-wrapper.desktop {
width: 100%;
height: 100%;
border: none;
border-radius: 0;
box-shadow: none;
}
/* Tablet Viewport (768px wide, 1024px high) */
.render-container.tablet, .iframe-wrapper.tablet {
width: 768px;
height: 1024px;
border-radius: 20px;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
border: 8px solid #1e293b;
}
/* Mobile Viewport (375px wide, 667px high) */
.render-container.mobile, .iframe-wrapper.mobile {
width: 375px;
height: 667px;
border-radius: 30px;
box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
border: 12px solid #1e293b;
}
/* Keyframes */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes float {
0%, 100% { transform: translateY(0px); }
50% { transform: translateY(-10px); }
}
</style>
</head>
<body>
<!-- Sidebar -->
<div class="sidebar">
<div class="sidebar-header">
<h1>Lit Showcase</h1>
</div>
<div class="search-box">
<input type="text" class="search-input" placeholder="Search components..." id="search">
</div>
<div class="project-list" id="projectList">
<!-- Modular Lit Components (Rendered natively on page) -->
<a class="project-item" href="#lit-3d-piano" data-name="Lit 3D Piano" data-slug="lit-3d-piano" data-type="native">
<span class="project-emoji">🎹</span>
<div class="project-info">
<div class="project-title">Lit 3D Piano</div>
<div class="project-meta">Modular Instrument</div>
</div>
</a>
<a class="project-item" href="#lit-calculator" data-name="Lit Calculator" data-slug="lit-calculator" data-type="native">
<span class="project-emoji">🧮</span>
<div class="project-info">
<div class="project-title">Lit Calculator</div>
<div class="project-meta">Mathematical Engine</div>
</div>
</a>
<a class="project-item" href="#lit-code-editor" data-name="Lit Code Editor" data-slug="lit-code-editor" data-type="native">
<span class="project-emoji">💻</span>
<div class="project-info">
<div class="project-title">Lit Code Editor</div>
<div class="project-meta">Monaco Editor Integrator</div>
</div>
</a>
<a class="project-item" href="#lit-draggable-dom" data-name="Lit Draggable Dom" data-slug="lit-draggable-dom" data-type="native">
<span class="project-emoji">🖐️</span>
<div class="project-info">
<div class="project-title">Lit Draggable Dom</div>
<div class="project-meta">Layout Manager</div>
</div>
</a>
<a class="project-item" href="#lit-file-based-routing" data-name="Lit File Based Routing" data-slug="lit-file-based-routing" data-type="native">
<span class="project-emoji">🚦</span>
<div class="project-info">
<div class="project-title">Lit File Based Routing</div>
<div class="project-meta">Application Router</div>
</div>
</a>
<a class="project-item" href="#lit-force-graph" data-name="Lit Force Graph" data-slug="lit-force-graph" data-type="native">
<span class="project-emoji">🕸️</span>
<div class="project-info">
<div class="project-title">Lit Force Graph</div>
<div class="project-meta">3D Networking Engine</div>
</div>
</a>
<a class="project-item" href="#lit-html-editor" data-name="Lit HTML Editor" data-slug="lit-html-editor" data-type="native">
<span class="project-emoji">✍️</span>
<div class="project-info">
<div class="project-title">Lit HTML Editor</div>
<div class="project-meta">Real-time Markdown & code</div>
</div>
</a>
<a class="project-item" href="#lit-html-table" data-name="Lit HTML Table" data-slug="lit-html-table" data-type="native">
<span class="project-emoji">📊</span>
<div class="project-info">
<div class="project-title">Lit HTML Table</div>
<div class="project-meta">Spreadsheet Grid View</div>
</div>
</a>
<a class="project-item" href="#lit-modules" data-name="Lit Modules" data-slug="lit-modules" data-type="native">
<span class="project-emoji">📦</span>
<div class="project-info">
<div class="project-title">Lit Modules</div>
<div class="project-meta">NPM Packaging Harness</div>
</div>
</a>
<a class="project-item" href="#lit-node-editor" data-name="Lit Node Editor" data-slug="lit-node-editor" data-type="native">
<span class="project-emoji">🪢</span>
<div class="project-info">
<div class="project-title">Lit Node Editor</div>
<div class="project-meta">Visual Shader graph</div>
</div>
</a>
<a class="project-item" href="#lit-sheet-music" data-name="Lit Sheet Music" data-slug="lit-sheet-music" data-type="native">
<span class="project-emoji">🎼</span>
<div class="project-info">
<div class="project-title">Lit Sheet Music</div>
<div class="project-meta">OSMD Renderer</div>
</div>
</a>
<a class="project-item" href="#lit-wmr" data-name="Lit WMR" data-slug="lit-wmr" data-type="native">
<span class="project-emoji"></span>
<div class="project-info">
<div class="project-title">Lit WMR</div>
<div class="project-meta">WMR Bundled Prototype</div>
</div>
</a>
</div>
</div>
<!-- Main Showcase Content -->
<div class="main-content">
<!-- Hero State -->
<div class="hero-state" id="heroState">
<div class="hero-card">
<span class="hero-icon"></span>
<h2 class="hero-title">Lit Showcase Hub</h2>
<p class="hero-desc">Explore a rich collection of modular Lit Web Components, prototypes, interactive instruments, databases, and custom UI modules. Select any example from the sidebar to preview natively or in a sandbox.</p>
<div class="hero-stats">
<div class="stat-item">
<div class="stat-val">20</div>
<div class="stat-lbl">Projects</div>
</div>
<div class="stat-item">
<div class="stat-val">Natively</div>
<div class="stat-lbl">Rendered</div>
</div>
<div class="stat-item">
<div class="stat-val">Vitest</div>
<div class="stat-lbl">Colocated</div>
</div>
</div>
</div>
</div>
<!-- Viewport -->
<div class="viewport" id="viewport">
<div class="viewport-header">
<div class="viewport-title-area">
<button class="back-btn" id="backBtn"></button>
<span class="viewport-title" id="viewportTitle">Project Name</span>
</div>
<div class="viewport-controls">
<button class="size-btn active" data-size="desktop">💻 Desktop</button>
<button class="size-btn" data-size="tablet">📟 Tablet</button>
<button class="size-btn" data-size="mobile">📱 Mobile</button>
<a href="#" target="_blank" class="external-link-btn" id="extLink">🌐 Open Direct</a>
</div>
</div>
<!-- Preview Wrapper that centers Tablet/Mobile mockups -->
<div class="viewport-content" id="viewportContent">
<!-- Native rendering viewport -->
<div class="render-container desktop" id="renderContainer"></div>
<!-- Iframe fallback viewport -->
<div class="iframe-wrapper desktop" id="iframeWrapper">
<iframe id="previewIframe" src="about:blank"></iframe>
</div>
</div>
</div>
</div>
<script type="module">
const exampleImports = {
'lit-3d-piano': () => import('../lit-components/lit-3d-piano/piano-component'),
'lit-calculator': () => import('../lit-components/lit-calculator/calculator'),
'lit-code-editor': () => import('../lit-components/lit-code-editor/code-editor'),
'lit-draggable-dom': () => import('../lit-components/lit-draggable-dom/draggable-dom'),
'lit-file-based-routing': () => import('../lit-components/lit-file-based-routing/generated-app'),
'lit-force-graph': () => import('../lit-components/lit-force-graph/lit-force-graph'),
'lit-html-editor': () => import('../lit-components/lit-html-editor/components/rich-text'),
'lit-html-table': () => import('../lit-components/lit-html-table/lit-html-table'),
'lit-modules': () => import('../lit-components/lit-modules/modules/app'),
'lit-node-editor': () => import('../lit-components/lit-node-editor/node-editor'),
'lit-sheet-music': () => import('../lit-components/lit-sheet-music/sheet-music'),
'lit-wmr': () => import('../lit-components/lit-wmr/simple-greeting'),
};
// Custom element Tag Names mapping
const tagNameMap = {
'lit-3d-piano': 'piano-component',
'lit-calculator': 'app-calculator',
'lit-code-editor': 'code-editor',
'lit-draggable-dom': 'draggable-dom',
'lit-file-based-routing': 'generated-app',
'lit-force-graph': 'lit-force-graph',
'lit-html-editor': 'rich-text',
'lit-html-table': 'lit-html-table',
'lit-modules': 'app-module',
'lit-node-editor': 'node-editor',
'lit-sheet-music': 'sheet-music',
'lit-wmr': 'simple-greeting',
};
const items = document.querySelectorAll('.project-item');
const heroState = document.getElementById('heroState');
const viewport = document.getElementById('viewport');
const renderContainer = document.getElementById('renderContainer');
const iframeWrapper = document.getElementById('iframeWrapper');
const iframe = document.getElementById('previewIframe');
const viewportTitle = document.getElementById('viewportTitle');
const extLink = document.getElementById('extLink');
const backBtn = document.getElementById('backBtn');
// Central selection and rendering engine
async function activateDemo(slug, updateHistory = true) {
const item = document.querySelector(`.project-item[data-slug="${slug}"]`);
if (!item) return;
items.forEach(i => i.classList.remove('active'));
item.classList.add('active');
const name = item.getAttribute('data-name');
const type = item.getAttribute('data-type');
const path = item.getAttribute('href');
heroState.style.display = 'none';
viewport.style.display = 'flex';
viewportTitle.textContent = name;
// Reset sizing buttons back to desktop view on loading a new demo
sizeBtns.forEach(b => b.classList.remove('active'));
const defaultDesktopBtn = document.querySelector('.size-btn[data-size="desktop"]');
if (defaultDesktopBtn) defaultDesktopBtn.classList.add('active');
renderContainer.className = 'render-container desktop';
iframeWrapper.className = 'iframe-wrapper desktop';
if (type === 'native') {
// Render custom element directly on page natively
renderContainer.style.display = 'flex';
iframeWrapper.className = 'iframe-wrapper';
iframe.src = 'about:blank';
extLink.style.display = 'none';
// Clear previous components safely
renderContainer.innerHTML = `<div style="color: var(--text-secondary); font-size: 14px;">Loading component...</div>`;
try {
// Dynamic ESM import
await exampleImports[slug]();
// Instantiate and mount custom element
const tagName = tagNameMap[slug];
const element = document.createElement(tagName);
// Add default config styles to custom element container
element.style.width = '100%';
element.style.height = '100%';
element.style.minHeight = '500px';
// Supply premium default mock data and config properties if needed
if (slug === 'lit-html-table') {
element.values = [
{ id: 1, name: "Minimoog Model D", type: "Analog Synthesizer", year: 1970, price: "$3,499", status: "In Stock" },
{ id: 2, name: "Roland Juno-106", type: "Polysynth", year: 1984, price: "$1,899", status: "Rare" },
{ id: 3, name: "Korg MS-20", type: "Monophonic Semi-Modular", year: 1978, price: "$899", status: "In Stock" },
{ id: 4, name: "Sequential Circuits Prophet-5", type: "Polysynth", year: 1978, price: "$3,299", status: "Limited" },
{ id: 5, name: "Yamaha DX7", type: "FM Synthesizer", year: 1983, price: "$950", status: "Restocking" }
];
element.editable = true;
} else if (slug === 'lit-code-editor') {
element.language = 'javascript';
element.code = `import { LitElement, html, css } from 'lit';
import { customElement, property } from 'lit/decorators.js';
@customElement('glowing-button')
export class GlowingButton extends LitElement {
static styles = css\`
button {
background: linear-gradient(135deg, #ff007f, #7f00ff);
color: white;
border: none;
padding: 14px 28px;
font-size: 16px;
font-weight: bold;
border-radius: 30px;
cursor: pointer;
box-shadow: 0 0 20px rgba(255, 0, 127, 0.4);
transition: all 0.3s ease;
}
button:hover {
transform: scale(1.05);
box-shadow: 0 0 30px rgba(127, 0, 255, 0.8);
}
\`;
@property() label = 'Interact With Me';
render() {
return html\`<button>\${this.label}</button>\`;
}
}`;
} else if (slug === 'lit-draggable-dom') {
element.innerHTML = `
<div style="background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%); color: white; padding: 25px; border-radius: 16px; box-shadow: 0 10px 30px rgba(255, 8, 68, 0.3); cursor: grab; width: 220px; font-family: 'Outfit', sans-serif; position: absolute; left: 80px; top: 120px; user-select: none;">
<h3 style="margin: 0 0 8px 0; font-size: 18px;">Design Token</h3>
<p style="margin: 0; font-size: 13px; opacity: 0.9;">Drag me around the canvas. I'll maintain my position smoothly!</p>
</div>
<div style="background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); color: white; padding: 25px; border-radius: 16px; box-shadow: 0 10px 30px rgba(56, 239, 125, 0.3); cursor: grab; width: 200px; font-family: 'Outfit', sans-serif; position: absolute; left: 360px; top: 200px; user-select: none;">
<h3 style="margin: 0 0 8px 0; font-size: 18px;">Reactive State</h3>
<p style="margin: 0; font-size: 13px; opacity: 0.9;">Multitouch support is active. Zoom or pan to navigate.</p>
</div>
<div style="background: linear-gradient(135deg, #f12711 0%, #f5af19 100%); color: white; padding: 25px; border-radius: 16px; box-shadow: 0 10px 30px rgba(245, 175, 25, 0.3); cursor: grab; width: 180px; font-family: 'Outfit', sans-serif; position: absolute; left: 220px; top: 380px; user-select: none;">
<h3 style="margin: 0 0 8px 0; font-size: 18px;">Physics Grid</h3>
<p style="margin: 0; font-size: 13px; opacity: 0.9;">Snaps and transforms align to the background mesh.</p>
</div>
`;
} else if (slug === 'lit-force-graph') {
const script = document.createElement('script');
script.type = 'application/json';
const data = {
name: "DeepMind AI Ecosystem",
description: "A force-directed graph illustrating Google DeepMind's prominent model architectures and system relationships.",
nodes: [
{ id: "gemini", name: "Gemini 1.5 Pro", group: "Models" },
{ id: "gemma", name: "Gemma 2", group: "Models" },
{ id: "alphafold", name: "AlphaFold 3", group: "Scientific" },
{ id: "imagen", name: "Imagen 3", group: "Creative" },
{ id: "veo", name: "Veo", group: "Creative" },
{ id: "agent", name: "Antigravity Agent", group: "Agents" },
{ id: "workspace", name: "Federated Workspace", group: "Infrastructure" },
{ id: "lit", name: "Lit Component Library", group: "Infrastructure" }
],
links: [
{ source: "gemini", target: "agent" },
{ source: "agent", target: "workspace" },
{ source: "workspace", target: "lit" },
{ source: "gemini", target: "gemma" },
{ source: "gemini", target: "imagen" },
{ source: "gemini", target: "veo" },
{ source: "gemini", target: "alphafold" }
]
};
script.textContent = JSON.stringify(data);
element.appendChild(script);
} else if (slug === 'lit-html-editor') {
element.node.innerHTML = `
<h1 style="color: #6366f1; font-family: 'Outfit', sans-serif; margin-top: 0;">Welcome to the Lit Rich Text Editor!</h1>
<p>This is a <strong>fully custom, native</strong> HTML editor built using Lit.</p>
<p>You can use the toolbar above to:</p>
<ul style="padding-left: 20px;">
<li>Apply bold, italic, or underline text formatting</li>
<li>Create customized lists</li>
<li>Insert links or blockquotes</li>
</ul>
<blockquote style="border-left: 4px solid #6366f1; padding-left: 12px; margin-left: 0; color: #666; font-style: italic; margin-top: 20px;">
"Simple, clean, and blazingly fast." - Modern Web Developer
</blockquote>
`;
} else if (slug === 'lit-sheet-music') {
const sampleXml = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE score-partwise PUBLIC
"-//Recordare//DTD MusicXML 3.1 Partwise//EN"
"http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.1">
<work>
<work-title>Ode to Joy (Theme)</work-title>
</work>
<part-list>
<score-part id="P1">
<part-name>Piano</part-name>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>1</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>G</sign>
<line>2</line>
</clef>
</attributes>
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
<note>
<pitch>
<step>E</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
<note>
<pitch>
<step>F</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
</note>
</measure>
</part>
</score-partwise>`;
element.updateComplete.then(() => {
element.renderMusic(sampleXml);
});
}
// Dynamically set background color for readability on light components
if (slug === 'lit-sheet-music' || slug === 'lit-wmr' || slug === 'lit-html-table') {
renderContainer.style.background = '#ffffff';
} else {
renderContainer.style.background = '#0d1117';
}
renderContainer.innerHTML = '';
// Inject script tag into parent container for lit-html-table
if (slug === 'lit-html-table') {
const script = document.createElement('script');
script.type = 'application/json';
const data = [
{ id: 1, name: "Minimoog Model D", type: "Analog Synthesizer", year: 1970, price: "$3,499", status: "In Stock" },
{ id: 2, name: "Roland Juno-106", type: "Polysynth", year: 1984, price: "$1,899", status: "Rare" },
{ id: 3, name: "Korg MS-20", type: "Monophonic Semi-Modular", year: 1978, price: "$899", status: "In Stock" },
{ id: 4, name: "Sequential Circuits Prophet-5", type: "Polysynth", year: 1978, price: "$3,299", status: "Limited" },
{ id: 5, name: "Yamaha DX7", type: "FM Synthesizer", year: 1983, price: "$950", status: "Restocking" }
];
script.textContent = JSON.stringify(data);
renderContainer.appendChild(script);
}
renderContainer.appendChild(element);
} catch (err) {
console.error('ESM Direct Render Error:', err);
renderContainer.innerHTML = `
<div style="color: #ef4444; text-align: center; padding: 20px;">
<h3 style="margin-bottom: 8px;">Direct Render Failed</h3>
<p style="font-size: 12px; color: var(--text-secondary);">${err.message}</p>
</div>
`;
}
} else {
// Fallback to secure sandbox iframe for full standalone applications
renderContainer.style.display = 'none';
iframeWrapper.className = 'iframe-wrapper show';
iframe.src = path;
extLink.style.display = 'flex';
extLink.href = path;
}
if (updateHistory) {
history.pushState({ slug }, '', `?demo=${slug}`);
}
}
// Dynamic sizing controls handler
const sizeBtns = document.querySelectorAll('.size-btn');
sizeBtns.forEach(btn => {
btn.addEventListener('click', () => {
sizeBtns.forEach(b => b.classList.remove('active'));
btn.classList.add('active');
const size = btn.getAttribute('data-size');
// Update classes on both elements
renderContainer.className = 'render-container ' + size;
iframeWrapper.className = 'iframe-wrapper ' + size;
if (iframeWrapper.classList.contains('show') || iframe.src !== 'about:blank') {
iframeWrapper.classList.add('show');
}
});
});
function resetToHero(updateHistory = true) {
items.forEach(i => i.classList.remove('active'));
renderContainer.innerHTML = '';
iframe.src = 'about:blank';
viewport.style.display = 'none';
heroState.style.display = 'flex';
if (updateHistory) {
history.pushState(null, '', window.location.pathname);
}
}
// Click handler for project selection
items.forEach(item => {
item.addEventListener('click', (e) => {
e.preventDefault();
const slug = item.getAttribute('data-slug');
activateDemo(slug);
});
});
backBtn.addEventListener('click', () => {
resetToHero();
});
// Live search filter
const searchInput = document.getElementById('search');
searchInput.addEventListener('input', (e) => {
const val = e.target.value.toLowerCase();
items.forEach(item => {
const title = item.getAttribute('data-name').toLowerCase();
if (title.includes(val)) {
item.style.display = 'flex';
} else {
item.style.display = 'none';
}
});
});
// Initial Routing Load
window.addEventListener('load', () => {
const params = new URLSearchParams(window.location.search);
const demo = params.get('demo');
if (demo) {
activateDemo(demo, false);
}
});
// Handle history navigation (back/forward browser buttons)
window.addEventListener('popstate', (e) => {
const params = new URLSearchParams(window.location.search);
const demo = params.get('demo');
if (demo) {
activateDemo(demo, false);
} else {
resetToHero(false);
}
});
</script>
</body>
</html>