lightview
Version:
A reactive UI library with features of Bau, Juris, and HTMX plus safe LLM UI generation
396 lines (366 loc) • 19.2 kB
HTML
<!-- 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: 'Indicator' }
]
});
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">Indicator</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;">
Indicator is used to place an element at the corner of another element.
Perfect for notifications, badges, and status indicators.
</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;">Notification badge on inbox
</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/layout/indicator.js');
await import('/components/data-display/badge.js');
await import('/components/actions/button.js');
const { signal, tags, $ } = Lightview;
const { div, img, Indicator, Badge, Button } = tags;
const count = signal(3);
const demo = div({ style: 'display: flex; gap: 2rem' },
Indicator({},
Indicator.Item({},
Badge({ color: 'primary' }, () => count.value)
),
Button({
onclick: () => { count.value++; }
}, 'Messages')
),
Indicator({},
Indicator.Item({ position: 'bottom-end' },
Badge({ color: 'success', size: 'xs' })
),
div({ class: 'avatar' },
div({ class: 'w-12 rounded-full' },
img({ src: 'https://i.pravatar.cc/100?img=5' })
)
)
)
);
$('#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/layout/indicator.js');
await import('/components/data-display/badge.js');
await import('/components/actions/button.js');
const { signal, $, tags } = Lightview;
const { Indicator, Badge, Button, div, img } = tags;
const count = signal(3);
const demo = {
tag: div,
attributes: { style: 'display: flex; gap: 2rem' },
children: [
{
tag: Indicator,
children: [
{
tag: Indicator.Item,
children: [{ tag: Badge, attributes: { color: 'primary' }, children: [() => count.value] }]
},
{
tag: Button,
attributes: { onclick: () => { count.value++; } },
children: ['Messages']
}
]
},
{
tag: Indicator,
children: [
{
tag: Indicator.Item,
attributes: { position: 'bottom-end' },
children: [{ tag: Badge, attributes: { color: 'success', size: 'xs' } }]
},
{
tag: div,
attributes: { class: 'avatar' },
children: [
{
tag: div,
attributes: { class: 'w-12 rounded-full' },
children: [{ tag: img, attributes: { src: 'https://i.pravatar.cc/100?img=5' } }]
}
]
}
]
}
]
};
$('#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/layout/indicator.js');
await import('/components/data-display/badge.js');
await import('/components/actions/button.js');
const { signal, $ } = Lightview;
const count = signal(3);
const demo = {
div: {
style: 'display: flex; gap: 2rem',
children: [
{
Indicator: {
children: [
{
'Indicator.Item': {
children: [{ Badge: { color: 'primary', children: [() => count.value] } }]
}
},
{
Button: {
onclick: () => { count.value++; },
children: ['Messages']
}
}
]
}
},
{
Indicator: {
children: [
{
'Indicator.Item': {
position: 'bottom-end',
children: [{ Badge: { color: 'success', size: 'xs' } }]
}
},
{
div: {
class: 'avatar',
children: [
{
div: {
class: 'w-12 rounded-full',
children: [{ img: { src: 'https://i.pravatar.cc/100?img=5' } }]
}
}
]
}
}
]
}
}
]
}
};
$('#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"><script type="module" src="/components/layout/indicator.js"></script>
<script type="module" src="/components/data-display/badge.js"></script>
<script type="module" src="/components/actions/button.js"></script>
<div style="display: flex; gap: 2rem">
<lv-indicator>
<item class="badge badge-primary">3</item>
<lv-button>Messages</lv-button>
</lv-indicator>
<lv-indicator>
<item position="bottom-end" class="badge badge-success badge-xs"></item>
<div class="avatar">
<div class="w-12 rounded-full">
<img src="https://i.pravatar.cc/100?img=5" />
</div>
</div>
</lv-indicator>
</div></code></pre>
</div>
</div>
</div>
<!-- Props Table -->
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Indicator.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>position</code></td>
<td>string</td>
<td>'top-end'</td>
<td>'top-start' | 'top-center' | 'top-end' | 'bottom-start' | 'bottom-center' |
'bottom-end'
</td>
</tr>
</tbody>
</table>
</div>
<!-- Indicator Gallery -->
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Indicator Gallery</h2>
<p class="text-sm" style="opacity: 0.7; margin-bottom: 1.5rem;">
Live examples using <code><lv-indicator></code> custom elements.
</p>
<script type="module" src="/components/layout/indicator.js"></script>
<script type="module" src="/components/data-display/badge.js"></script>
<h3 class="text-lg font-semibold" style="margin-bottom: 0.75rem;">Top Positions</h3>
<div style="display: flex; gap: 2rem; margin-bottom: 2rem; flex-wrap: wrap;">
<lv-indicator>
<item position="top-start" class="badge badge-secondary">top-start</item>
<div class="bg-base-300 p-6 rounded-box">content</div>
</lv-indicator>
<lv-indicator>
<item position="top-center" class="badge badge-secondary">top-center</item>
<div class="bg-base-300 p-6 rounded-box">content</div>
</lv-indicator>
<lv-indicator>
<item position="top-end" class="badge badge-secondary">top-end</item>
<div class="bg-base-300 p-6 rounded-box">content</div>
</lv-indicator>
</div>
<h3 class="text-lg font-semibold" style="margin-bottom: 0.75rem;">Bottom Positions</h3>
<div style="display: flex; gap: 2rem; margin-bottom: 2rem; flex-wrap: wrap;">
<lv-indicator>
<item position="bottom-start" class="badge badge-secondary">bottom-start</item>
<div class="bg-base-300 p-6 rounded-box">content</div>
</lv-indicator>
<lv-indicator>
<item position="bottom-center" class="badge badge-secondary">bottom-center</item>
<div class="bg-base-300 p-6 rounded-box">content</div>
</lv-indicator>
<lv-indicator>
<item position="bottom-end" class="badge badge-secondary">bottom-end</item>
<div class="bg-base-300 p-6 rounded-box">content</div>
</lv-indicator>
</div>
<h3 class="text-lg font-semibold" style="margin-bottom: 0.75rem;">Common Use Cases</h3>
<div style="display: flex; gap: 3rem; margin-bottom: 2rem; align-items: center;">
<lv-indicator>
<item class="badge badge-primary">99+</item>
<lv-button>Inbox</lv-button>
</lv-indicator>
<lv-indicator>
<item position="bottom-end" class="badge badge-success badge-xs"></item>
<div class="avatar">
<div class="w-12 rounded-full">
<img src="https://i.pravatar.cc/100?img=8" />
</div>
</div>
</lv-indicator>
</div>
</div>
</div>
</div>
</div>