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.
403 lines
14 KiB
403 lines
14 KiB
<script lang="ts">
|
|
import { Mark, type MarkColor } from '$uix/eidos/components/mark';
|
|
import { compileMorfo } from '$uix/morfo';
|
|
import { markMorfo } from '@/uix/morfo/components/mark';
|
|
|
|
type Tab = 'live' | 'api' | 'morfo' | 'sema' | 'recipe' | 'a11y';
|
|
type TraceEntry = { event: string; family: string; intent?: string; at: number };
|
|
let tab = $state<Tab>('live');
|
|
let trace = $state<TraceEntry[]>([]);
|
|
let stageRef = $state<HTMLElement | null>(null);
|
|
|
|
let color = $state<MarkColor>('fulfill');
|
|
let content = $state<string>('dolor sit');
|
|
|
|
const colors: MarkColor[] = [
|
|
'primary',
|
|
'secondary',
|
|
'neutral',
|
|
'affirm',
|
|
'fulfill',
|
|
'risk',
|
|
'threat',
|
|
'loss'
|
|
];
|
|
|
|
const compiled = compileMorfo(markMorfo);
|
|
const partsList = $derived([...compiled.parts.byKebab.values()]);
|
|
const events = $derived([...compiled.actions.byName.values()]);
|
|
|
|
$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();
|
|
});
|
|
|
|
const somaSnippet = $derived(
|
|
[
|
|
'<!-- Mark is eidos-native — no soma layer. -->',
|
|
'<!-- Equivalent markup: -->',
|
|
'',
|
|
'<mark',
|
|
' data-mark',
|
|
` data-color="${color}"`,
|
|
'>',
|
|
` ${content}`,
|
|
'</mark>'
|
|
].join('\n')
|
|
);
|
|
|
|
const eidosSnippet = $derived(
|
|
[
|
|
"<script lang='ts'>",
|
|
" import { Mark } from '$uix/eidos/components/mark';",
|
|
'</' + 'script>',
|
|
'',
|
|
'<Mark',
|
|
color !== 'fulfill' && ` color="${color}"`,
|
|
'>',
|
|
' ' + content,
|
|
'</Mark>'
|
|
]
|
|
.filter(Boolean)
|
|
.join('\n')
|
|
);
|
|
</script>
|
|
|
|
<div data-uix-canvas-inner>
|
|
<header>
|
|
<div data-uix-eyebrow>Typography · Mark</div>
|
|
<h1 data-uix-page-title>Mark</h1>
|
|
<p data-uix-page-lede>
|
|
Inline text highlight primitive. Renders <code>{`<mark>`}</code> with a soft background tint
|
|
per intent color. Inherits the ambient typography so it composes seamlessly inside Text /
|
|
Heading / Code. For substring highlighting of search-result hits, see the higher-level
|
|
<code>{`<Highlight>`}</code>
|
|
primitive. Single part. Eidos-native: no soma backing, no semantic events.
|
|
</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>0
|
|
</span>
|
|
<span data-uix-meta-pill>
|
|
<span data-uix-meta-key>colors</span>8
|
|
</span>
|
|
<span data-uix-meta-pill>
|
|
<span data-uix-meta-key>scope</span>eidos
|
|
</span>
|
|
</div>
|
|
</header>
|
|
|
|
<div data-uix-stage>
|
|
<div data-uix-stage-area bind:this={stageRef}>
|
|
<p
|
|
style="max-inline-size: 38rem; padding: var(--space-3); border: 1px dashed var(--color-neutral-border); border-radius: var(--radius-md); font: inherit;"
|
|
>
|
|
Lorem ipsum
|
|
<Mark {color}>{content}</Mark>
|
|
amet, consectetur adipiscing elit.
|
|
</p>
|
|
</div>
|
|
<div data-uix-stage-trace>
|
|
<span data-uix-stage-trace-key>trace</span>
|
|
<span>{trace.length === 0 ? 'no semantic events' : `${trace.length} event(s)`}</span>
|
|
<span style="color: var(--uix-text-faint)">·</span>
|
|
<span data-uix-stage-trace-key>color</span>
|
|
<span>{color}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<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>4</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 · 0e</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>
|
|
Mark is eidos-native — no <span data-uix-layer-badge="soma">soma</span> split. The
|
|
<code>color</code>
|
|
accepts the full intent palette; the highlight inherits ambient typography.
|
|
</p>
|
|
|
|
<div data-uix-subsection-head>
|
|
<span data-uix-layer-badge="eidos">eidos</span> props · highlight
|
|
</div>
|
|
<div data-uix-controls>
|
|
<label data-uix-control>
|
|
<span data-uix-control-label>color</span>
|
|
<span data-uix-chips role="radiogroup">
|
|
{#each colors as opt}
|
|
<button data-uix-chip data-active={color === opt} onclick={() => (color = opt)}
|
|
>{opt}</button
|
|
>
|
|
{/each}
|
|
</span>
|
|
</label>
|
|
<label data-uix-control style="grid-column: span 2;">
|
|
<span data-uix-control-label>content</span>
|
|
<input type="text" bind:value={content} style="inline-size: 100%; font: inherit;" />
|
|
</label>
|
|
</div>
|
|
|
|
<div data-uix-subsection-head>
|
|
<span data-uix-layer-badge="eidos">eidos</span> color gallery
|
|
</div>
|
|
<div
|
|
style="display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: var(--space-2); padding: var(--space-3); border: 1px dashed var(--color-neutral-border); border-radius: var(--radius-md);"
|
|
>
|
|
{#each colors as opt}
|
|
<div style="display: flex; align-items: center; gap: 0.5em;">
|
|
<span
|
|
style="color: var(--color-content-muted); font-size: var(--font-size-xs); min-inline-size: 5em;"
|
|
>
|
|
{opt}
|
|
</span>
|
|
<Mark color={opt}>highlight</Mark>
|
|
</div>
|
|
{/each}
|
|
</div>
|
|
|
|
<div data-uix-subsection-head>
|
|
<span data-uix-layer-badge="eidos">eidos</span> inline composition
|
|
</div>
|
|
<div
|
|
style="padding: var(--space-3); border: 1px dashed var(--color-neutral-border); border-radius: var(--radius-md); display: flex; flex-direction: column; gap: var(--space-2);"
|
|
>
|
|
<p style="margin: 0;">
|
|
Search returned <Mark color="affirm">3 matches</Mark> for the query
|
|
<Mark color="primary">"typography"</Mark>.
|
|
</p>
|
|
<p style="margin: 0;">
|
|
Deadline approaching: <Mark color="threat">2 days remaining</Mark>.
|
|
</p>
|
|
<p style="margin: 0;">
|
|
The file <Mark color="risk">deleted.txt</Mark> cannot be recovered.
|
|
</p>
|
|
</div>
|
|
|
|
<div data-uix-code>
|
|
<div data-uix-code-head>
|
|
<span data-uix-layer-badge="soma">soma</span>
|
|
<span>n/a · mark is eidos-native — equivalent markup shown</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 · intent tint</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>
|
|
Mark inherits the ambient typography and decorates with a soft background tint. The
|
|
intent palette is the canonical ColorRole union, so highlights follow the theme.
|
|
</p>
|
|
|
|
<div data-uix-subsection-head>Props</div>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Prop</th><th>Type</th><th>Default</th><th>Notes</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name">color</td><td class="type">'primary' | 'secondary' | 'neutral' | 'affirm' | 'fulfill' | 'risk' | 'threat' | 'loss'</td><td class="default">'fulfill'</td><td>Intent palette for the highlight tint.</td></tr>
|
|
<tr><td class="name">as</td><td class="type">string</td><td class="default">'mark'</td><td>Override rendered tag.</td></tr>
|
|
<tr><td class="name">tagStyle</td><td class="type">string</td><td class="default">—</td><td>Extra inline CSS.</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div data-uix-subsection-head>Composability examples</div>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Use case</th><th>Snippet</th></tr></thead>
|
|
<tbody>
|
|
<tr>
|
|
<td class="name">Search-result hit</td>
|
|
<td><code>{`<Mark color="fulfill">match</Mark>`}</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name">Attention grab</td>
|
|
<td><code>{`<Mark color="threat">deadline</Mark>`}</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name">Affirmative confirmation</td>
|
|
<td><code>{`<Mark color="affirm">approved</Mark>`}</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name">Destructive marker</td>
|
|
<td><code>{`<Mark color="risk">removed</Mark>`}</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name">Inside a Heading</td>
|
|
<td>
|
|
<code>{`<Heading><Mark color="primary">UIX</Mark> typography</Heading>`}</code>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="name">Multiple highlights in flow</td>
|
|
<td>
|
|
<code>{`<p>...<Mark>first</Mark>...<Mark color="neutral">aside</Mark>...</p>`}</code>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div data-uix-subsection-head>Reference comparison</div>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Library</th><th>Closest equivalent</th><th>Difference</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name">radix-themes</td><td>—</td><td>Radix has no dedicated Mark; consumer uses Text with custom bg.</td></tr>
|
|
<tr><td class="name">chakra-ui</td><td><code><Mark></code> via Highlight</td><td>Chakra wraps via Highlight only.</td></tr>
|
|
<tr><td class="name">mantine</td><td><code><Mark></code></td><td>Mantine has free <code>color</code>; UIX restricts to intent palette.</td></tr>
|
|
<tr><td class="name">MDN <code><mark></code></td><td>HTML primitive</td><td>UIX wraps with intent palette + theme contract.</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
|
|
{#if tab === 'morfo'}
|
|
<section data-uix-section>
|
|
<h2 data-uix-section-title>Morfo contract</h2>
|
|
<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>{markMorfo.name}</td></tr>
|
|
<tr><td class="name">kebab</td><td><code>{markMorfo.kebab}</code></td></tr>
|
|
<tr><td class="name">scope</td><td>{markMorfo.scope.join(', ')}</td></tr>
|
|
<tr><td class="name">parts</td><td>{partsList.length}</td></tr>
|
|
<tr><td class="name">events</td><td>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>kebab</th><th>marker</th><th>element</th><th>archetype</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.archetype}</td>
|
|
<td class="default">{part.optional ? 'yes' : 'no'}</td>
|
|
</tr>
|
|
{/each}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<p data-uix-section-desc style="margin-top: var(--uix-space-4);">
|
|
The Provider stamps <code>data-mark</code> on the rendered tag (default
|
|
<code>{`<mark>`}</code>) plus <code>data-color</code>.
|
|
</p>
|
|
</section>
|
|
{/if}
|
|
|
|
{#if tab === 'sema'}
|
|
<section data-uix-section>
|
|
<h2 data-uix-section-title>
|
|
<span data-uix-layer-badge="sema">sema</span> · events
|
|
</h2>
|
|
<p data-uix-section-desc>
|
|
Mark declares no semantic events. The highlight is a decorator — no commit, no emerge.
|
|
If a consumer animates the appearance of marked text (search-result flash), the
|
|
animation belongs to the containing list or popover surface.
|
|
</p>
|
|
</section>
|
|
{/if}
|
|
|
|
{#if tab === 'recipe'}
|
|
<section data-uix-section>
|
|
<h2 data-uix-section-title>Eidos recipe</h2>
|
|
<p data-uix-section-desc>
|
|
Recipe lives in <code>src/uix/eidos/components/mark/mark.css</code>. The selector
|
|
<code>[data-mark]</code>
|
|
inherits typography; <code>data-color</code> swaps the bg + text palette.
|
|
</p>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Selector</th><th>Owner</th><th>Purpose</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name"><code>[data-mark]</code></td><td><span data-uix-tag data-kind="morfo">morfo</span></td><td>Provider marker. Default fulfill tint.</td></tr>
|
|
<tr><td class="name"><code>{`[data-mark][data-color='X']`}</code></td><td><span data-uix-tag data-kind="eidos">eidos</span></td><td>Intent palette: primary / secondary / neutral / affirm / fulfill / risk / threat / loss.</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
|
|
{#if tab === 'a11y'}
|
|
<section data-uix-section>
|
|
<h2 data-uix-section-title>Accessibility</h2>
|
|
<div data-uix-table-wrap>
|
|
<table data-uix-table>
|
|
<thead><tr><th>Concern</th><th>Contract</th></tr></thead>
|
|
<tbody>
|
|
<tr><td class="name">Role</td><td>Native HTML <code>{`<mark>`}</code> semantics. Some screen readers announce as "highlighted" or "marked" — but the announcement is implementation-defined, so don't rely on it for meaningful semantics.</td></tr>
|
|
<tr><td class="name">For required emphasis</td><td>Use <code>{`<strong>`}</code> or <code>{`<em>`}</code> — both carry semantic emphasis. Mark is decorative.</td></tr>
|
|
<tr><td class="name">Color contrast</td><td>Each intent's bg + text combination meets WCAG AA via the foundation contract.</td></tr>
|
|
<tr><td class="name">Composition</td><td>Mark inherits typography — composes inside any inline-flow primitive without breaking the parent's line height.</td></tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
</div>
|