You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
738 lines
33 KiB
738 lines
33 KiB
<script lang="ts">
|
|
import {
|
|
Drawer,
|
|
type DrawerVariant,
|
|
type DrawerDirection,
|
|
type DrawerSize
|
|
} from '$uix/eidos/components/drawer';
|
|
import { compileMorfo } from '$uix/morfo';
|
|
import { drawerMorfo } from '@/uix/morfo/components/drawer';
|
|
import { resolveSignature } from '$uix/sema';
|
|
import { getActiveUix } from '$active-uix';
|
|
|
|
const uix = getActiveUix();
|
|
|
|
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
|
|
let tab = $state<Tab>('live');
|
|
|
|
// ── Live state ────────────────────────────────────────────────────────
|
|
let open = $state(false);
|
|
let variant = $state<DrawerVariant>('overlay');
|
|
let direction = $state<DrawerDirection>('right');
|
|
let size = $state<DrawerSize>('md');
|
|
let disabled = $state(false);
|
|
let dismissible = $state(true);
|
|
let handleOnly = $state(false);
|
|
let dragToDismiss = $state(false);
|
|
let showHandle = $state(false);
|
|
let overlayOpacity = $state(0.62);
|
|
let closeThreshold = $state(0.25);
|
|
let velocityThreshold = $state(0.5);
|
|
let trapFocus = $state(true);
|
|
let loop = $state(false);
|
|
let preventScroll = $state(true);
|
|
let isDragging = $state(false);
|
|
let triggerLabel = $state('Open drawer');
|
|
let titleText = $state('Drawer panel');
|
|
let descText = $state('Drag from the leading edge or press Escape to dismiss.');
|
|
let bodyText = $state(
|
|
'Drawers are side panels with snap points and gesture-driven drag — they reserve attention without freezing the rest of the surface in inline / persistent variants.'
|
|
);
|
|
|
|
type TraceEntry = { event: string; family: string; intent?: string; at: number };
|
|
let trace = $state<TraceEntry[]>([]);
|
|
|
|
let stageRef = $state<HTMLElement | null>(null);
|
|
$effect(() => {
|
|
const el = stageRef;
|
|
if (!el) return;
|
|
const obs = new MutationObserver((mutations) => {
|
|
for (const m of mutations) {
|
|
if (m.attributeName !== 'data-event') continue;
|
|
const target = m.target as Element;
|
|
const ev = target.getAttribute('data-event');
|
|
if (!ev) continue;
|
|
trace = [
|
|
{
|
|
event: ev,
|
|
family: target.getAttribute('data-event-family') ?? '—',
|
|
intent: target.getAttribute('data-event-intent') ?? undefined,
|
|
at: Date.now()
|
|
},
|
|
...trace
|
|
].slice(0, 6);
|
|
}
|
|
});
|
|
obs.observe(el, { attributes: true, subtree: true, attributeFilter: ['data-event'] });
|
|
return () => obs.disconnect();
|
|
});
|
|
|
|
// ── Compiled morfo ────────────────────────────────────────────────────
|
|
const compiled = compileMorfo(drawerMorfo);
|
|
const partsList = $derived([...compiled.parts.byKebab.values()]);
|
|
const events = $derived([...compiled.actions.byName.values()]);
|
|
const dataAttrsContent = compiled.contracts.dataAttrsByPart.get('content') ?? [];
|
|
|
|
function fmtTime(at: number): string {
|
|
const d = new Date(at);
|
|
return `${String(d.getSeconds()).padStart(2, '0')}.${String(d.getMilliseconds()).padStart(3, '0')}`;
|
|
}
|
|
|
|
// Soma snippet — headless, ARIA + behavior only. No visual concerns.
|
|
const somaSnippet = $derived(
|
|
[
|
|
"<script lang='ts'>",
|
|
" import * as Drawer from '$soma/components/drawer';",
|
|
' let open = $state(false);',
|
|
'</' + 'script>',
|
|
'',
|
|
'<Drawer.Provider',
|
|
' bind:open',
|
|
variant !== 'overlay' && ` variant="${variant}"`,
|
|
direction !== 'bottom' && ` direction="${direction}"`,
|
|
!dismissible && ' dismissible={false}',
|
|
handleOnly && ' handleOnly',
|
|
dragToDismiss && ' dragToDismiss',
|
|
disabled && ' disabled',
|
|
closeThreshold !== 0.25 && ` closeThreshold={${closeThreshold}}`,
|
|
velocityThreshold !== 0.5 && ` velocityThreshold={${velocityThreshold}}`,
|
|
'>',
|
|
variant !== 'persistent' && ` <Drawer.Trigger>${triggerLabel}</Drawer.Trigger>`,
|
|
variant === 'overlay' && ' <Drawer.Overlay />',
|
|
' <Drawer.Content',
|
|
!trapFocus && ' trapFocus={false}',
|
|
loop && ' loop',
|
|
!preventScroll && ' preventScroll={false}',
|
|
' >',
|
|
showHandle && ' <Drawer.Handle />',
|
|
` <Drawer.Title>${titleText}</Drawer.Title>`,
|
|
` <Drawer.Description>${descText}</Drawer.Description>`,
|
|
' <p>...</p>',
|
|
variant !== 'persistent' && ' <Drawer.Close>Close</Drawer.Close>',
|
|
' </Drawer.Content>',
|
|
'</Drawer.Provider>'
|
|
]
|
|
.filter(Boolean)
|
|
.join('\n')
|
|
);
|
|
|
|
// Eidos snippet — disciplined option C compound shape:
|
|
// `<Drawer>` is the root, child parts attached as `<Drawer.X>`.
|
|
const eidosSnippet = $derived(
|
|
[
|
|
"<script lang='ts'>",
|
|
" import { Drawer } from '$uix/eidos/components/drawer';",
|
|
' let open = $state(false);',
|
|
'</' + 'script>',
|
|
'',
|
|
'<Drawer',
|
|
' bind:open',
|
|
variant !== 'overlay' && ` variant="${variant}"`,
|
|
direction !== 'bottom' && ` direction="${direction}"`,
|
|
!dismissible && ' dismissible={false}',
|
|
handleOnly && ' handleOnly',
|
|
dragToDismiss && ' dragToDismiss',
|
|
disabled && ' disabled',
|
|
'>',
|
|
variant !== 'persistent' && ` <Drawer.Trigger>${triggerLabel}</Drawer.Trigger>`,
|
|
variant === 'overlay' && ` <Drawer.Overlay${overlayOpacity !== 0.62 ? ` overlayOpacity={${overlayOpacity}}` : ''} />`,
|
|
' <Drawer.Content',
|
|
size !== 'md' && ` size="${size}"`,
|
|
!trapFocus && ' trapFocus={false}',
|
|
loop && ' loop',
|
|
!preventScroll && ' preventScroll={false}',
|
|
' >',
|
|
showHandle && ' <Drawer.Handle />',
|
|
` <Drawer.Title>${titleText}</Drawer.Title>`,
|
|
` <Drawer.Description>${descText}</Drawer.Description>`,
|
|
' <p>...</p>',
|
|
variant !== 'persistent' && ' <Drawer.Close>Close</Drawer.Close>',
|
|
' </Drawer.Content>',
|
|
'</Drawer>'
|
|
]
|
|
.filter(Boolean)
|
|
.join('\n')
|
|
);
|
|
</script>
|
|
|
|
<div data-uix-canvas-inner>
|
|
<header>
|
|
<div data-uix-eyebrow>Overlays · Drawer</div>
|
|
<h1 data-uix-page-title>Drawer</h1>
|
|
<p data-uix-page-lede>
|
|
Side panel with snap-point resize and opt-in drag dismissal. Three
|
|
variants — overlay (modal sheet, backdrop + focus trap), inline (no
|
|
backdrop, background interactive), persistent (always-visible, in
|
|
layout flow). Eight parts, six events with causal exit reasons via
|
|
<code>data-last-action</code>.
|
|
</p>
|
|
<div data-uix-page-meta>
|
|
<span data-uix-meta-pill>
|
|
<span data-uix-meta-key>parts</span>{compiled.parts.order.length}
|
|
</span>
|
|
<span data-uix-meta-pill>
|
|
<span data-uix-meta-key>events</span>{events.length}
|
|
</span>
|
|
<span data-uix-meta-pill>
|
|
<span data-uix-meta-key>variants</span>3
|
|
</span>
|
|
<span data-uix-meta-pill>
|
|
<span data-uix-meta-key>sizes</span>4
|
|
</span>
|
|
<span data-uix-meta-pill>
|
|
<span data-uix-meta-key>apg</span>
|
|
<a href={drawerMorfo.apg} target="_blank" rel="noreferrer">dialog-modal ↗</a>
|
|
</span>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Live preview always rendered -->
|
|
<div data-uix-stage>
|
|
<div data-uix-stage-area bind:this={stageRef}>
|
|
<Drawer
|
|
bind:open
|
|
bind:isDragging
|
|
{variant}
|
|
{direction}
|
|
{disabled}
|
|
{dismissible}
|
|
{handleOnly}
|
|
{dragToDismiss}
|
|
{closeThreshold}
|
|
{velocityThreshold}
|
|
>
|
|
{#if variant !== 'persistent'}
|
|
<Drawer.Trigger data-perm-step="0" data-perm-label="open drawer">
|
|
{triggerLabel}
|
|
</Drawer.Trigger>
|
|
{/if}
|
|
{#if variant === 'overlay'}
|
|
<Drawer.Overlay {overlayOpacity} />
|
|
{/if}
|
|
<Drawer.Content {size} {trapFocus} {loop} {preventScroll}>
|
|
{#if showHandle}<Drawer.Handle />{/if}
|
|
<div class="drawer-scroll">
|
|
<Drawer.Title>{titleText}</Drawer.Title>
|
|
<Drawer.Description>{descText}</Drawer.Description>
|
|
<p style="margin: var(--uix-space-4) 0; color: var(--uix-text-muted);">{bodyText}</p>
|
|
{#if variant !== 'persistent'}
|
|
<Drawer.Close data-perm-step="1" data-perm-label="close drawer">
|
|
Close
|
|
</Drawer.Close>
|
|
{/if}
|
|
</div>
|
|
</Drawer.Content>
|
|
</Drawer>
|
|
</div>
|
|
<div data-uix-stage-trace>
|
|
<span data-uix-stage-trace-key>trace</span>
|
|
{#if trace.length === 0}
|
|
<span>open the drawer to see events</span>
|
|
{:else}
|
|
{#each trace.slice(0, 3) as entry}
|
|
<span><span data-uix-stage-trace-event>{entry.event}</span> · {entry.family}{entry.intent ? ' · ' + entry.intent : ''}</span>
|
|
<span style="color: var(--uix-text-faint)">{fmtTime(entry.at)}</span>
|
|
{/each}
|
|
{/if}
|
|
<span style="margin-inline-start: auto;">
|
|
<span data-uix-stage-trace-key>open</span> {String(open)}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Tabs -->
|
|
<div data-uix-tabs role="tablist">
|
|
<button data-uix-tab data-active={tab === 'live'} onclick={() => (tab = 'live')}>Live</button>
|
|
<button data-uix-tab data-active={tab === 'api'} onclick={() => (tab = 'api')}>
|
|
API <span data-uix-tab-count>17</span>
|
|
</button>
|
|
<button data-uix-tab data-active={tab === 'morfo'} onclick={() => (tab = 'morfo')}>
|
|
<span data-uix-layer-badge="morfo">morfo</span>
|
|
<span data-uix-tab-count>{partsList.length}p · {events.length}e</span>
|
|
</button>
|
|
<button data-uix-tab data-active={tab === 'sema'} onclick={() => (tab = 'sema')}>
|
|
<span data-uix-layer-badge="sema">sema</span>
|
|
<span data-uix-tab-count>{events.length}</span>
|
|
</button>
|
|
<button data-uix-tab data-active={tab === 'recipe'} onclick={() => (tab = 'recipe')}>Recipe</button>
|
|
<button data-uix-tab data-active={tab === 'a11y'} onclick={() => (tab = 'a11y')}>A11y</button>
|
|
</div>
|
|
|
|
{#if tab === 'live'}
|
|
<section data-uix-section>
|
|
<h2 data-uix-section-title>Controls</h2>
|
|
<p data-uix-section-desc>Props grouped by the architectural layer that owns them: <span data-uix-layer-badge="soma">soma</span> headless behavior, <span data-uix-layer-badge="eidos">eidos</span> visual treatment. Demo-only inputs (literal text content) sit at the bottom. Sema events live in the dedicated <a href="#sema" onclick={(e) => { e.preventDefault(); tab = 'sema'; }}>Sema</a> tab — they are not Provider props.</p>
|
|
|
|
<!-- ── Soma props ──────────────────────────────────────────────── -->
|
|
<div data-uix-subsection-head>
|
|
<span data-uix-layer-badge="soma">soma</span> props · headless behavior
|
|
</div>
|
|
<div data-uix-controls>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>open <span data-uix-control-hint>bindable</span></span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={open} />
|
|
<span data-uix-switch-label>{open ? 'open' : 'closed'}</span>
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>variant</span>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each ['overlay', 'inline', 'persistent'] as v}
|
|
<button data-uix-chip data-active={variant === v} onclick={() => (variant = v as DrawerVariant)}>{v}</button>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>direction</span>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each ['top', 'right', 'bottom', 'left'] as d}
|
|
<button data-uix-chip data-active={direction === d} onclick={() => (direction = d as DrawerDirection)}>{d}</button>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>disabled</span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={disabled} />
|
|
<span data-uix-switch-label>{disabled ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>dismissible</span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={dismissible} />
|
|
<span data-uix-switch-label>{dismissible ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>handleOnly</span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={handleOnly} />
|
|
<span data-uix-switch-label>{handleOnly ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>dragToDismiss</span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={dragToDismiss} />
|
|
<span data-uix-switch-label>{dragToDismiss ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>closeThreshold <span data-uix-control-hint>{closeThreshold}</span></span>
|
|
<input type="range" min="0" max="1" step="0.05" bind:value={closeThreshold} />
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>velocityThreshold <span data-uix-control-hint>{velocityThreshold}</span></span>
|
|
<input type="range" min="0" max="2" step="0.1" bind:value={velocityThreshold} />
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>trapFocus <span data-uix-control-hint>Content prop</span></span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={trapFocus} />
|
|
<span data-uix-switch-label>{trapFocus ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>loop <span data-uix-control-hint>Content prop</span></span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={loop} />
|
|
<span data-uix-switch-label>{loop ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>preventScroll <span data-uix-control-hint>Content prop</span></span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={preventScroll} />
|
|
<span data-uix-switch-label>{preventScroll ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>render Handle part <span data-uix-control-hint>composition</span></span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={showHandle} />
|
|
<span data-uix-switch-label>{showHandle ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
</div>
|
|
|
|
<!-- ── Eidos props ─────────────────────────────────────────────── -->
|
|
<div data-uix-subsection-head>
|
|
<span data-uix-layer-badge="eidos">eidos</span> props · visual treatment
|
|
</div>
|
|
<div data-uix-controls>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>size <span data-uix-control-hint>Content · main axis</span></span>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each ['sm', 'md', 'lg', 'full'] as s}
|
|
<button data-uix-chip data-active={size === s} onclick={() => (size = s as DrawerSize)}>{s}</button>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>overlayOpacity <span data-uix-control-hint>Overlay · {overlayOpacity}</span></span>
|
|
<input type="range" min="0" max="1" step="0.02" bind:value={overlayOpacity} disabled={variant !== 'overlay'} />
|
|
</label>
|
|
</div>
|
|
|
|
<!-- ── Demo content (literal text) ─────────────────────────────── -->
|
|
<div data-uix-subsection-head>Demo content <span style="font-weight: normal; color: var(--uix-text-muted);">· literal text rendered inside the drawer</span></div>
|
|
<div data-uix-controls>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>trigger label</span>
|
|
<input type="text" bind:value={triggerLabel} />
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>title</span>
|
|
<input type="text" bind:value={titleText} />
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>description</span>
|
|
<input type="text" bind:value={descText} />
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>body</span>
|
|
<textarea bind:value={bodyText}></textarea>
|
|
</label>
|
|
</div>
|
|
|
|
<!-- ── Code snippets per layer ─────────────────────────────────── -->
|
|
<div data-uix-code>
|
|
<div data-uix-code-head>
|
|
<span data-uix-layer-badge="soma">soma</span>
|
|
<span>headless · ARIA + behavior only</span>
|
|
<span data-uix-code-lang>svelte</span>
|
|
</div>
|
|
<pre><code>{somaSnippet}</code></pre>
|
|
</div>
|
|
|
|
<div data-uix-code style="margin-top: var(--uix-space-3);">
|
|
<div data-uix-code-head>
|
|
<span data-uix-layer-badge="eidos">eidos</span>
|
|
<span>visual · adds size, overlayOpacity</span>
|
|
<span data-uix-code-lang>svelte</span>
|
|
</div>
|
|
<pre><code>{eidosSnippet}</code></pre>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
|
|
{#if tab === 'api'}
|
|
<section data-uix-section>
|
|
<h2 data-uix-section-title>API reference</h2>
|
|
<p data-uix-section-desc>All public props on every part. Eidos additions are tagged.</p>
|
|
|
|
<div data-uix-subsection-head>Provider</div>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Description</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name">open <span data-uix-tag data-kind="bindable">bindable</span></td><td class="type">boolean</td><td class="default">false</td><td>Whether the drawer is open. Ignored when variant='persistent'.</td></tr>
|
|
<tr><td class="name">variant</td><td class="type">'overlay' | 'inline' | 'persistent'</td><td class="default">'overlay'</td><td>overlay = modal sheet (backdrop + focus trap); inline = no backdrop, background interactive; persistent = always-visible, no Trigger, no close-* events.</td></tr>
|
|
<tr><td class="name">direction</td><td class="type">'top' | 'right' | 'bottom' | 'left' | 'start' | 'end'</td><td class="default">'bottom'</td><td>Edge to attach to. start/end resolve via document dir (RTL-aware).</td></tr>
|
|
<tr><td class="name">disabled</td><td class="type">boolean</td><td class="default">false</td><td>Disables the trigger; drawer stays closed.</td></tr>
|
|
<tr><td class="name">dismissible</td><td class="type">boolean</td><td class="default">true</td><td>Allow Escape / overlay click / drag-to-dismiss.</td></tr>
|
|
<tr><td class="name">handleOnly</td><td class="type">boolean</td><td class="default">false</td><td>Drag gesture only initiates from the Handle.</td></tr>
|
|
<tr><td class="name">dragToDismiss</td><td class="type">boolean</td><td class="default">false</td><td>Opt into translate-to-dismiss on no-snap drawers.</td></tr>
|
|
<tr><td class="name">snapPoints</td><td class="type">(number | string)[]</td><td class="default empty">—</td><td>Resize-on-drag snap stops. Numbers are fractions of axis size; strings are CSS lengths.</td></tr>
|
|
<tr><td class="name">closeThreshold</td><td class="type">number</td><td class="default">0.25</td><td>Drag fraction past which release dismisses.</td></tr>
|
|
<tr><td class="name">velocityThreshold</td><td class="type">number</td><td class="default">0.5</td><td>px/ms — fast flicks dismiss regardless of distance.</td></tr>
|
|
<tr><td class="name">onOpenChange / onOpenChangeComplete</td><td class="type">(open: boolean) => void</td><td class="default empty">—</td><td>Fire on every open/close, and after the animation settles.</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div data-uix-subsection-head>Content</div>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Description</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name">size <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">ResponsiveProp<'sm' | 'md' | 'lg' | 'full'></td><td class="default">'md'</td><td>Width (left/right drawers) or height (top/bottom). Resolved via uix.dom.resolve.</td></tr>
|
|
<tr><td class="name">trapFocus</td><td class="type">boolean</td><td class="default">true</td><td>Tab cycles within Content while open. Ignored unless variant='overlay'.</td></tr>
|
|
<tr><td class="name">loop</td><td class="type">boolean</td><td class="default">false</td><td>Tab loops from last to first focusable.</td></tr>
|
|
<tr><td class="name">preventScroll</td><td class="type">boolean</td><td class="default">true</td><td>Body scroll lock — only effective in variant='overlay'.</td></tr>
|
|
<tr><td class="name">forceMount</td><td class="type">boolean</td><td class="default">false</td><td>Keep in DOM even when closed (CSS transitions).</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div data-uix-subsection-head>Overlay</div>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Description</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name">overlayOpacity <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">number | string</td><td class="default empty">—</td><td>Override the recipe's default. Fraction (0.4 → 40%) or CSS string. Only meaningful in variant='overlay'.</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
|
|
{#if tab === 'morfo'}
|
|
<section data-uix-section>
|
|
<h2 data-uix-section-title>
|
|
<span data-uix-layer-badge="morfo">morfo</span>
|
|
· declarative contract
|
|
</h2>
|
|
<p data-uix-section-desc>
|
|
The morfo is the single source of truth: parts (with markers,
|
|
archetypes, ARIA, keyboard) + events (with semantic family / intent
|
|
/ sequence / prewrite). Soma transcribes it to runtime behavior;
|
|
eidos targets the data-attrs it emits; sema dispatches the event
|
|
signatures. Source: <code>src/uix/morfo/components/drawer.ts</code>.
|
|
</p>
|
|
|
|
<!-- ── Component header ───────────────────────────────────────── -->
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Field</th><th>Value</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name">name</td><td class="type">"{drawerMorfo.name}"</td></tr>
|
|
<tr><td class="name">kebab</td><td class="type">"{drawerMorfo.kebab}"</td></tr>
|
|
<tr><td class="name">scope</td><td class="type">[{drawerMorfo.scope.map((s) => `"${s}"`).join(', ')}]</td></tr>
|
|
<tr><td class="name">apg</td><td><a href={drawerMorfo.apg} target="_blank" rel="noreferrer">{drawerMorfo.apg}</a></td></tr>
|
|
<tr><td class="name">parts.length</td><td class="default">{drawerMorfo.parts.length}</td></tr>
|
|
<tr><td class="name">events.length</td><td class="default">{drawerMorfo.events?.length ?? 0}</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- ── Parts overview ────────────────────────────────────────── -->
|
|
<div data-uix-subsection-head>Parts</div>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Part</th><th>Marker</th><th>Element</th><th>Role</th><th>Archetype</th><th>States</th><th>Optional</th></tr></thead>
|
|
<tbody>
|
|
{#each partsList as part}
|
|
<tr>
|
|
<td class="name">{part.kebab}</td>
|
|
<td><code data-uix-part-marker>[{part.marker}]</code></td>
|
|
<td class="type"><{part.defaultElement}></td>
|
|
<td class="type">{part.role ?? '—'}</td>
|
|
<td class="default">{part.archetype ?? '—'}</td>
|
|
<td class="default">{part.states.length ? part.states.join(' | ') : '—'}</td>
|
|
<td class="default">{part.optional ? 'yes' : 'no'}</td>
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- ── Per-part contracts (data + aria + keyboard) ────────────── -->
|
|
{#each drawerMorfo.parts as rawPart}
|
|
{@const partAny = rawPart as unknown as { kebab: string; aria?: ReadonlyArray<{ attr: string; value: { kind: string }; condition?: { when: string; prop?: string; part?: string }; severity?: string }>; keyboard?: ReadonlyArray<{ key: string; action: string }> }}
|
|
{@const dataAttrs = compiled.contracts.dataAttrsByPart.get(partAny.kebab) ?? []}
|
|
{@const ariaAttrs = partAny.aria ?? []}
|
|
{@const keyboard = partAny.keyboard ?? []}
|
|
{#if dataAttrs.length || ariaAttrs.length || keyboard.length}
|
|
<div data-uix-subsection-head>{partAny.kebab}</div>
|
|
|
|
{#if dataAttrs.length}
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>data-attr</th><th>Values</th><th>Source kind</th></tr></thead>
|
|
<tbody>
|
|
{#each dataAttrs as attr}
|
|
<tr>
|
|
<td class="name">{attr.attr}</td>
|
|
<td class="type">{attr.values ? attr.values.join(' | ') : '—'}</td>
|
|
<td class="default">{'value' in attr && attr.value ? (attr as { value: { kind: string } }).value.kind : '—'}</td>
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{/if}
|
|
|
|
{#if ariaAttrs.length}
|
|
<div data-uix-table-wrap style="margin-top: var(--uix-space-2);">
|
|
<table data-uix-table>
|
|
<thead><tr><th>aria-attr</th><th>Source kind</th><th>Condition</th><th>Severity</th></tr></thead>
|
|
<tbody>
|
|
{#each ariaAttrs as a}
|
|
<tr>
|
|
<td class="name">{a.attr}</td>
|
|
<td class="type">{a.value.kind}</td>
|
|
<td class="default">{a.condition ? `when ${a.condition.when}${a.condition.prop ? ` (${a.condition.prop})` : ''}${a.condition.part ? ` (${a.condition.part})` : ''}` : 'always'}</td>
|
|
<td class="default">{a.severity ?? 'required'}</td>
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{/if}
|
|
|
|
{#if keyboard.length}
|
|
<div data-uix-table-wrap style="margin-top: var(--uix-space-2);">
|
|
<table data-uix-table>
|
|
<thead><tr><th>key</th><th>action</th></tr></thead>
|
|
<tbody>
|
|
{#each keyboard as kb}
|
|
<tr>
|
|
<td><span data-uix-kbd>{kb.key === ' ' ? 'Space' : kb.key}</span></td>
|
|
<td class="default">{kb.action}</td>
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
{/if}
|
|
{/if}
|
|
{/each}
|
|
|
|
<!-- ── Events declaration ────────────────────────────────────── -->
|
|
<div data-uix-subsection-head>Events declaration</div>
|
|
<p data-uix-section-desc style="margin-top: 0.25rem;">
|
|
Each event declares its semantic family + intent (when applicable),
|
|
sequence (pre / post), target part, optional prewrite (transient
|
|
marker stamped before the perceptual signal), and commit
|
|
(descriptive — the runtime smoke verifies the observed state
|
|
matches). Interactive playback is in the <a href="#sema" onclick={(e) => { e.preventDefault(); tab = 'sema'; }}>Sema</a> tab.
|
|
</p>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>name</th><th>family</th><th>verb</th><th>sequence</th><th>intent</th><th>target</th><th>prewrite</th><th>commit</th></tr></thead>
|
|
<tbody>
|
|
{#each events as action}
|
|
{@const sem = action.semantic}
|
|
{@const intentDecl = 'intent' in sem ? sem.intent : undefined}
|
|
{@const intentStr = typeof intentDecl === 'string' ? intentDecl : intentDecl ? `fromProp:${(intentDecl as { fromProp?: string }).fromProp ?? '?'}` : '—'}
|
|
<tr>
|
|
<td class="name">{action.name}</td>
|
|
<td class="type">{sem.family}</td>
|
|
<td>{sem.verb ?? '—'}</td>
|
|
<td>{sem.sequence ?? 'pre'}</td>
|
|
<td class="default">{intentStr}</td>
|
|
<td>{action.target}</td>
|
|
<td class="default">{action.prewrite.length ? action.prewrite.map((p) => `${p.attr}=${p.value}`).join(', ') : '—'}</td>
|
|
<td class="default">{action.commit ? `${action.commit.attr}=${action.commit.value}` : '—'}</td>
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
|
|
{#if tab === 'sema'}
|
|
<section data-uix-section id="sema">
|
|
<h2 data-uix-section-title>
|
|
<span data-uix-layer-badge="sema">sema</span>
|
|
· events + perceptual signature
|
|
</h2>
|
|
<p data-uix-section-desc>Six events, all on the Content part. close-* fire prewrite of <code>data-last-action</code> so eidos can tint the closing animation by causa. Each event declares its <code>family</code> (`emerge` for open/close) and intent — the sema engine maps those to per-channel signatures (sound pitch / motion / color / haptic) per the SEMA_MAP table. Click <strong>play</strong> to fire the signal on the live drawer.</p>
|
|
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Name</th><th>Family</th><th>Verb</th><th>Sequence</th><th>Intent</th><th>Play</th></tr></thead>
|
|
<tbody>
|
|
{#each events as action}
|
|
{@const intentDecl = 'intent' in action.semantic ? action.semantic.intent : undefined}
|
|
{@const effectiveIntent = typeof intentDecl === 'string' ? intentDecl : undefined}
|
|
<tr>
|
|
<td class="name">{action.name}</td>
|
|
<td class="type">{action.semantic.family}</td>
|
|
<td>{action.semantic.verb ?? '—'}</td>
|
|
<td>{action.semantic.sequence ?? 'pre'}</td>
|
|
<td class="default">{effectiveIntent ?? (intentDecl ? 'fromProp' : '—')}</td>
|
|
<td>
|
|
<button
|
|
data-uix-play
|
|
onclick={() => {
|
|
const target = (stageRef?.querySelector('[data-drawer-content]') ?? stageRef?.querySelector('[data-drawer-trigger]') ?? stageRef) as HTMLElement | null;
|
|
if (!target) return;
|
|
void uix.events?.emit({
|
|
name: action.name,
|
|
family: action.semantic.family,
|
|
target,
|
|
...(effectiveIntent ? { intent: effectiveIntent } : {})
|
|
});
|
|
}}
|
|
>▶ play</button>
|
|
</td>
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
|
|
{#if tab === 'recipe'}
|
|
<section data-uix-section>
|
|
<h2 data-uix-section-title>Eidos recipe</h2>
|
|
<p data-uix-section-desc>
|
|
Selectors at <code>src/uix/eidos/components/drawer/drawer.css</code>. Tokens bare-prefixed (<code>--drawer-*</code>). Variant drives positioning (overlay/inline = position:fixed; persistent = position:relative in flow).
|
|
</p>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Selector</th><th>Source</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name">[data-drawer-trigger]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-drawer-overlay][data-state]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-drawer-content][data-variant][data-side]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-drawer-content][data-size]</td><td><span data-uix-tag data-kind="eidos">eidos</span></td></tr>
|
|
<tr><td class="name">[data-drawer-content][data-state='closed'][data-last-action]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-drawer-handle]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-drawer-title] / [data-drawer-description] / [data-drawer-close]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
|
|
{#if tab === 'a11y'}
|
|
<section data-uix-section>
|
|
<h2 data-uix-section-title>Accessibility</h2>
|
|
<p data-uix-section-desc>
|
|
Follows the APG <a href={drawerMorfo.apg} target="_blank" rel="noreferrer">dialog-modal pattern</a>. Focus is trapped in overlay mode; persistent variant participates in normal tab flow.
|
|
</p>
|
|
|
|
<div data-uix-subsection-head>Keyboard</div>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Key</th><th>Action</th></tr></thead>
|
|
<tbody>
|
|
<tr><td><span data-uix-kbd>Escape</span></td><td>Close (when dismissible).</td></tr>
|
|
<tr><td><span data-uix-kbd>Tab</span></td><td>Focus next element. Cycles inside Content when trapFocus is on.</td></tr>
|
|
<tr><td><span data-uix-kbd>Shift+Tab</span></td><td>Focus previous.</td></tr>
|
|
<tr><td><span data-uix-kbd>Enter</span> / <span data-uix-kbd>Space</span></td><td>Activate Trigger to open the drawer.</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div data-uix-subsection-head>ARIA contract</div>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Part</th><th>Attribute</th><th>Value</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name">trigger</td><td>aria-expanded</td><td class="type">{`{open}`}</td></tr>
|
|
<tr><td class="name">trigger</td><td>aria-controls</td><td class="type">{`<content id>`}</td></tr>
|
|
<tr><td class="name">content</td><td>role</td><td class="type">"dialog"</td></tr>
|
|
<tr><td class="name">content</td><td>aria-modal</td><td class="type">"true" (overlay only)</td></tr>
|
|
<tr><td class="name">content</td><td>aria-labelledby</td><td class="type">{`<title id>`}</td></tr>
|
|
<tr><td class="name">content</td><td>aria-describedby</td><td class="type">{`<description id>`}</td></tr>
|
|
<tr><td class="name">overlay</td><td>aria-hidden</td><td class="type">"true"</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
<style>
|
|
/* Inner scroll wrapper. Lets the body clip / scroll independently when
|
|
* the user resizes a top/bottom drawer down. */
|
|
.drawer-scroll {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: var(--space-3);
|
|
flex: 1 1 auto;
|
|
min-height: 0;
|
|
min-width: 0;
|
|
overflow: auto;
|
|
}
|
|
</style>
|