Files
WRNexusJSDoc/app/pages/components/chat-bubble.wrn
T

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>&lt;ChatBubble
size=&quot;default&quot;
color=&quot;primary&quot;
title=&quot;title&quot;
description=&quot;description&quot;
items=&quot;[]&quot;
/&gt;</code></pre><p>Legacy mount name: <code>data-component=&quot;ChatBubble&quot;</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>&quot;default&quot;</code></td></tr><tr><td><code>color</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;primary&quot;</code></td></tr><tr><td><code>title</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</code></td></tr><tr><td><code>description</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</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>&quot;Conversation&quot;</code></td></tr><tr><td><code>variant</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;default&quot;</code></td></tr><tr><td><code>class</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</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 &#123;
props &#123;
@event action = function
@event messageClick = function
@event avatarClick = function
@event linkClick = function
size = &quot;default&quot;
color = &quot;primary&quot;
title = &quot;&quot;
description = &quot;&quot;
items = []
oneSided = false
showAvatars = false
showMetadata = false
ariaLabel = &quot;Conversation&quot;
variant = &quot;default&quot;
class = &quot;&quot;
&#125;
functions &#123;
function messageDirection(item) &#123;
return item.direction === &quot;outgoing&quot; ? &quot;outgoing&quot; : &quot;incoming&quot;
&#125;
function selectMessage(item, index) &#123;
$emit(&quot;messageClick&quot;, &#123;
item: item,
index: index,
direction: messageDirection(item)
&#125;)
&#125;
function selectAvatar(sourceEvent, item, index) &#123;
sourceEvent.stopPropagation()
$emit(&quot;avatarClick&quot;, &#123;
item: item,
index: index,
direction: messageDirection(item)
&#125;)
&#125;
function selectLink(sourceEvent, link, item, index) &#123;
sourceEvent.stopPropagation()
$emit(&quot;linkClick&quot;, &#123;
link: link,
item: item,
index: index
&#125;)
&#125;
function selectAction(sourceEvent, item, index) &#123;
sourceEvent.stopPropagation()
$emit(&quot;action&quot;, &#123;
action: item.action || &quot;retry&quot;,
item: item,
index: index
&#125;)
&#125;
&#125;
view &#123;
&lt;section
&#123;...attrs&#125;
class=&quot;wire-next wire-next--color-&#123;color&#125; wire-next--size-&#123;size&#125; wire-next--chat-bubble wire-next--variant-&#123;variant&#125; &#123;class&#125;&quot;
data-one-sided=&quot;&#123;oneSided&#125;&quot;
role=&quot;log&quot;
aria-label=&quot;&#123;ariaLabel&#125;&quot;
aria-live=&quot;polite&quot;
&gt;
&#123;#if title || description&#125;
&lt;header class=&quot;wire-next__chat-header&quot;&gt;
&#123;#if title&#125;&lt;h3&gt;&#123;title&#125;&lt;/h3&gt;&#123;/if&#125;
&#123;#if description&#125;&lt;p&gt;&#123;description&#125;&lt;/p&gt;&#123;/if&#125;
&lt;/header&gt;
&#123;/if&#125;
&#123;#if items.length&#125;
&lt;div class=&quot;wire-next__chat-thread&quot;&gt;
&#123;#each items as item, index&#125;
&lt;article
class=&quot;wire-next__chat-message&quot;
data-direction=&quot;&#123;messageDirection(item)&#125;&quot;
aria-label=&quot;&#123;messageDirection(item) === 'outgoing' ? 'Sent message' : 'Received message'&#125;&quot;
&gt;
&lt;div class=&quot;wire-next__chat-row&quot;&gt;
&#123;#if showAvatars &amp;&amp; (item.avatarSrc || item.avatarFallback)&#125;
&lt;button
class=&quot;wire-next__chat-avatar&quot;
type=&quot;button&quot;
aria-label=&quot;&#123;item.avatarLabel || item.author || 'Message author'&#125;&quot;
@click=&quot;selectAvatar(event, item, index)&quot;
&gt;
&#123;#if item.avatarSrc&#125;
&lt;img src=&quot;&#123;item.avatarSrc&#125;&quot; alt=&quot;&#123;item.avatarAlt || ''&#125;&quot; /&gt;
&#123;:else&#125;
&lt;span&gt;&#123;item.avatarFallback&#125;&lt;/span&gt;
&#123;/if&#125;
&lt;/button&gt;
&#123;/if&#125;
&lt;div
class=&quot;wire-next__chat-content&quot;
role=&quot;button&quot;
tabindex=&quot;0&quot;
@click=&quot;selectMessage(item, index)&quot;
@keydown=&quot;if (event.key === 'Enter' || event.key === ' ') &#123; event.preventDefault(); selectMessage(item, index) &#125;&quot;
&gt;
&#123;#if item.title&#125;&lt;h4&gt;&#123;item.title&#125;&lt;/h4&gt;&#123;/if&#125;
&#123;#if item.text&#125;&lt;p&gt;&#123;item.text&#125;&lt;/p&gt;&#123;/if&#125;
&#123;#if item.bullets &amp;&amp; item.bullets.length&#125;
&lt;ul&gt;
&#123;#each item.bullets as bullet&#125;&lt;li&gt;&#123;bullet&#125;&lt;/li&gt;&#123;/each&#125;
&lt;/ul&gt;
&#123;/if&#125;
&#123;#if item.links &amp;&amp; item.links.length&#125;
&lt;nav aria-label=&quot;Message links&quot;&gt;
&#123;#each item.links as link&#125;
&lt;a
href=&quot;&#123;link.href || '#'&#125;&quot;
@click=&quot;selectLink(event, link, item, index)&quot;
&gt;&#123;link.label&#125;&lt;/a&gt;
&#123;/each&#125;
&lt;/nav&gt;
&#123;/if&#125;
&lt;/div&gt;
&lt;/div&gt;
&#123;#if showMetadata &amp;&amp; (item.timestamp || item.status || item.actionLabel)&#125;
&lt;footer class=&quot;wire-next__chat-meta&quot; data-tone=&quot;&#123;item.statusTone || 'muted'&#125;&quot;&gt;
&#123;#if item.statusIcon&#125;&lt;span class=&quot;&#123;item.statusIcon&#125;&quot; aria-hidden=&quot;true&quot;&gt;
&lt;/span&gt;&#123;/if&#125;
&#123;#if item.status&#125;&lt;span&gt;&#123;item.status&#125;&lt;/span&gt;&#123;/if&#125;
&#123;#if item.timestamp&#125;&lt;time datetime=&quot;&#123;item.datetime || ''&#125;&quot;&gt;&#123;item.timestamp&#125;&lt;/time&gt;&#123;/if&#125;
&#123;#if item.actionLabel&#125;
&lt;button type=&quot;button&quot; @click=&quot;selectAction(event, item, index)&quot;&gt;
&#123;item.actionLabel&#125;
&lt;/button&gt;
&#123;/if&#125;
&lt;/footer&gt;
&#123;/if&#125;
&lt;/article&gt;
&#123;/each&#125;
&lt;/div&gt;
&#123;/if&#125;
&lt;slot /&gt;
&lt;/section&gt;
&#125;
&#125;
</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>
}
}