176 lines
11 KiB
Plaintext
176 lines
11 KiB
Plaintext
page ChatBubblecomponent {
|
|
seo {
|
|
title = "ChatBubble component"
|
|
description = "Theme-aware, responsive chat bubble component."
|
|
}
|
|
|
|
view {
|
|
<div class="docs-shell">
|
|
<SkipLink label="Skip to content" href="#main" class="docs-skip-link" />
|
|
<header class="topbar">
|
|
<a class="brand" href="/"><span>W</span> WRNexusJS</a>
|
|
<nav aria-label="Primary"><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav>
|
|
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.5.0</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme" title="Toggle color theme">◐</button></div>
|
|
</header>
|
|
<div class="mobile-doc-nav"><details><summary>Browse documentation</summary><nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="/components">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a><a href="/tutorial">Tutorial</a><a href="/guides/project-structure">Guides</a><a href="/examples">Examples</a><a href="/search">Search</a></nav></details></div>
|
|
<main class="portal-main docs-layout component-detail-page"><article id="main" class="documentation prose standalone"><nav class="breadcrumbs" aria-label="Breadcrumb"><a href="/">Home</a><span>/</span><a href="/components">Components</a><span>/</span><span aria-current="page">ChatBubble</span></nav><section class="doc-intro"><span class="eyebrow">base component</span><h1>ChatBubble</h1><p>Theme-aware, responsive chat bubble component.</p><div class="doc-meta"><span>@wrnexus/ui 0.5.0</span><span>11 props</span><span>1 slots</span><span>4 events</span></div></section><section id="usage"><h2>Usage</h2><p>Components are auto-discovered. Use the component directly in any <code>.wrn</code> view:</p><pre data-language="wrn"><code><ChatBubble
|
|
size="default"
|
|
color="primary"
|
|
title="title"
|
|
description="description"
|
|
items="[]"
|
|
/></code></pre><p>Legacy mount name: <code>data-component="ChatBubble"</code>.</p></section><section id="props"><h2>Props and attributes</h2><div class="table-wrap"><table><thead><tr><th>Prop</th><th>Type</th><th>Requirement</th><th>Default</th></tr></thead><tbody><tr><td><code>size</code></td><td><code>string</code></td><td>Optional</td><td><code>"default"</code></td></tr><tr><td><code>color</code></td><td><code>string</code></td><td>Optional</td><td><code>"primary"</code></td></tr><tr><td><code>title</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>description</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>items</code></td><td><code>string</code></td><td>Optional</td><td><code>[]</code></td></tr><tr><td><code>oneSided</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>showAvatars</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>showMetadata</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>ariaLabel</code></td><td><code>string</code></td><td>Optional</td><td><code>"Conversation"</code></td></tr><tr><td><code>variant</code></td><td><code>string</code></td><td>Optional</td><td><code>"default"</code></td></tr><tr><td><code>class</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr></tbody></table></div></section><section id="slots"><h2>Slots</h2><ul><li><code>default</code></li></ul></section><section id="events"><h2>Events</h2><ul><li><code>action</code></li><li><code>messageClick</code></li><li><code>avatarClick</code></li><li><code>linkClick</code></li></ul></section><section id="source"><h2>Source contract</h2><p>Installed source: <code>components/ChatBubble.wrn</code></p><pre data-language="wrn"><code>component ChatBubble {
|
|
props {
|
|
@event action = function
|
|
@event messageClick = function
|
|
@event avatarClick = function
|
|
@event linkClick = function
|
|
size = "default"
|
|
color = "primary"
|
|
title = ""
|
|
description = ""
|
|
items = []
|
|
oneSided = false
|
|
showAvatars = false
|
|
showMetadata = false
|
|
ariaLabel = "Conversation"
|
|
variant = "default"
|
|
class = ""
|
|
}
|
|
|
|
functions {
|
|
function messageDirection(item) {
|
|
return item.direction === "outgoing" ? "outgoing" : "incoming"
|
|
}
|
|
|
|
function selectMessage(item, index) {
|
|
$emit("messageClick", {
|
|
item: item,
|
|
index: index,
|
|
direction: messageDirection(item)
|
|
})
|
|
}
|
|
|
|
function selectAvatar(sourceEvent, item, index) {
|
|
sourceEvent.stopPropagation()
|
|
$emit("avatarClick", {
|
|
item: item,
|
|
index: index,
|
|
direction: messageDirection(item)
|
|
})
|
|
}
|
|
|
|
function selectLink(sourceEvent, link, item, index) {
|
|
sourceEvent.stopPropagation()
|
|
$emit("linkClick", {
|
|
link: link,
|
|
item: item,
|
|
index: index
|
|
})
|
|
}
|
|
|
|
function selectAction(sourceEvent, item, index) {
|
|
sourceEvent.stopPropagation()
|
|
$emit("action", {
|
|
action: item.action || "retry",
|
|
item: item,
|
|
index: index
|
|
})
|
|
}
|
|
}
|
|
|
|
view {
|
|
<section
|
|
{...attrs}
|
|
class="wire-next wire-next--color-{color} wire-next--size-{size} wire-next--chat-bubble wire-next--variant-{variant} {class}"
|
|
data-one-sided="{oneSided}"
|
|
role="log"
|
|
aria-label="{ariaLabel}"
|
|
aria-live="polite"
|
|
>
|
|
{#if title || description}
|
|
<header class="wire-next__chat-header">
|
|
{#if title}<h3>{title}</h3>{/if}
|
|
{#if description}<p>{description}</p>{/if}
|
|
</header>
|
|
{/if}
|
|
|
|
{#if items.length}
|
|
<div class="wire-next__chat-thread">
|
|
{#each items as item, index}
|
|
<article
|
|
class="wire-next__chat-message"
|
|
data-direction="{messageDirection(item)}"
|
|
aria-label="{messageDirection(item) === 'outgoing' ? 'Sent message' : 'Received message'}"
|
|
>
|
|
<div class="wire-next__chat-row">
|
|
{#if showAvatars && (item.avatarSrc || item.avatarFallback)}
|
|
<button
|
|
class="wire-next__chat-avatar"
|
|
type="button"
|
|
aria-label="{item.avatarLabel || item.author || 'Message author'}"
|
|
@click="selectAvatar(event, item, index)"
|
|
>
|
|
{#if item.avatarSrc}
|
|
<img src="{item.avatarSrc}" alt="{item.avatarAlt || ''}" />
|
|
{:else}
|
|
<span>{item.avatarFallback}</span>
|
|
{/if}
|
|
</button>
|
|
{/if}
|
|
|
|
<div
|
|
class="wire-next__chat-content"
|
|
role="button"
|
|
tabindex="0"
|
|
@click="selectMessage(item, index)"
|
|
@keydown="if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); selectMessage(item, index) }"
|
|
>
|
|
{#if item.title}<h4>{item.title}</h4>{/if}
|
|
{#if item.text}<p>{item.text}</p>{/if}
|
|
{#if item.bullets && item.bullets.length}
|
|
<ul>
|
|
{#each item.bullets as bullet}<li>{bullet}</li>{/each}
|
|
</ul>
|
|
{/if}
|
|
{#if item.links && item.links.length}
|
|
<nav aria-label="Message links">
|
|
{#each item.links as link}
|
|
<a
|
|
href="{link.href || '#'}"
|
|
@click="selectLink(event, link, item, index)"
|
|
>{link.label}</a>
|
|
{/each}
|
|
</nav>
|
|
{/if}
|
|
</div>
|
|
</div>
|
|
|
|
{#if showMetadata && (item.timestamp || item.status || item.actionLabel)}
|
|
<footer class="wire-next__chat-meta" data-tone="{item.statusTone || 'muted'}">
|
|
{#if item.statusIcon}<span class="{item.statusIcon}" aria-hidden="true">
|
|
</span>{/if}
|
|
{#if item.status}<span>{item.status}</span>{/if}
|
|
{#if item.timestamp}<time datetime="{item.datetime || ''}">{item.timestamp}</time>{/if}
|
|
{#if item.actionLabel}
|
|
<button type="button" @click="selectAction(event, item, index)">
|
|
{item.actionLabel}
|
|
</button>
|
|
{/if}
|
|
</footer>
|
|
{/if}
|
|
</article>
|
|
{/each}
|
|
</div>
|
|
{/if}
|
|
<slot />
|
|
</section>
|
|
}
|
|
}
|
|
</code></pre></section></article><aside class="on-this-page"><h2>On this page</h2><nav><a href="#usage">Usage</a><a href="#props">Props and attributes</a><a href="#slots">Slots</a><a href="#events">Events</a><a href="#source">Source contract</a></nav></aside></main>
|
|
<footer><div class="footer-brand"><span class="footer-mark" aria-hidden="true">W</span><p><strong>WRNexusJS 0.5.0</strong><span>Complete API documentation generated from installed package declarations.</span></p></div><nav aria-label="Footer"><a href="/packages">All packages</a><a href="/getting-started">Get started</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p class="footer-meta">Private Developer Preview · Bun-native</p></footer>
|
|
<BackToTop />
|
|
</div>
|
|
}
|
|
}
|