UNPKG

lightview

Version:

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

454 lines (411 loc) 21.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: 'Radial Progress' } ] }); 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">Radial Progress</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;"> Radial progress shows a circular progress indicator. Supports custom colors, sizes, and thickness. </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;">Static radial progress indicators</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: 100, autoRun: true }); </script><code contenteditable="true">await import('/components/data-display/radial-progress.js'); const { tags, $ } = Lightview; const { div, RadialProgress } = tags; const demo = div({ style: 'display: flex; gap: 1rem' }, RadialProgress({ value: 0 }, '0%'), RadialProgress({ value: 25 }, '25%'), RadialProgress({ value: 50, color: 'primary' }, '50%'), RadialProgress({ value: 75, color: 'secondary' }, '75%'), RadialProgress({ value: 100, color: 'success' }, '100%') ); $('#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: 100 }); </script><code contenteditable="true">await import('/components/data-display/radial-progress.js'); const { $, tags } = Lightview; const { RadialProgress } = tags; const demo = { tag: 'div', attributes: { style: 'display: flex; gap: 1rem' }, children: [ { tag: RadialProgress, attributes: { value: 0 }, children: ['0%'] }, { tag: RadialProgress, attributes: { value: 25 }, children: ['25%'] }, { tag: RadialProgress, attributes: { value: 50, color: 'primary' }, children: ['50%'] }, { tag: RadialProgress, attributes: { value: 75, color: 'secondary' }, children: ['75%'] }, { tag: RadialProgress, attributes: { value: 100, color: 'success' }, children: ['100%'] } ] }; $('#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: 100 }); </script><code contenteditable="true">await import('/components/data-display/radial-progress.js'); const { $ } = Lightview; const demo = { div: { style: 'display: flex; gap: 1rem', children: [ { RadialProgress: { value: 0, children: ['0%'] } }, { RadialProgress: { value: 25, children: ['25%'] } }, { RadialProgress: { value: 50, color: 'primary', children: ['50%'] } }, { RadialProgress: { value: 75, color: 'secondary', children: ['75%'] } }, { RadialProgress: { value: 100, color: 'success', children: ['100%'] } } ] } }; $('#example').content(demo);</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: 100 }); </script><code contenteditable="true" class="language-html">&lt;!-- Import the component (registers lv-radial-progress) --&gt; &lt;script type="module" src="/components/data-display/radial-progress.js"&gt;&lt;/script&gt; &lt;div style="display: flex; gap: 1rem;"&gt; &lt;lv-radial-progress value="0"&gt;0%&lt;/lv-radial-progress&gt; &lt;lv-radial-progress value="25"&gt;25%&lt;/lv-radial-progress&gt; &lt;lv-radial-progress value="50" color="primary"&gt;50%&lt;/lv-radial-progress&gt; &lt;lv-radial-progress value="75" color="secondary"&gt;75%&lt;/lv-radial-progress&gt; &lt;lv-radial-progress value="100" color="success"&gt;100%&lt;/lv-radial-progress&gt; &lt;/div&gt;</code></pre> </div> </div> </div> <div id="syntax-reactive-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: 200 }); </script><code contenteditable="true">await import('/components/data-display/radial-progress.js'); await import('/components/actions/button.js'); const { signal, tags, $ } = Lightview; const { div, RadialProgress, Button } = tags; const progress = signal(0); let interval; const start = () => { if (interval) return; interval = setInterval(() => { progress.value = (progress.value + 1) % 101; }, 50); }; const stop = () => { clearInterval(interval); interval = null; }; const demo = div({ style: 'display: flex; flex-direction: column; align-items: center; gap: 1rem' }, RadialProgress({ value: () => progress.value, size: '8rem', color: () => progress.value >= 100 ? 'success' : 'primary' }, () => `${progress.value}%`), div({ style: 'display: flex; gap: 0.5rem' }, Button({ size: 'sm', onclick: start }, 'Start'), Button({ size: 'sm', onclick: stop }, 'Stop'), Button({ size: 'sm', onclick: () => { progress.value = 0; } }, 'Reset') ) ); $('#example').content(demo);</code></pre> </div> <!-- vDOM Syntax --> <div id="syntax-reactive-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: 200 }); </script><code contenteditable="true">await import('/components/data-display/radial-progress.js'); await import('/components/actions/button.js'); const { signal, $, tags } = Lightview; const { RadialProgress, Button } = tags; const progress = signal(0); let interval; const start = () => { if (interval) return; interval = setInterval(() => { progress.value = (progress.value + 1) % 101; }, 50); }; const stop = () => { clearInterval(interval); interval = null; }; const demo = { tag: 'div', attributes: { style: 'display: flex; flex-direction: column; align-items: center; gap: 1rem' }, children: [ { tag: RadialProgress, attributes: { value: () => progress.value, size: '8rem', color: () => progress.value >= 100 ? 'success' : 'primary' }, children: [() => `${progress.value}%`] }, { tag: 'div', attributes: { style: 'display: flex; gap: 0.5rem' }, children: [ { tag: Button, attributes: { size: 'sm', onclick: start }, children: ['Start'] }, { tag: Button, attributes: { size: 'sm', onclick: stop }, children: ['Stop'] }, { tag: Button, attributes: { size: 'sm', onclick: () => { progress.value = 0; } }, children: ['Reset'] } ] } ] }; $('#example').content(demo);</code></pre> </div> <!-- Object DOM Syntax --> <div id="syntax-reactive-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: 200 }); </script><code contenteditable="true">await import('/components/data-display/radial-progress.js'); await import('/components/actions/button.js'); const { signal, $ } = Lightview; const progress = signal(0); let interval; const start = () => { if (interval) return; interval = setInterval(() => { progress.value = (progress.value + 1) % 101; }, 50); }; const stop = () => { clearInterval(interval); interval = null; }; const demo = { div: { style: 'display: flex; flex-direction: column; align-items: center; gap: 1rem', children: [ { RadialProgress: { value: () => progress.value, size: '8rem', color: () => progress.value >= 100 ? 'success' : 'primary', children: [() => `${progress.value}%`] } }, { div: { style: 'display: flex; gap: 0.5rem', children: [ { Button: { size: 'sm', onclick: start, children: ['Start'] } }, { Button: { size: 'sm', onclick: stop, children: ['Stop'] } }, { Button: { size: 'sm', onclick: () => { progress.value = 0; }, children: ['Reset'] } } ] } } ] } }; $('#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>value</code></td> <td>number | signal</td> <td>0</td> <td>Progress value (0-100)</td> </tr> <tr> <td><code>size</code></td> <td>string</td> <td>-</td> <td>CSS size value (e.g., '8rem')</td> </tr> <tr> <td><code>thickness</code></td> <td>string</td> <td>-</td> <td>Line thickness (e.g., '4px', '1rem')</td> </tr> <tr> <td><code>color</code></td> <td>string</td> <td>-</td> <td>'primary' | 'secondary' | 'accent' | 'success' | 'warning' | 'error'</td> </tr> </tbody> </table> </div> <!-- Radial Progress Gallery --> <h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Radial Progress Gallery</h2> <p class="text-sm" style="opacity: 0.7; margin-bottom: 1.5rem;"> Live examples using <code>&lt;lv-radial-progress&gt;</code> custom elements. </p> <script type="module" src="/components/data-display/radial-progress.js"></script> <!-- Different Values --> <h3 class="text-lg font-semibold" style="margin-bottom: 0.75rem;">Different Values</h3> <div style="display: flex; gap: 1rem; margin-bottom: 2rem;"> <lv-radial-progress value="0">0%</lv-radial-progress> <lv-radial-progress value="25">25%</lv-radial-progress> <lv-radial-progress value="50">50%</lv-radial-progress> <lv-radial-progress value="75">75%</lv-radial-progress> <lv-radial-progress value="100">100%</lv-radial-progress> </div> <!-- All Colors --> <h3 class="text-lg font-semibold" style="margin-bottom: 0.75rem;">All Colors</h3> <div style="display: flex; gap: 1rem; margin-bottom: 2rem;"> <lv-radial-progress value="70" color="text-primary">70%</lv-radial-progress> <lv-radial-progress value="70" color="text-secondary">70%</lv-radial-progress> <lv-radial-progress value="70" color="text-accent">70%</lv-radial-progress> <lv-radial-progress value="70" color="text-success">70%</lv-radial-progress> <lv-radial-progress value="70" color="text-warning">70%</lv-radial-progress> <lv-radial-progress value="70" color="text-error">70%</lv-radial-progress> </div> <!-- Custom Size & Thickness --> <h3 class="text-lg font-semibold" style="margin-bottom: 0.75rem;">Custom Size & Thickness</h3> <div style="display: flex; gap: 1rem; align-items: center; margin-bottom: 2rem;"> <lv-radial-progress value="70" size="6rem">70%</lv-radial-progress> <lv-radial-progress value="70" size="8rem" thickness="2px">70%</lv-radial-progress> <lv-radial-progress value="70" size="10rem" thickness="1rem" color="text-success">70%</lv-radial-progress> </div> </div> </div> </div> </div>