176 lines
11 KiB
Plaintext
176 lines
11 KiB
Plaintext
page Alertcomponent {
|
|
seo {
|
|
title = "Alert component"
|
|
description = "Theme-aware, responsive alert 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">Alert</span></nav><section class="doc-intro"><span class="eyebrow">base component</span><h1>Alert</h1><p>Theme-aware, responsive alert component.</p><div class="doc-meta"><span>@wrnexus/ui 0.5.0</span><span>21 props</span><span>0 slots</span><span>2 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><Alert
|
|
size="default"
|
|
color="info"
|
|
variant="soft"
|
|
radius="md"
|
|
shadow="sm"
|
|
/></code></pre><p>Legacy mount name: <code>data-component="Alert"</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>"info"</code></td></tr><tr><td><code>variant</code></td><td><code>string</code></td><td>Optional</td><td><code>"soft"</code></td></tr><tr><td><code>class</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>radius</code></td><td><code>string</code></td><td>Optional</td><td><code>"md"</code></td></tr><tr><td><code>shadow</code></td><td><code>string</code></td><td>Optional</td><td><code>"sm"</code></td></tr><tr><td><code>title</code></td><td><code>string</code></td><td>Optional</td><td><code>"Alert"</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>actions</code></td><td><code>string</code></td><td>Optional</td><td><code>[]</code></td></tr><tr><td><code>showIcon</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>icon</code></td><td><code>string</code></td><td>Optional</td><td><code>""</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>"Dismiss alert"</code></td></tr><tr><td><code>role</code></td><td><code>string</code></td><td>Optional</td><td><code>"alert"</code></td></tr><tr><td><code>live</code></td><td><code>string</code></td><td>Optional</td><td><code>"polite"</code></td></tr><tr><td><code>linkLabel</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>linkHref</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>actionLabel</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>actionHref</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>compact</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</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><li><code>action</code></li></ul></section><section id="source"><h2>Source contract</h2><p>Installed source: <code>components/alert.wrn</code></p><pre data-language="wrn"><code>component Alert {
|
|
props {
|
|
size = "default"
|
|
color = "info"
|
|
variant = "soft"
|
|
class = ""
|
|
radius = "md"
|
|
shadow = "sm"
|
|
|
|
title = "Alert"
|
|
description = ""
|
|
items = []
|
|
actions = []
|
|
|
|
showIcon = false
|
|
icon = ""
|
|
dismissible = false
|
|
dismissLabel = "Dismiss alert"
|
|
role = "alert"
|
|
live = "polite"
|
|
|
|
linkLabel = ""
|
|
linkHref = ""
|
|
actionLabel = ""
|
|
actionHref = ""
|
|
compact = false
|
|
|
|
@event dismiss = function
|
|
@event action = function
|
|
}
|
|
|
|
state visible = true
|
|
|
|
functions {
|
|
function dispatchAlertEvent(sourceEvent, eventName, action, root, customEvent) {
|
|
root = sourceEvent.currentTarget.closest("[data-wrn-alert]")
|
|
|
|
if (!root) {
|
|
return
|
|
}
|
|
|
|
customEvent = document.createEvent("CustomEvent")
|
|
customEvent.initCustomEvent(eventName, true, false, {
|
|
component: "Alert",
|
|
title: title,
|
|
color: color,
|
|
variant: variant,
|
|
action: action
|
|
})
|
|
root.dispatchEvent(customEvent)
|
|
}
|
|
|
|
function dismissAlert(sourceEvent) {
|
|
visible = false
|
|
dispatchAlertEvent(sourceEvent, "dismiss", null)
|
|
}
|
|
|
|
function selectAction(sourceEvent, action) {
|
|
dispatchAlertEvent(sourceEvent, "action", action)
|
|
}
|
|
}
|
|
|
|
view {
|
|
<section
|
|
{...attrs}
|
|
data-wrn-alert
|
|
data-color="{color}"
|
|
data-variant="{variant}"
|
|
data-radius="{radius}"
|
|
data-shadow="{shadow}"
|
|
data-show="visible"
|
|
aria-hidden="{visible ? 'false' : 'true'}"
|
|
role="{role}"
|
|
aria-live="{live}"
|
|
class="wire-next wire-next--color-{color} wire-next--size-{size} wire-next--alert wire-next--alert-{variant} {compact ? 'wire-next--alert-compact' : ''} {class}"
|
|
>
|
|
{#if showIcon}
|
|
<span class="wire-next__alert-icon" aria-hidden="true">
|
|
{#if icon}
|
|
<span class="{icon}">
|
|
</span>
|
|
{:else if color === "success"}
|
|
<span class="icon-[lucide--circle-check]">
|
|
</span>
|
|
{:else if color === "danger"}
|
|
<span class="icon-[lucide--circle-x]">
|
|
</span>
|
|
{:else if color === "warning"}
|
|
<span class="icon-[lucide--triangle-alert]">
|
|
</span>
|
|
{:else}
|
|
<span class="icon-[lucide--info]">
|
|
</span>
|
|
{/if}
|
|
</span>
|
|
{/if}
|
|
|
|
<div class="wire-next__alert-body">
|
|
{#if title}<strong class="wire-next__alert-title">{title}</strong>{/if}
|
|
{#if description}<p>{description}</p>{/if}
|
|
|
|
{#if items.length > 0}
|
|
<ul>
|
|
{#each items as item}<li>{item.label || item}</li>{/each}
|
|
</ul>
|
|
{/if}
|
|
|
|
{#if actions.length > 0 || actionLabel || linkLabel}
|
|
<div class="wire-next__alert-actions">
|
|
{#each actions as item}
|
|
<a
|
|
href="{item.href || '#'}"
|
|
data-variant="{item.variant || 'link'}"
|
|
@click="selectAction(event, item)"
|
|
>{item.label}</a>
|
|
{/each}
|
|
{#if actionLabel}
|
|
<a
|
|
href="{actionHref || '#'}"
|
|
data-variant="action"
|
|
@click="selectAction(event, { label: actionLabel, href: actionHref })"
|
|
>{actionLabel}</a>
|
|
{/if}
|
|
{#if linkLabel}
|
|
<a
|
|
href="{linkHref || '#'}"
|
|
data-variant="link"
|
|
@click="selectAction(event, { label: linkLabel, href: linkHref })"
|
|
>{linkLabel}</a>
|
|
{/if}
|
|
</div>
|
|
{/if}
|
|
</div>
|
|
|
|
{#if dismissible}
|
|
<button
|
|
type="button"
|
|
class="wire-next__alert-dismiss"
|
|
aria-label="{dismissLabel}"
|
|
@click="dismissAlert(event)"
|
|
>
|
|
<span class="icon-[lucide--x]" aria-hidden="true">
|
|
</span>
|
|
</button>
|
|
{/if}
|
|
</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>
|
|
}
|
|
}
|