UNPKG

lightview

Version:

A reactive UI library with features of Bau, Juris, and HTMX plus safe LLM UI generation

361 lines (335 loc) 17.8 kB
<!-- SEO-friendly SPA Shim --> <script src="/lightview-router.js"></script> <script> if (globalThis.LightviewRouter) { LightviewRouter.base('/index.html'); } </script> <!-- Load the page-specific stylesheet --> <link rel="stylesheet" href="./index.css"> <!-- Gallery Structure --> <div class="gallery-page"> <div class="gallery-layout"> <!-- Sidebar Overlay --> <div id="sidebar-overlay" class="sidebar-overlay"></div> <!-- Sidebar --> <div id="gallery-sidebar" class="gallery-sidebar" style="visibility: hidden" src="./component-nav.html"></div> <!-- Main Content --> <div id="gallery-main" class="gallery-main"> <!-- Header Container --> <div style="position: sticky; top: 0; z-index: 30; background: var(--gallery-surface); border-bottom: 1px solid var(--gallery-border); backdrop-filter: blur(8px);"> <!-- Breadcrumbs Row --> <div style="padding: 0.75rem 1.5rem 0;"> <script> (() => { const { Breadcrumbs } = Lightview.tags; const breadcrumbs = Breadcrumbs({ id: 'page-breadcrumbs', items: [ { label: 'Components', href: '/docs/components' }, { label: 'Kbd' } ] }); document.currentScript.replaceWith(breadcrumbs.domEl); })(); </script> </div> <!-- Title Row --> <div class="gallery-header" style="border-bottom: none; height: auto; padding-top: 0.5rem; padding-bottom: 0.75rem;"> <button id="toggle-btn" class="toggle-btn" aria-label="Toggle Sidebar"> <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="toggle-icon" style="stroke: currentColor; stroke-width: 2;"> <path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" /> <path stroke-linecap="round" stroke-linejoin="round" d="M11 19l-7-7 7-7" /> </svg> </button> <h1 class="gallery-title">Kbd</h1> </div> </div> <!-- Content --> <div class="gallery-content"> <div class="section-content" style="max-width: 1000px;"> <p class="text-lg" style="opacity: 0.7; margin-bottom: 1.5rem;"> Kbd is used to display keyboard shortcuts and key combinations. Perfect for documentation and help interfaces. </p> <!-- Basic Example with Examplify --> <div class="card bg-base-200" style="margin-bottom: 2rem;"> <div class="card-body"> <h2 class="card-title">Basic Example</h2> <p class="text-sm" style="opacity: 0.7; margin-bottom: 1rem;">Keyboard keys with different sizes</p> <!-- Tabs --> <script> globalThis.switchSyntaxTab = (tabId) => { const tabs = ['tagged', 'vdom', 'object', 'html']; tabs.forEach(t => { const tabEl = document.getElementById(`tab-btn-${t}`); const contentEl = document.getElementById(`syntax-${t}`); if (t === tabId) { tabEl.classList.add('syntax-tab-active'); contentEl.style.display = 'block'; } else { tabEl.classList.remove('syntax-tab-active'); contentEl.style.display = 'none'; } }); }; </script> <div role="tablist" class="syntax-tabs" style="margin-bottom: 1rem;"> <button id="tab-btn-tagged" role="tab" class="syntax-tab syntax-tab-active" onclick="switchSyntaxTab('tagged')">Tagged</button> <button id="tab-btn-vdom" role="tab" class="syntax-tab" onclick="switchSyntaxTab('vdom')">vDOM</button> <button id="tab-btn-object" role="tab" class="syntax-tab" onclick="switchSyntaxTab('object')">Object DOM</button> <button id="tab-btn-html" role="tab" class="syntax-tab" onclick="switchSyntaxTab('html')">HTML</button> </div> <!-- Tagged Syntax --> <div id="syntax-tagged"> <pre><script> examplify(document.currentScript.nextElementSibling, { at: document.currentScript.parentElement, scripts: ['/lightview.js', '/lightview-x.js'], styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'], type: 'module', minHeight: 140, autoRun: true }); </script><code contenteditable="true">await import('/components/data-display/kbd.js'); const { tags, $ } = Lightview; const { div, span, Kbd } = tags; const shortcuts = div({ style: 'display: flex; flex-direction: column; gap: 1rem' }, div({ style: 'display: flex; gap: 0.5rem; align-items: center' }, span({}, 'Save: '), Kbd({}, '⌘'), Kbd({}, 'S') ), div({ style: 'display: flex; gap: 0.5rem; align-items: center' }, span({}, 'Undo: '), Kbd({}, '⌘'), Kbd({}, 'Z') ), div({ style: 'display: flex; gap: 0.5rem; align-items: center' }, span({}, 'Copy: '), Kbd({}, '⌘'), Kbd({}, 'C') ) ); $('#example').content(shortcuts);</code></pre> </div> <!-- vDOM Syntax --> <div id="syntax-vdom" style="display: none;"> <pre><script> examplify(document.currentScript.nextElementSibling, { at: document.currentScript.parentElement, scripts: ['/lightview.js', '/lightview-x.js'], styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'], type: 'module', minHeight: 140 }); </script><code contenteditable="true">await import('/components/data-display/kbd.js'); const { $, tags } = Lightview; const { Kbd } = tags; const shortcuts = { tag: 'div', attributes: { style: 'display: flex; flex-direction: column; gap: 1rem' }, children: [ { tag: 'div', attributes: { style: 'display: flex; gap: 0.5rem; align-items: center' }, children: [ { tag: 'span', children: ['Save: '] }, { tag: Kbd, children: ['⌘'] }, { tag: Kbd, children: ['S'] } ] }, { tag: 'div', attributes: { style: 'display: flex; gap: 0.5rem; align-items: center' }, children: [ { tag: 'span', children: ['Undo: '] }, { tag: Kbd, children: ['⌘'] }, { tag: Kbd, children: ['Z'] } ] }, { tag: 'div', attributes: { style: 'display: flex; gap: 0.5rem; align-items: center' }, children: [ { tag: 'span', children: ['Copy: '] }, { tag: Kbd, children: ['⌘'] }, { tag: Kbd, children: ['C'] } ] } ] }; $('#example').content(shortcuts);</code></pre> </div> <!-- Object DOM Syntax --> <div id="syntax-object" style="display: none;"> <pre><script> examplify(document.currentScript.nextElementSibling, { at: document.currentScript.parentElement, scripts: ['/lightview.js', '/lightview-x.js'], styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'], type: 'module', minHeight: 140 }); </script><code contenteditable="true">await import('/components/data-display/kbd.js'); const { $ } = Lightview; const shortcuts = { div: { style: 'display: flex; flex-direction: column; gap: 1rem', children: [ { div: { style: 'display: flex; gap: 0.5rem; align-items: center', children: [{ span: { children: ['Save: '] } }, { Kbd: { children: ['⌘'] } }, { Kbd: { children: ['S'] } }] } }, { div: { style: 'display: flex; gap: 0.5rem; align-items: center', children: [{ span: { children: ['Undo: '] } }, { Kbd: { children: ['⌘'] } }, { Kbd: { children: ['Z'] } }] } }, { div: { style: 'display: flex; gap: 0.5rem; align-items: center', children: [{ span: { children: ['Copy: '] } }, { Kbd: { children: ['⌘'] } }, { Kbd: { children: ['C'] } }] } } ] } }; $('#example').content(shortcuts);</code></pre> </div> <!-- HTML Syntax --> <div id="syntax-html" style="display: none;"> <pre><script> examplify(document.currentScript.nextElementSibling, { at: document.currentScript.parentElement, scripts: ['/lightview.js', '/lightview-x.js'], styles: ['https://cdn.jsdelivr.net/npm/daisyui@3.9.4/dist/full.min.css'], type: 'module', language: 'html', minHeight: 140 }); </script><code contenteditable="true" class="language-html">&lt;!-- Import the component (registers lv-kbd) --&gt; &lt;script type="module" src="/components/data-display/kbd.js"&gt;&lt;/script&gt; &lt;div style="display: flex; flex-direction: column; gap: 1rem"&gt; &lt;div style="display: flex; gap: 0.5rem; align-items: center"&gt; &lt;span&gt;Save: &lt;/span&gt; &lt;lv-kbd&gt;&lt;/lv-kbd&gt; &lt;lv-kbd&gt;S&lt;/lv-kbd&gt; &lt;/div&gt; &lt;div style="display: flex; gap: 0.5rem; align-items: center"&gt; &lt;span&gt;Undo: &lt;/span&gt; &lt;lv-kbd&gt;&lt;/lv-kbd&gt; &lt;lv-kbd&gt;Z&lt;/lv-kbd&gt; &lt;/div&gt; &lt;div style="display: flex; gap: 0.5rem; align-items: center"&gt; &lt;span&gt;Copy: &lt;/span&gt; &lt;lv-kbd&gt;&lt;/lv-kbd&gt; &lt;lv-kbd&gt;C&lt;/lv-kbd&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </div> <!-- Props Table --> <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Props</h2> <div style="overflow-x: auto; margin-bottom: 2rem;"> <table class="table table-zebra"> <thead> <tr> <th>Prop</th> <th>Type</th> <th>Default</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>size</code></td> <td>string</td> <td>-</td> <td>'xs' | 'sm' | 'md' | 'lg'</td> </tr> </tbody> </table> </div> <!-- Kbd Gallery --> <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Kbd Gallery</h2> <p class="text-sm" style="opacity: 0.7; margin-bottom: 1.5rem;"> Live examples using <code>&lt;lv-kbd&gt;</code> custom elements. </p> <script type="module" src="/components/data-display/kbd.js"></script> <!-- Keyboard Shortcuts --> <h3 class="text-lg font-semibold" style="margin-bottom: 0.75rem;">Keyboard Shortcuts</h3> <div style="display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 2rem;"> <div style="display: flex; gap: 0.25rem; align-items: center;"> <span style="min-width: 70px;">Save:</span> <lv-kbd></lv-kbd> <lv-kbd>S</lv-kbd> </div> <div style="display: flex; gap: 0.25rem; align-items: center;"> <span style="min-width: 70px;">Copy:</span> <lv-kbd></lv-kbd> <lv-kbd>C</lv-kbd> </div> <div style="display: flex; gap: 0.25rem; align-items: center;"> <span style="min-width: 70px;">Paste:</span> <lv-kbd></lv-kbd> <lv-kbd>V</lv-kbd> </div> <div style="display: flex; gap: 0.25rem; align-items: center;"> <span style="min-width: 70px;">Undo:</span> <lv-kbd></lv-kbd> <lv-kbd>Z</lv-kbd> </div> </div> <!-- All Sizes --> <h3 class="text-lg font-semibold" style="margin-bottom: 0.75rem;">All Sizes</h3> <div style="display: flex; align-items: flex-end; gap: 0.5rem; margin-bottom: 2rem;"> <lv-kbd size="xs">xs</lv-kbd> <lv-kbd size="sm">sm</lv-kbd> <lv-kbd size="md">md</lv-kbd> <lv-kbd size="lg">lg</lv-kbd> </div> <!-- Function Keys --> <h3 class="text-lg font-semibold" style="margin-bottom: 0.75rem;">Function Keys</h3> <div style="display: flex; gap: 0.25rem; margin-bottom: 2rem;"> <lv-kbd>F1</lv-kbd> <lv-kbd>F2</lv-kbd> <lv-kbd>F3</lv-kbd> <lv-kbd>F4</lv-kbd> <lv-kbd>F5</lv-kbd> <lv-kbd>F6</lv-kbd> <lv-kbd>F7</lv-kbd> <lv-kbd>F8</lv-kbd> <lv-kbd>F9</lv-kbd> <lv-kbd>F10</lv-kbd> <lv-kbd>F11</lv-kbd> <lv-kbd>F12</lv-kbd> </div> <!-- Arrow Keys --> <h3 class="text-lg font-semibold" style="margin-bottom: 0.75rem;">Arrow Keys</h3> <div style="display: inline-grid; grid-template-columns: repeat(3, auto); gap: 0.25rem; margin-bottom: 2rem;"> <div></div> <lv-kbd></lv-kbd> <div></div> <lv-kbd></lv-kbd> <lv-kbd></lv-kbd> <lv-kbd></lv-kbd> </div> </div> </div> </div> </div>