UNPKG

lightview

Version:

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

356 lines (332 loc) 16.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: 'Steps' } ] }); 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">Steps</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;"> Steps show a sequence of steps and current progress. Supports colors, icons, and vertical layout. </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;">Interactive checkout steps</p> <!-- Tabs --> <script> globalThis.switchSyntaxTab = (tabId) => { const tabs = ['tagged', 'vdom', 'object']; 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> </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: 120, autoRun: true }); </script><code contenteditable="true">await import('/components/navigation/steps.js'); await import('/components/actions/button.js'); const { signal, tags, $ } = Lightview; const { div, Steps, Button } = tags; const currentStep = signal(1); const stepNames = ['Cart', 'Shipping', 'Payment', 'Confirm']; const demo = div({ style: 'display: flex; flex-direction: column; gap: 1rem;' }, Steps({}, ...stepNames.map((name, i) => Steps.Item({ color: () => i < currentStep.value ? 'primary' : undefined }, name) ) ), div({ style: 'display: flex; gap: 0.5rem; justify-content: center;' }, Button({ size: 'sm', disabled: () => currentStep.value <= 1, onclick: () => { currentStep.value--; } }, 'Back'), Button({ size: 'sm', color: 'primary', disabled: () => currentStep.value >= stepNames.length, onclick: () => { currentStep.value++; } }, 'Next') ) ); $('#example').content(demo);</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: 120 }); </script><code contenteditable="true">await import('/components/navigation/steps.js'); await import('/components/actions/button.js'); const { signal, $, tags } = Lightview; const { Steps, Button, div } = tags; const currentStep = signal(1); const stepNames = ['Cart', 'Shipping', 'Payment', 'Confirm']; const demo = { tag: div, attributes: { style: 'display: flex; flex-direction: column; gap: 1rem;' }, children: [ { tag: Steps, children: stepNames.map((name, i) => ({ tag: Steps.Item, attributes: { color: () => i < currentStep.value ? 'primary' : undefined }, children: [name] })) }, { tag: div, attributes: { style: 'display: flex; gap: 0.5rem; justify-content: center;' }, children: [ { tag: Button, attributes: { size: 'sm', disabled: () => currentStep.value <= 1, onclick: () => { currentStep.value--; } }, children: ['Back'] }, { tag: Button, attributes: { size: 'sm', color: 'primary', disabled: () => currentStep.value >= stepNames.length, onclick: () => { currentStep.value++; } }, children: ['Next'] } ] } ] }; $('#example').content(demo);</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: 120 }); </script><code contenteditable="true">await import('/components/navigation/steps.js'); await import('/components/actions/button.js'); const { signal, $ } = Lightview; const currentStep = signal(1); const stepNames = ['Cart', 'Shipping', 'Payment', 'Confirm']; const demo = { div: { style: 'display: flex; flex-direction: column; gap: 1rem;', children: [ { Steps: { children: stepNames.map((name, i) => ({ 'Steps.Item': { color: () => i < currentStep.value ? 'primary' : undefined, children: [name] } })) } }, { div: { style: 'display: flex; gap: 0.5rem; justify-content: center;', children: [ { Button: { size: 'sm', disabled: () => currentStep.value <= 1, onclick: () => { currentStep.value--; }, children: ['Back'] } }, { Button: { size: 'sm', color: 'primary', disabled: () => currentStep.value >= stepNames.length, onclick: () => { currentStep.value++; }, children: ['Next'] } } ] } } ] } }; $('#example').content(demo);</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>vertical</code></td> <td>boolean</td> <td>false</td> <td>Vertical layout</td> </tr> </tbody> </table> </div> <!-- Steps.Item Props --> <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Steps.Item 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>color</code></td> <td>string</td> <td>-</td> <td>'primary' | 'secondary' | 'accent' | 'info' | 'success' | 'warning' | 'error' </td> </tr> <tr> <td><code>content</code></td> <td>string</td> <td>-</td> <td>Custom icon/content for step circle</td> </tr> </tbody> </table> </div> <!-- Colors --> <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Colors</h2> <ul class="steps" style="margin-bottom: 2rem;"> <li class="step step-primary">Primary</li> <li class="step step-secondary">Secondary</li> <li class="step step-accent">Accent</li> <li class="step step-info">Info</li> <li class="step step-success">Success</li> <li class="step step-warning">Warning</li> <li class="step step-error">Error</li> </ul> <!-- With Icons --> <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">With Icons</h2> <ul class="steps" style="margin-bottom: 2rem;"> <li class="step step-info" data-content="?">Step 1</li> <li class="step step-info" data-content="!">Step 2</li> <li class="step step-info" data-content="✓">Step 3</li> <li class="step step-info" data-content="✕">Step 4</li> <li class="step step-info" data-content="★">Step 5</li> </ul> <!-- Vertical --> <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Vertical</h2> <ul class="steps steps-vertical" style="margin-bottom: 2rem;"> <li class="step step-primary">Register</li> <li class="step step-primary">Choose plan</li> <li class="step">Purchase</li> <li class="step">Receive Product</li> </ul> </div> </div> </div> </div> </div>