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.
svelte-kit-vice/web/routes/uix/components/link-preview/+page.svelte

626 lines
28 KiB

<script lang="ts">
import {
LinkPreview,
type LinkPreviewSize
} from '$uix/eidos/components/link-preview';
import { compileMorfo } from '$uix/morfo';
import { linkPreviewMorfo } from '@/uix/morfo/components/link-preview';
import { getActiveUix } from '$active-uix';
const uix = getActiveUix();
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
let tab = $state<Tab>('live');
type Side = 'top' | 'right' | 'bottom' | 'left';
type Align = 'start' | 'center' | 'end';
// ── Live state ────────────────────────────────────────────────────────
// Provider props
let open = $state(false);
let openDelay = $state(700);
let closeDelay = $state(300);
let disabled = $state(false);
// Content (Soma) props
let side = $state<Side>('top');
let sideOffset = $state(8);
let align = $state<Align>('center');
let alignOffset = $state(0);
let avoidCollisions = $state(true);
// Content (Eidos) props
let size = $state<LinkPreviewSize>('md');
// Composition
let showArrow = $state(true);
// Demo content
let triggerLabel = $state('Hover this link');
let href = $state('https://www.w3.org/WAI/ARIA/apg/');
let previewTitle = $state('WAI-ARIA Authoring Practices');
let previewBody = $state(
'Recommended patterns for accessible widgets including the dialog-modal pattern used here, with keyboard, focus and ARIA contracts spelled out part-by-part.'
);
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(linkPreviewMorfo);
const partsList = $derived([...compiled.parts.byKebab.values()]);
const events = $derived([...compiled.actions.byName.values()]);
function fmtTime(at: number): string {
const d = new Date(at);
return `${String(d.getSeconds()).padStart(2, '0')}.${String(d.getMilliseconds()).padStart(3, '0')}`;
}
const somaSnippet = $derived(
[
"<script lang='ts'>",
" import * as LinkPreview from '$soma/components/link-preview';",
' let open = $state(false);',
'</' + 'script>',
'',
'<LinkPreview.Provider',
' bind:open',
openDelay !== 700 && ` openDelay={${openDelay}}`,
closeDelay !== 300 && ` closeDelay={${closeDelay}}`,
disabled && ' disabled',
'>',
` <LinkPreview.Trigger href="${href}">${triggerLabel}</LinkPreview.Trigger>`,
' <LinkPreview.Portal>',
' <LinkPreview.Content',
side !== 'top' && ` side="${side}"`,
align !== 'center' && ` align="${align}"`,
sideOffset !== 8 && ` sideOffset={${sideOffset}}`,
!avoidCollisions && ' avoidCollisions={false}',
' >',
showArrow && ' <LinkPreview.Arrow />',
' <h3>...</h3>',
' <p>...</p>',
' </LinkPreview.Content>',
' </LinkPreview.Portal>',
'</LinkPreview.Provider>'
]
.filter(Boolean)
.join('\n')
);
const eidosSnippet = $derived(
[
"<script lang='ts'>",
" import { LinkPreview } from '$uix/eidos/components/link-preview';",
' let open = $state(false);',
'</' + 'script>',
'',
'<LinkPreview',
' bind:open',
openDelay !== 700 && ` openDelay={${openDelay}}`,
closeDelay !== 300 && ` closeDelay={${closeDelay}}`,
disabled && ' disabled',
'>',
` <LinkPreview.Trigger href="${href}">${triggerLabel}</LinkPreview.Trigger>`,
' <LinkPreview.Portal>',
' <LinkPreview.Content',
size !== 'md' && ` size="${size}"`,
side !== 'top' && ` side="${side}"`,
align !== 'center' && ` align="${align}"`,
' >',
showArrow && ' <LinkPreview.Arrow />',
' <h3>...</h3>',
' <p>...</p>',
' </LinkPreview.Content>',
' </LinkPreview.Portal>',
'</LinkPreview>'
]
.filter(Boolean)
.join('\n')
);
</script>
<div data-uix-canvas-inner>
<header>
<div data-uix-eyebrow>Overlays · LinkPreview</div>
<h1 data-uix-page-title>LinkPreview</h1>
<p data-uix-page-lede>
Anchored content preview on hover or keyboard focus — Radix
HoverCard equivalent. Trigger is an <code>&lt;a&gt;</code>;
the floating panel reveals after <code>openDelay</code> (default
700ms) with a SafePolygon bridging trigger and content so the
pointer can travel without dismissing. Non-modal, no-op on touch
(navigates the link directly).
</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>sizes</span>5
</span>
<span data-uix-meta-pill>
<span data-uix-meta-key>apg</span>
<a href="https://www.w3.org/WAI/ARIA/apg/patterns/tooltip/" target="_blank" rel="noreferrer">tooltip ↗</a>
</span>
</div>
</header>
<!-- Live preview always rendered -->
<div data-uix-stage>
<div data-uix-stage-area bind:this={stageRef} style="min-block-size: 14rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--uix-space-3);">
<p style="margin: 0; color: var(--uix-text-muted); font-size: var(--uix-font-size-sm);">
Read about
<LinkPreview bind:open {openDelay} {closeDelay} {disabled}>
<LinkPreview.Trigger href={href} target="_blank" rel="noreferrer">
{triggerLabel}
</LinkPreview.Trigger>
<LinkPreview.Portal>
<LinkPreview.Content {size} {side} {sideOffset} {align} {alignOffset} {avoidCollisions}>
{#if showArrow}<LinkPreview.Arrow />{/if}
<h3 style="margin: 0; font-size: 1em; font-weight: 600;">{previewTitle}</h3>
<p style="margin: 0; color: var(--color-content-secondary);">{previewBody}</p>
</LinkPreview.Content>
</LinkPreview.Portal>
</LinkPreview>
in the W3C reference.
</p>
</div>
<div data-uix-stage-trace>
<span data-uix-stage-trace-key>trace</span>
{#if trace.length === 0}
<span>hover the link 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>3</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>
Soma owns the hover-bridge polygon, open/close timing and dismissal. Eidos adds <code>size</code> on Content (xs..xl). Trigger is rendered as <code>&lt;a&gt;</code>; on touch the preview is a no-op and the link follows.
</p>
<!-- ── Soma Provider props ─────────────────────────────────────── -->
<div data-uix-subsection-head>
<span data-uix-layer-badge="soma">soma</span> Provider props · open + delays + disabled
</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>openDelay <span data-uix-control-hint>{openDelay}ms</span></span>
<input type="range" min="0" max="2000" step="50" bind:value={openDelay} />
</label>
<label data-uix-control>
<span data-uix-control-label>closeDelay <span data-uix-control-hint>{closeDelay}ms</span></span>
<input type="range" min="0" max="2000" step="50" bind:value={closeDelay} />
</label>
<label data-uix-control>
<span data-uix-control-label>disabled <span data-uix-control-hint>preview never opens</span></span>
<span data-uix-switch>
<input type="checkbox" bind:checked={disabled} />
<span data-uix-switch-label>{disabled ? 'on' : 'off'}</span>
</span>
</label>
</div>
<!-- ── Soma Content props ──────────────────────────────────────── -->
<div data-uix-subsection-head>
<span data-uix-layer-badge="soma">soma</span> Content props · floating placement
</div>
<div data-uix-controls>
<label data-uix-control>
<span data-uix-control-label>side</span>
<span data-uix-chips role="radiogroup">
{#each ['top', 'right', 'bottom', 'left'] as s (s)}
<button data-uix-chip data-active={side === s} onclick={() => (side = s as Side)}>{s}</button>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>align</span>
<span data-uix-chips role="radiogroup">
{#each ['start', 'center', 'end'] as a (a)}
<button data-uix-chip data-active={align === a} onclick={() => (align = a as Align)}>{a}</button>
{/each}
</span>
</label>
<label data-uix-control>
<span data-uix-control-label>sideOffset <span data-uix-control-hint>{sideOffset}px</span></span>
<input type="range" min="0" max="32" step="1" bind:value={sideOffset} />
</label>
<label data-uix-control>
<span data-uix-control-label>alignOffset <span data-uix-control-hint>{alignOffset}px</span></span>
<input type="range" min="-32" max="32" step="1" bind:value={alignOffset} />
</label>
<label data-uix-control>
<span data-uix-control-label>avoidCollisions</span>
<span data-uix-switch>
<input type="checkbox" bind:checked={avoidCollisions} />
<span data-uix-switch-label>{avoidCollisions ? 'on' : 'off'}</span>
</span>
</label>
</div>
<!-- ── Eidos Content props ─────────────────────────────────────── -->
<div data-uix-subsection-head>
<span data-uix-layer-badge="eidos">eidos</span> Content props · visual size
<span style="font-weight: normal; color: var(--uix-text-muted);">
· padding / min-width / font-size
</span>
</div>
<div data-uix-controls>
<label data-uix-control>
<span data-uix-control-label>size</span>
<span data-uix-chips role="radiogroup">
{#each ['xs', 'sm', 'md', 'lg', 'xl'] as s (s)}
<button data-uix-chip data-active={size === s} onclick={() => (size = s as LinkPreviewSize)}>{s}</button>
{/each}
</span>
</label>
</div>
<!-- ── Composition ─────────────────────────────────────────────── -->
<div data-uix-subsection-head>Composition <span style="font-weight: normal; color: var(--uix-text-muted);">· toggle structural parts</span></div>
<div data-uix-controls>
<label data-uix-control>
<span data-uix-control-label>render Arrow part</span>
<span data-uix-switch>
<input type="checkbox" bind:checked={showArrow} />
<span data-uix-switch-label>{showArrow ? 'on' : 'off'}</span>
</span>
</label>
</div>
<!-- ── Demo content ────────────────────────────────────────────── -->
<div data-uix-subsection-head>Demo content <span style="font-weight: normal; color: var(--uix-text-muted);">· literal text</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>href</span>
<input type="text" bind:value={href} />
</label>
<label data-uix-control>
<span data-uix-control-label>preview title</span>
<input type="text" bind:value={previewTitle} />
</label>
<label data-uix-control>
<span data-uix-control-label>preview body</span>
<textarea bind:value={previewBody}></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 · hover-bridge + floating positioning + dismissal</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 on Content</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>
Three parts: Provider (root), Trigger (anchor), Content (panel),
plus optional Arrow inside Content. Portal wraps Content for body-level rendering.
</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 preview is open.</td></tr>
<tr><td class="name">onOpenChange / onOpenChangeComplete</td><td class="type">(open: boolean) =&gt; void</td><td class="default empty">—</td><td>Fire on every transition / after settle.</td></tr>
<tr><td class="name">openDelay</td><td class="type">number</td><td class="default">700</td><td>Hover-open delay (ms). Matches Radix HoverCard default.</td></tr>
<tr><td class="name">closeDelay</td><td class="type">number</td><td class="default">300</td><td>Hover-close delay (ms). Corridor for pointer to traverse to content.</td></tr>
<tr><td class="name">disabled</td><td class="type">boolean</td><td class="default">false</td><td>Hover/focus do not open the preview.</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Trigger</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">id</td><td class="type">string</td><td class="default empty">auto</td><td>—</td></tr>
<tr><td class="name">…native anchor attrs</td><td class="type">PrimitiveAnchorAttributes</td><td class="default empty">—</td><td>Renders an <code>&lt;a&gt;</code>; all HTML anchor attrs (<code>href</code>, <code>target</code>, <code>rel</code>) flow through.</td></tr>
<tr><td class="name">child</td><td class="type">{`Snippet<[{ props }]>`}</td><td class="default empty">—</td><td>Opt out of the default <code>&lt;a&gt;</code> and render your own element (e.g. button-triggered hover-card).</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&lt;'xs' | 'sm' | 'md' | 'lg' | 'xl'&gt;</td><td class="default">'md'</td><td>Visual size — padding, min-width, font-size.</td></tr>
<tr><td class="name">side</td><td class="type">'top' | 'right' | 'bottom' | 'left'</td><td class="default">'top'</td><td>Side of the trigger.</td></tr>
<tr><td class="name">align</td><td class="type">'start' | 'center' | 'end'</td><td class="default">'center'</td><td>Alignment along the side.</td></tr>
<tr><td class="name">sideOffset</td><td class="type">number</td><td class="default">8</td><td>Distance from trigger.</td></tr>
<tr><td class="name">alignOffset</td><td class="type">number</td><td class="default">0</td><td>Offset along the alignment axis.</td></tr>
<tr><td class="name">avoidCollisions</td><td class="type">boolean</td><td class="default">true</td><td>Flip / shift to avoid viewport edges.</td></tr>
<tr><td class="name">collisionBoundary</td><td class="type">Boundary | Boundary[]</td><td class="default">[]</td><td>Custom boundary element(s).</td></tr>
<tr><td class="name">collisionPadding</td><td class="type">number | Record&lt;Side, number&gt;</td><td class="default">0</td><td>Padding from boundaries.</td></tr>
<tr><td class="name">sticky</td><td class="type">'partial' | 'always'</td><td class="default">'partial'</td><td>Sticking behavior on scroll.</td></tr>
<tr><td class="name">hideWhenDetached</td><td class="type">boolean</td><td class="default">true</td><td>Hide when trigger leaves the viewport.</td></tr>
<tr><td class="name">customAnchor</td><td class="type">string | HTMLElement | Measurable | null</td><td class="default empty">—</td><td>Anchor to a different element/rect than the trigger.</td></tr>
<tr><td class="name">forceMount</td><td class="type">boolean</td><td class="default">false</td><td>Keep in DOM when closed (for external animation).</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>
Source: <code>src/uix/morfo/components/link-preview.ts</code>.
Trigger emits the hover/focus events; Content stamps
<code>data-state</code> and <code>data-side</code> via the
Floating layer.
</p>
<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">"{linkPreviewMorfo.name}"</td></tr>
<tr><td class="name">kebab</td><td class="type">"{linkPreviewMorfo.kebab}"</td></tr>
<tr><td class="name">scope</td><td class="type">[{linkPreviewMorfo.scope.map((s) => `"${s}"`).join(', ')}]</td></tr>
<tr><td class="name">parts.length</td><td class="default">{linkPreviewMorfo.parts.length}</td></tr>
<tr><td class="name">events.length</td><td class="default">{events.length}</td></tr>
</tbody>
</table>
</div>
<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 (part.kebab)}
<tr>
<td class="name">{part.kebab}</td>
<td><code data-uix-part-marker>[{part.marker}]</code></td>
<td class="type">&lt;{part.defaultElement}&gt;</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>
<div data-uix-subsection-head>Events declaration</div>
<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 (action.name)}
{@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>
Hover / focus opens the preview; pointer-leave or escape closes
it. Click <strong>play</strong> to fire on the live preview.
</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 (action.name)}
{@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 ?? '—'}</td>
<td>
<button
data-uix-play
onclick={() => {
const target = (stageRef?.querySelector('[data-link-preview-content]') ?? stageRef?.querySelector('[data-link-preview-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/link-preview/link-preview.css</code>.
Trigger paints the <code>&lt;a&gt;</code> directly (underline + hover/open color shift)
— it does NOT render as <code>&lt;Button&gt;</code> like other triggers, because
link previews are navigational anchors rather than action controls.
</p>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Selector</th><th>Source</th><th>What it paints</th></tr></thead>
<tbody>
<tr><td class="name">[data-link-preview-trigger]</td><td><span data-uix-tag data-kind="soma">morfo</span></td><td>Anchor: underline + accent color.</td></tr>
<tr><td class="name">[data-link-preview-trigger][data-state='open']</td><td><span data-uix-tag data-kind="soma">morfo</span></td><td>Stronger color when preview is open.</td></tr>
<tr><td class="name">[data-link-preview-content]</td><td><span data-uix-tag data-kind="soma">morfo</span></td><td>Floating panel: border, bg, shadow, padding.</td></tr>
<tr><td class="name">[data-link-preview-content][data-size]</td><td><span data-uix-tag data-kind="eidos">eidos</span></td><td>Size variant (xs..xl) — padding / min-width / font-size.</td></tr>
<tr><td class="name">[data-link-preview-content][data-state][data-side]</td><td><span data-uix-tag data-kind="soma">morfo</span></td><td>Open/close transition per side (slide+fade).</td></tr>
<tr><td class="name">[data-link-preview-arrow]</td><td><span data-uix-tag data-kind="soma">morfo</span></td><td>Arrow fill matches the panel bg.</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>
LinkPreview is decorative for assistive tech — the content
panel is sighted-user enhancement, not a primary information
channel. Screen readers should rely on the link's accessible
name (and surrounding context) to convey the destination. The
preview opens on keyboard focus too so sighted-keyboard users
get the affordance.
</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>Tab</span></td><td>Focus the trigger — preview opens after a short delay (skips on initial mount).</td></tr>
<tr><td><span data-uix-kbd>Escape</span></td><td>Close the preview, focus stays on trigger.</td></tr>
<tr><td><span data-uix-kbd>Enter</span></td><td>Follow the link's <code>href</code> (native anchor behavior).</td></tr>
</tbody>
</table>
</div>
<div data-uix-subsection-head>Pointer</div>
<div data-uix-table-wrap>
<table data-uix-table>
<thead><tr><th>Gesture</th><th>Behavior</th></tr></thead>
<tbody>
<tr><td>Hover trigger</td><td>After <code>openDelay</code> (700ms default) the preview opens.</td></tr>
<tr><td>Leave trigger toward content</td><td>SafePolygon bridges the gap; preview stays open while pointer is in the triangle.</td></tr>
<tr><td>Leave both</td><td>After <code>closeDelay</code> (300ms default) the preview closes.</td></tr>
<tr><td>Touch</td><td>No preview — the link is followed directly. Avoids modal hover-trap on mobile.</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>data-state</td><td class="type">"open" | "closed"</td></tr>
<tr><td class="name">content</td><td>role</td><td class="type">(none — sighted enhancement)</td></tr>
<tr><td class="name">content</td><td>data-state</td><td class="type">"open" | "closed"</td></tr>
<tr><td class="name">content</td><td>data-side</td><td class="type">"top" | "right" | "bottom" | "left"</td></tr>
</tbody>
</table>
</div>
</section>
{/if}
</div>

Powered by TurnKey Linux.