lightview
Version:
A reactive UI library with features of Bau, Juris, and HTMX plus safe LLM UI generation
277 lines (256 loc) • 14.8 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: 'Dock' }
]
});
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">Dock</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;">
Dock is a bottom navigation bar for mobile interfaces.
Supports icons with labels and active states.
</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 bottom navigation
</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'],
type: 'module',
minHeight: 150,
autoRun: true
});
</script><code contenteditable="true">const { default: Dock } = await import('/components/navigation/dock.js');
const { signal, tags, $ } = Lightview;
const { div } = tags;
const active = signal('home');
const demo = div({ style: 'position: relative; height: 8rem; background-color: #f2f2f2; border-radius: 1rem; overflow: hidden;' },
Dock({ style: 'position: absolute; bottom: 0; left: 0; right: 0;' },
Dock.Item({
active: () => active.value === 'home',
onclick: () => { active.value = 'home'; }
}, '🏠', Dock.Label({}, 'Home')),
Dock.Item({
active: () => active.value === 'search',
onclick: () => { active.value = 'search'; }
}, '🔍', Dock.Label({}, 'Search')),
Dock.Item({
active: () => active.value === 'profile',
onclick: () => { active.value = 'profile'; }
}, '👤', Dock.Label({}, 'Profile'))
)
);
$('#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'],
type: 'module',
minHeight: 150
});
</script><code contenteditable="true">const { default: Dock } = await import('/components/navigation/dock.js');
const { signal, $ } = Lightview;
const active = signal('home');
const demo = {
tag: 'div',
attributes: { style: 'position: relative; height: 8rem; background-color: #f2f2f2; border-radius: 1rem; overflow: hidden;' },
children: [
{
tag: Dock,
attributes: { style: 'position: absolute; bottom: 0; left: 0; right: 0;' },
children: [
{
tag: Dock.Item,
attributes: { active: () => active.value === 'home', onclick: () => { active.value = 'home'; } },
children: ['🏠', { tag: Dock.Label, children: ['Home'] }]
},
{
tag: Dock.Item,
attributes: { active: () => active.value === 'search', onclick: () => { active.value = 'search'; } },
children: ['🔍', { tag: Dock.Label, children: ['Search'] }]
},
{
tag: Dock.Item,
attributes: { active: () => active.value === 'profile', onclick: () => { active.value = 'profile'; } },
children: ['👤', { tag: Dock.Label, children: ['Profile'] }]
}
]
}
]
};
$('#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'],
type: 'module',
minHeight: 150
});
</script><code contenteditable="true">await import('/components/navigation/dock.js');
const { signal, $ } = Lightview;
const active = signal('home');
const demo = {
div: {
style: 'position: relative; height: 8rem; background-color: #f2f2f2; border-radius: 1rem; overflow: hidden;',
children: [
{
Dock: {
style: 'position: absolute; bottom: 0; left: 0; right: 0;',
children: [
{ 'Dock.Item': { active: () => active.value === 'home', onclick: () => { active.value = 'home'; }, children: ['🏠', { 'Dock.Label': { children: ['Home'] } }] } },
{ 'Dock.Item': { active: () => active.value === 'search', onclick: () => { active.value = 'search'; }, children: ['🔍', { 'Dock.Label': { children: ['Search'] } }] } },
{ 'Dock.Item': { active: () => active.value === 'profile', onclick: () => { active.value = 'profile'; }, children: ['👤', { 'Dock.Label': { children: ['Profile'] } }] } }
]
}
}
]
}
};
$('#example').content(demo);</code></pre>
</div>
</div>
</div>
<!-- Props Table -->
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Sub-components</h2>
<div style="overflow-x: auto; margin-bottom: 2rem;">
<table class="table table-zebra">
<thead>
<tr>
<th>Component</th>
<th>Props</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Dock.Item</code></td>
<td>active</td>
<td>Navigation item</td>
</tr>
<tr>
<td><code>Dock.Label</code></td>
<td>-</td>
<td>Text label below icon</td>
</tr>
</tbody>
</table>
</div>
<!-- Static Example -->
<h2 class="text-xl font-bold" style="margin-bottom: 1rem;">Static Demo</h2>
<div
style="position: relative; height: 8rem; margin-bottom: 2rem; overflow: hidden; background-color: #f2f2f2; border-radius: 1rem;">
<div class="dock"
style="position: absolute; bottom: 0; left: 0; right: 0; background-color: white;">
<button class="dock-active">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6" />
</svg>
<span class="dock-label">Home</span>
</button>
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span class="dock-label">Details</span>
</button>
<button>
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
</svg>
<span class="dock-label">Stats</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>