Files
WRNexusJSDoc/app/pages/components/badge.wrn
T

136 lines
10 KiB
Plaintext

page Badgecomponent {
seo {
title = "Badge component"
description = "Theme-aware, responsive badge 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">Badge</span></nav><section class="doc-intro"><span class="eyebrow">base component</span><h1>Badge</h1><p>Theme-aware, responsive badge component.</p><div class="doc-meta"><span>@wrnexus/ui 0.5.0</span><span>22 props</span><span>0 slots</span><span>1 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;Badge
label=&quot;Badge&quot;
size=&quot;md&quot;
color=&quot;primary&quot;
variant=&quot;solid&quot;
shape=&quot;pill&quot;
/&gt;</code></pre><p>Legacy mount name: <code>data-component=&quot;Badge&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>label</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;Badge&quot;</code></td></tr><tr><td><code>size</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;md&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>variant</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;solid&quot;</code></td></tr><tr><td><code>shape</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;pill&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><tr><td><code>icon</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</code></td></tr><tr><td><code>iconPosition</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;start&quot;</code></td></tr><tr><td><code>dot</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>dotOnly</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>dotLabel</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;Status&quot;</code></td></tr><tr><td><code>animated</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>avatarSrc</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</code></td></tr><tr><td><code>avatarAlt</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</code></td></tr><tr><td><code>dismissible</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>dismissLabel</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;Remove badge&quot;</code></td></tr><tr><td><code>truncate</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>maxWidth</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;12rem&quot;</code></td></tr><tr><td><code>anchorLabel</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</code></td></tr><tr><td><code>anchorIcon</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</code></td></tr><tr><td><code>placement</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;inline&quot;</code></td></tr><tr><td><code>anchorLabelText</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;Badge anchor&quot;</code></td></tr></tbody></table></div></section><section id="slots"><h2>Slots</h2><p>This component does not declare a slot.</p></section><section id="events"><h2>Events</h2><ul><li><code>dismiss</code></li></ul></section><section id="source"><h2>Source contract</h2><p>Installed source: <code>components/Badge.wrn</code></p><pre data-language="wrn"><code>component Badge &#123;
props &#123;
label = &quot;Badge&quot;
size = &quot;md&quot;
color = &quot;primary&quot;
variant = &quot;solid&quot;
shape = &quot;pill&quot;
class = &quot;&quot;
icon = &quot;&quot;
iconPosition = &quot;start&quot;
dot = false
dotOnly = false
dotLabel = &quot;Status&quot;
animated = false
avatarSrc = &quot;&quot;
avatarAlt = &quot;&quot;
dismissible = false
dismissLabel = &quot;Remove badge&quot;
truncate = false
maxWidth = &quot;12rem&quot;
anchorLabel = &quot;&quot;
anchorIcon = &quot;&quot;
placement = &quot;inline&quot;
anchorLabelText = &quot;Badge anchor&quot;
@event dismiss = function
&#125;
state visible = true
functions &#123;
function dismissBadge(sourceEvent, root, customEvent) &#123;
visible = false
root = sourceEvent.currentTarget.closest(&quot;[data-wrn-badge]&quot;)
customEvent = document.createEvent(&quot;CustomEvent&quot;)
customEvent.initCustomEvent(&quot;dismiss&quot;, true, false, &#123;
component: &quot;Badge&quot;,
label: label
&#125;)
root.dispatchEvent(customEvent)
&#125;
&#125;
view &#123;
&lt;span
&#123;...attrs&#125;
class=&quot;wire-next wire-next--badge-root &#123;anchorLabel || anchorIcon ? 'wire-next--badge-anchored' : ''&#125; &#123;class&#125;&quot;
data-wrn-badge
data-placement=&quot;&#123;placement&#125;&quot;
data-show=&quot;visible&quot;
aria-hidden=&quot;&#123;visible ? 'false' : 'true'&#125;&quot;
&gt;
&#123;#if anchorLabel || anchorIcon&#125;
&lt;button type=&quot;button&quot; class=&quot;wire-next__badge-anchor&quot; aria-label=&quot;&#123;anchorLabelText&#125;&quot;&gt;
&#123;#if anchorIcon&#125;&lt;span class=&quot;&#123;anchorIcon&#125;&quot; aria-hidden=&quot;true&quot;&gt;
&lt;/span&gt;&#123;/if&#125;
&#123;#if anchorLabel&#125;&lt;span&gt;&#123;anchorLabel&#125;&lt;/span&gt;&#123;/if&#125;
&lt;/button&gt;
&#123;/if&#125;
&lt;span
class=&quot;wire-next__badge&quot;
data-size=&quot;&#123;size&#125;&quot;
data-color=&quot;&#123;color&#125;&quot;
data-variant=&quot;&#123;variant&#125;&quot;
data-shape=&quot;&#123;shape&#125;&quot;
data-animated=&quot;&#123;animated ? 'true' : 'false'&#125;&quot;
style=&quot;--wire-badge-max-width:&#123;maxWidth&#125;&quot;
role=&quot;&#123;dotOnly ? 'status' : ''&#125;&quot;
aria-label=&quot;&#123;dotOnly ? dotLabel : ''&#125;&quot;
&gt;
&#123;#if animated&#125;
&lt;span class=&quot;wire-next__badge-ping&quot; aria-hidden=&quot;true&quot;&gt;
&lt;/span&gt;
&#123;/if&#125;
&#123;#if avatarSrc&#125;
&lt;img class=&quot;wire-next__badge-avatar&quot; src=&quot;&#123;avatarSrc&#125;&quot; alt=&quot;&#123;avatarAlt&#125;&quot; loading=&quot;lazy&quot; /&gt;
&#123;/if&#125;
&#123;#if dot || dotOnly&#125;
&lt;span class=&quot;wire-next__badge-dot&quot; aria-hidden=&quot;true&quot;&gt;
&lt;/span&gt;
&#123;/if&#125;
&#123;#if icon &amp;&amp; iconPosition === &quot;start&quot;&#125;
&lt;span class=&quot;wire-next__badge-icon &#123;icon&#125;&quot; aria-hidden=&quot;true&quot;&gt;
&lt;/span&gt;
&#123;/if&#125;
&#123;#if !dotOnly&#125;
&lt;span class=&quot;wire-next__badge-label &#123;truncate ? 'wire-next__badge-label--truncate' : ''&#125;&quot;&gt;
&#123;label&#125;
&lt;/span&gt;
&#123;/if&#125;
&#123;#if icon &amp;&amp; iconPosition === &quot;end&quot;&#125;
&lt;span class=&quot;wire-next__badge-icon &#123;icon&#125;&quot; aria-hidden=&quot;true&quot;&gt;
&lt;/span&gt;
&#123;/if&#125;
&#123;#if dismissible&#125;
&lt;button type=&quot;button&quot; class=&quot;wire-next__badge-dismiss&quot; aria-label=&quot;&#123;dismissLabel&#125;&quot; @click=&quot;dismissBadge(event)&quot;&gt;
&lt;span class=&quot;icon-[lucide--x]&quot; aria-hidden=&quot;true&quot;&gt;
&lt;/span&gt;
&lt;/button&gt;
&#123;/if&#125;
&lt;/span&gt;
&lt;/span&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>
}
}