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.
582 lines
24 KiB
582 lines
24 KiB
<script lang="ts">
|
|
import Switch, { type SwitchSize } from '$uix/eidos/components/switch';
|
|
import { compileMorfo } from '$uix/morfo';
|
|
import { switchMorfo } from '@/uix/morfo/components/switch';
|
|
import { getActiveUix } from '$active-uix';
|
|
import { page } from '$app/state';
|
|
|
|
const uix = getActiveUix();
|
|
const params = page.url.searchParams;
|
|
|
|
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
|
|
let tab = $state<Tab>('live');
|
|
|
|
type SwitchIntent = 'neutral' | 'affirm' | 'risk' | 'threat';
|
|
type SwitchColor = 'primary' | 'secondary' | undefined;
|
|
|
|
// ── Live state ────────────────────────────────────────────────────────
|
|
let checked = $state(false);
|
|
let size = $state<SwitchSize>('md');
|
|
let intent = $state<SwitchIntent>('neutral');
|
|
let color = $state<SwitchColor>(undefined);
|
|
let disabled = $state(params.get('perm.disabled') === 'true');
|
|
let readonly = $state(false);
|
|
let invalid = $state(params.get('perm.invalid') === 'true');
|
|
let required = $state(false);
|
|
let label = $state('Notifications');
|
|
|
|
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(switchMorfo);
|
|
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')}`;
|
|
}
|
|
|
|
// ── Code snippets ─────────────────────────────────────────────────────
|
|
const somaSnippet = $derived(
|
|
[
|
|
"<script lang='ts'>",
|
|
" import * as Switch from '$soma/components/switch';",
|
|
' let checked = $state(false);',
|
|
'</' + 'script>',
|
|
'',
|
|
'<Switch.Provider',
|
|
' bind:checked',
|
|
intent !== 'neutral' && ` intent="${intent}"`,
|
|
color && ` color="${color}"`,
|
|
disabled && ' disabled',
|
|
readonly && ' readonly',
|
|
required && ' required',
|
|
invalid && ' invalid',
|
|
label && ` aria-label="${label}"`,
|
|
'>',
|
|
' <Switch.Thumb />',
|
|
'</Switch.Provider>'
|
|
]
|
|
.filter(Boolean)
|
|
.join('\n')
|
|
);
|
|
|
|
const eidosSnippet = $derived(
|
|
[
|
|
"<script lang='ts'>",
|
|
" import Switch from '$uix/eidos/components/switch';",
|
|
' let checked = $state(false);',
|
|
'</' + 'script>',
|
|
'',
|
|
'<Switch',
|
|
' bind:checked',
|
|
size !== 'md' && ` size="${size}"`,
|
|
intent !== 'neutral' && ` intent="${intent}"`,
|
|
color && ` color="${color}"`,
|
|
disabled && ' disabled',
|
|
readonly && ' readonly',
|
|
required && ' required',
|
|
invalid && ' invalid',
|
|
label && ` aria-label="${label}"`,
|
|
'/>'
|
|
]
|
|
.filter(Boolean)
|
|
.join('\n')
|
|
);
|
|
</script>
|
|
|
|
<svelte:head>
|
|
<meta name="perm-axes" content="disabled,invalid" />
|
|
</svelte:head>
|
|
|
|
<div data-uix-canvas-inner>
|
|
<header>
|
|
<div data-uix-eyebrow>Forms · Switch</div>
|
|
<h1 data-uix-page-title>Switch</h1>
|
|
<p data-uix-page-lede>
|
|
Binary input with track + thumb (sliding paradigm). Two morfo parts —
|
|
<code>Provider</code> (the interactive button, <code>role="switch"</code>)
|
|
and <code>Thumb</code>. One event — <code>commit-toggle</code> with
|
|
<code>sequence: 'post'</code> — the perceptual consolidation lands on the
|
|
settled state, not on the gesture.
|
|
</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>3
|
|
</span>
|
|
<span data-uix-meta-pill>
|
|
<span data-uix-meta-key>intents</span>4
|
|
</span>
|
|
<span data-uix-meta-pill>
|
|
<span data-uix-meta-key>apg</span>
|
|
<a href={switchMorfo.apg} target="_blank" rel="noreferrer">switch ↗</a>
|
|
</span>
|
|
</div>
|
|
</header>
|
|
|
|
<!-- Live preview always rendered -->
|
|
<div data-uix-stage>
|
|
<div data-uix-stage-area bind:this={stageRef}>
|
|
<label style="display: inline-flex; align-items: center; gap: var(--uix-space-3); font-size: var(--uix-font-size-2);">
|
|
<Switch
|
|
bind:checked
|
|
{size}
|
|
{intent}
|
|
{color}
|
|
{disabled}
|
|
{readonly}
|
|
{required}
|
|
{invalid}
|
|
aria-label={label}
|
|
data-perm-step={disabled ? undefined : '0'}
|
|
data-perm-label={disabled ? undefined : 'toggle switch'}
|
|
/>
|
|
<span>{label}</span>
|
|
</label>
|
|
</div>
|
|
<div data-uix-stage-trace>
|
|
<span data-uix-stage-trace-key>trace</span>
|
|
{#if trace.length === 0}
|
|
<span>flip the switch 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>checked</span> {String(checked)}
|
|
</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>11</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 + intent/color resolution, <span data-uix-layer-badge="eidos">eidos</span> visual treatment. The sema event is in the dedicated <a href="#sema" onclick={(e) => { e.preventDefault(); tab = 'sema'; }}>Sema</a> tab.
|
|
</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>checked <span data-uix-control-hint>bindable</span></span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked />
|
|
<span data-uix-switch-label>{checked ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>intent <span data-uix-control-hint>semantic</span></span>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each ['neutral', 'affirm', 'risk', 'threat'] as i}
|
|
<button data-uix-chip data-active={intent === i} onclick={() => (intent = i as SwitchIntent)}>{i}</button>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>color <span data-uix-control-hint>only when intent='neutral'</span></span>
|
|
<span data-uix-chips role="radiogroup">
|
|
<button data-uix-chip data-active={color === undefined} onclick={() => (color = undefined)}>—</button>
|
|
{#each ['primary', 'secondary'] as c}
|
|
<button data-uix-chip data-active={color === c} onclick={() => (color = c as SwitchColor)} disabled={intent !== 'neutral'}>{c}</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>readonly</span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={readonly} />
|
|
<span data-uix-switch-label>{readonly ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>required</span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={required} />
|
|
<span data-uix-switch-label>{required ? 'on' : 'off'}</span>
|
|
</span>
|
|
</label>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>invalid</span>
|
|
<span data-uix-switch>
|
|
<input type="checkbox" bind:checked={invalid} />
|
|
<span data-uix-switch-label>{invalid ? '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>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each ['xs', 'sm', 'md', 'lg', 'xl'] as s}
|
|
<button data-uix-chip data-active={size === s} onclick={() => (size = s as SwitchSize)}>{s}</button>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
</div>
|
|
|
|
<!-- ── Demo content ────────────────────────────────────────────── -->
|
|
<div data-uix-subsection-head>Demo content <span style="font-weight: normal; color: var(--uix-text-muted);">· accessible label</span></div>
|
|
<div data-uix-controls>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>label / aria-label</span>
|
|
<input type="text" bind:value={label} />
|
|
</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 + intent/color resolution</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; renders Thumb automatically</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 the eidos wrapper. Consumers needing raw Thumb composition fall back to <code>$soma/components/switch</code>.</p>
|
|
|
|
<div data-uix-subsection-head>Switch (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">checked <span data-uix-tag data-kind="bindable">bindable</span></td><td class="type">boolean</td><td class="default">false</td><td>Whether the switch is on.</td></tr>
|
|
<tr><td class="name">onCheckedChange</td><td class="type">(checked: boolean) => void</td><td class="default empty">—</td><td>Fires on every flip.</td></tr>
|
|
<tr><td class="name">intent</td><td class="type">'neutral' | 'affirm' | 'risk' | 'threat'</td><td class="default">'neutral'</td><td>Doctrinal intent. Drives the commit-toggle perceptual signature. Wins data-color over color.</td></tr>
|
|
<tr><td class="name">color</td><td class="type">'primary' | 'secondary'</td><td class="default empty">—</td><td>Hierarchical accent. Only applies when intent='neutral'. Doctrine forbids aesthetic-vs-semantic conflicts.</td></tr>
|
|
<tr><td class="name">disabled</td><td class="type">boolean</td><td class="default">false</td><td>OR-merged with Field.</td></tr>
|
|
<tr><td class="name">readonly</td><td class="type">boolean</td><td class="default">false</td><td>Prevents flipping but keeps focusable.</td></tr>
|
|
<tr><td class="name">required</td><td class="type">boolean</td><td class="default">false</td><td>OR-merged with Field.</td></tr>
|
|
<tr><td class="name">invalid</td><td class="type">boolean</td><td class="default">false</td><td>External invalid flag.</td></tr>
|
|
<tr><td class="name">name</td><td class="type">string</td><td class="default empty">—</td><td>Form name; renders a hidden input while checked.</td></tr>
|
|
<tr><td class="name">value</td><td class="type">string</td><td class="default">'on'</td><td>Form value when checked.</td></tr>
|
|
<tr><td class="name">size <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">'sm' | 'md' | 'lg'</td><td class="default">'md'</td><td>Visual size. Maps to track / thumb / font size via the recipe.</td></tr>
|
|
<tr><td class="name">thumb <span data-uix-tag data-kind="eidos">eidos</span></td><td class="type">{`Snippet<[{ checked: boolean }]>`}</td><td class="default empty">—</td><td>Optional content rendered inside the thumb (e.g. sun/moon for theme toggle).</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/switch.ts</code>. The
|
|
event sequence is <code>'post'</code> — the perceptual signal
|
|
lands after the structural flip, celebrating the settled state.
|
|
</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">"{switchMorfo.name}"</td></tr>
|
|
<tr><td class="name">kebab</td><td class="type">"{switchMorfo.kebab}"</td></tr>
|
|
<tr><td class="name">scope</td><td class="type">[{switchMorfo.scope.map((s) => `"${s}"`).join(', ')}]</td></tr>
|
|
<tr><td class="name">apg</td><td><a href={switchMorfo.apg} target="_blank" rel="noreferrer">{switchMorfo.apg}</a></td></tr>
|
|
<tr><td class="name">parts.length</td><td class="default">{switchMorfo.parts.length}</td></tr>
|
|
<tr><td class="name">events.length</td><td class="default">{switchMorfo.events?.length ?? 0}</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}
|
|
<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>
|
|
|
|
{#each switchMorfo.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})` : ''}` : '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}
|
|
|
|
<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}
|
|
{@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>
|
|
One event — <code>commit-toggle</code>. Intent is bound to
|
|
the <code>intent</code> prop, so the perceptual signature
|
|
follows: affirm uplifts, risk warns, threat hits harder.
|
|
Click <strong>play</strong> to fire on the live switch.
|
|
</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 : intent}
|
|
<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-switch]') as HTMLElement | null;
|
|
if (!target) return;
|
|
void uix.events?.emit({
|
|
name: action.name,
|
|
family: action.semantic.family,
|
|
target,
|
|
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/switch/switch.css</code>. Tokens bare-prefixed (<code>--switch-*</code>).
|
|
</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-switch][data-state]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-switch][data-color]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-switch][data-size]</td><td><span data-uix-tag data-kind="eidos">eidos</span></td></tr>
|
|
<tr><td class="name">[data-switch][data-disabled]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-switch][data-invalid]</td><td><span data-uix-tag data-kind="soma">morfo</span></td></tr>
|
|
<tr><td class="name">[data-switch-thumb][data-state]</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={switchMorfo.apg} target="_blank" rel="noreferrer">switch pattern</a>. Renders <code><button role="switch"></code> with <code>aria-checked</code>; Enter / Space toggle.
|
|
</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>Enter</span> / <span data-uix-kbd>Space</span></td><td>Toggle on/off.</td></tr>
|
|
<tr><td><span data-uix-kbd>Tab</span></td><td>Move focus.</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">provider</td><td>role</td><td class="type">"switch"</td></tr>
|
|
<tr><td class="name">provider</td><td>type</td><td class="type">"button"</td></tr>
|
|
<tr><td class="name">provider</td><td>aria-checked</td><td class="type">{`{checked}`}</td></tr>
|
|
<tr><td class="name">provider</td><td>aria-disabled</td><td class="type">"true" (when disabled)</td></tr>
|
|
<tr><td class="name">provider</td><td>aria-readonly</td><td class="type">"true" (when readonly)</td></tr>
|
|
<tr><td class="name">provider</td><td>aria-required</td><td class="type">"true" (when required)</td></tr>
|
|
<tr><td class="name">provider</td><td>aria-invalid</td><td class="type">"true" (when invalid)</td></tr>
|
|
<tr><td class="name">provider</td><td>aria-label</td><td class="type">{`{label}`}</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
|
|
</div>
|