291 lines
19 KiB
Plaintext
291 lines
19 KiB
Plaintext
page Cardcomponent {
|
|
seo {
|
|
title = "Card component"
|
|
description = "Theme-aware, responsive card 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">Card</span></nav><section class="doc-intro"><span class="eyebrow">base component</span><h1>Card</h1><p>Theme-aware, responsive card component.</p><div class="doc-meta"><span>@wrnexus/ui 0.5.0</span><span>31 props</span><span>1 slots</span><span>6 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><Card
|
|
title="Card title"
|
|
subtitle="subtitle"
|
|
description="description"
|
|
header="header"
|
|
footer="footer"
|
|
/></code></pre><p>Legacy mount name: <code>data-component="Card"</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>title</code></td><td><code>string</code></td><td>Optional</td><td><code>"Card title"</code></td></tr><tr><td><code>subtitle</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>header</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>footer</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>imageSrc</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>imageAlt</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>imagePosition</code></td><td><code>string</code></td><td>Optional</td><td><code>"top"</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>headerActions</code></td><td><code>string</code></td><td>Optional</td><td><code>[]</code></td></tr><tr><td><code>navigation</code></td><td><code>string</code></td><td>Optional</td><td><code>[]</code></td></tr><tr><td><code>activeNav</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>mobileNavigation</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>alertTitle</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>alertDescription</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>empty</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>emptyTitle</code></td><td><code>string</code></td><td>Optional</td><td><code>"No data to show"</code></td></tr><tr><td><code>emptyIcon</code></td><td><code>string</code></td><td>Optional</td><td><code>"icon-[lucide--inbox]"</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>size</code></td><td><code>string</code></td><td>Optional</td><td><code>"md"</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>variant</code></td><td><code>string</code></td><td>Optional</td><td><code>"default"</code></td></tr><tr><td><code>layout</code></td><td><code>string</code></td><td>Optional</td><td><code>"vertical"</code></td></tr><tr><td><code>align</code></td><td><code>string</code></td><td>Optional</td><td><code>"left"</code></td></tr><tr><td><code>hover</code></td><td><code>string</code></td><td>Optional</td><td><code>"none"</code></td></tr><tr><td><code>scrollable</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>maxHeight</code></td><td><code>string</code></td><td>Optional</td><td><code>"18rem"</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>ariaLabel</code></td><td><code>string</code></td><td>Optional</td><td><code>""</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>click</code></li><li><code>action</code></li><li><code>navigate</code></li><li><code>dismiss</code></li><li><code>load</code></li><li><code>error</code></li></ul></section><section id="source"><h2>Source contract</h2><p>Installed source: <code>components/card.wrn</code></p><pre data-language="wrn"><code>component Card {
|
|
props {
|
|
@event click = function
|
|
@event action = function
|
|
@event navigate = function
|
|
@event dismiss = function
|
|
@event load = function
|
|
@event error = function
|
|
title = "Card title"
|
|
subtitle = ""
|
|
description = ""
|
|
header = ""
|
|
footer = ""
|
|
imageSrc = ""
|
|
imageAlt = ""
|
|
imagePosition = "top"
|
|
actionLabel = ""
|
|
actionHref = ""
|
|
headerActions = []
|
|
navigation = []
|
|
activeNav = ""
|
|
mobileNavigation = false
|
|
alertTitle = ""
|
|
alertDescription = ""
|
|
empty = false
|
|
emptyTitle = "No data to show"
|
|
emptyIcon = "icon-[lucide--inbox]"
|
|
items = []
|
|
size = "md"
|
|
color = "primary"
|
|
variant = "default"
|
|
layout = "vertical"
|
|
align = "left"
|
|
hover = "none"
|
|
scrollable = false
|
|
maxHeight = "18rem"
|
|
dismissible = false
|
|
ariaLabel = ""
|
|
class = ""
|
|
}
|
|
|
|
state visible = true
|
|
state selectedNav = activeNav
|
|
|
|
functions {
|
|
function chooseNavigation(item, index) {
|
|
previousValue = selectedNav
|
|
selectedNav = item.value || item.label
|
|
$emit("navigate", {
|
|
value: selectedNav,
|
|
previousValue: previousValue,
|
|
item: item,
|
|
index: index
|
|
})
|
|
}
|
|
|
|
function chooseMobileNavigation(sourceEvent) {
|
|
previousValue = selectedNav
|
|
selectedNav = sourceEvent.target.value
|
|
$emit("navigate", {
|
|
value: selectedNav,
|
|
previousValue: previousValue
|
|
})
|
|
}
|
|
|
|
function chooseAction(action, index) {
|
|
$emit("action", {
|
|
action: action,
|
|
index: index
|
|
})
|
|
}
|
|
|
|
function dismissCard(sourceEvent) {
|
|
panel = sourceEvent.currentTarget.closest(".wire-next__card-panel")
|
|
if (panel) {
|
|
panel.setAttribute("hidden", "")
|
|
}
|
|
visible = false
|
|
$emit("dismiss", {
|
|
title: title
|
|
})
|
|
}
|
|
}
|
|
|
|
view {
|
|
<section
|
|
{...attrs}
|
|
class="wire-next wire-next--card {class}"
|
|
data-size="{size}"
|
|
data-color="{color}"
|
|
data-variant="{variant}"
|
|
data-layout="{layout}"
|
|
data-align="{align}"
|
|
data-hover="{hover}"
|
|
data-image-position="{imagePosition}"
|
|
data-group="{items.length > 0}"
|
|
aria-label="{ariaLabel || title}"
|
|
>
|
|
{#if items.length > 0}
|
|
<div class="wire-next__card-group">
|
|
{#each items as item}
|
|
<article class="wire-next__card-panel">
|
|
{#if item.imageSrc}
|
|
<div class="wire-next__card-media">
|
|
<img src="{item.imageSrc}" alt="{item.imageAlt || ''}" loading="lazy" />
|
|
</div>
|
|
{/if}
|
|
<div class="wire-next__card-body">
|
|
{#if item.title}<h3>{item.title}</h3>{/if}
|
|
{#if item.description}<p>{item.description}</p>{/if}
|
|
</div>
|
|
{#if item.footer}<footer class="wire-next__card-footer">{item.footer}</footer>{/if}
|
|
</article>
|
|
{/each}
|
|
</div>
|
|
{:else if visible}
|
|
<article class="wire-next__card-panel">
|
|
{#if imagePosition === "overlay" && imageSrc}
|
|
<div class="wire-next__card-media wire-next__card-media--overlay">
|
|
<img
|
|
src="{imageSrc}"
|
|
alt="{imageAlt}"
|
|
loading="lazy"
|
|
@load="$emit('load', { src: imageSrc })"
|
|
@error="$emit('error', { src: imageSrc })"
|
|
/>
|
|
<div class="wire-next__card-overlay">
|
|
{#if title}<h3>{title}</h3>{/if}
|
|
{#if subtitle}<span class="wire-next__card-subtitle">{subtitle}</span>{/if}
|
|
{#if description}<p>{description}</p>{/if}
|
|
{#if footer}<small>{footer}</small>{/if}
|
|
</div>
|
|
</div>
|
|
{:else}
|
|
{#if header || headerActions.length > 0 || dismissible}
|
|
<header class="wire-next__card-header">
|
|
<span>{header}</span>
|
|
{#if headerActions.length > 0 || dismissible}
|
|
<span class="wire-next__card-header-actions">
|
|
{#each headerActions as action, index}
|
|
<button
|
|
type="button"
|
|
aria-label="{action.ariaLabel || action.label}"
|
|
title="{action.label}"
|
|
@click="chooseAction(action, index)"
|
|
>
|
|
{#if action.icon}<span class="{action.icon}" aria-hidden="true">
|
|
</span>{/if}
|
|
{#if !action.icon}<span>{action.label}</span>{/if}
|
|
</button>
|
|
{/each}
|
|
{#if dismissible}
|
|
<button type="button" aria-label="Close card" @click="dismissCard(event)">
|
|
<span class="icon-[lucide--x]" aria-hidden="true">
|
|
</span>
|
|
</button>
|
|
{/if}
|
|
</span>
|
|
{/if}
|
|
</header>
|
|
{/if}
|
|
|
|
{#if navigation.length > 0}
|
|
<nav class="wire-next__card-navigation" aria-label="{ariaLabel || title}">
|
|
<div class="wire-next__card-tabs">
|
|
{#each navigation as item, index}
|
|
<button
|
|
type="button"
|
|
data-active="{selectedNav === (item.value || item.label)}"
|
|
aria-current="{selectedNav === (item.value || item.label) ? 'page' : ''}"
|
|
@click="chooseNavigation(item, index)"
|
|
>
|
|
{item.label}
|
|
</button>
|
|
{/each}
|
|
</div>
|
|
{#if mobileNavigation}
|
|
<select
|
|
class="wire-next__card-navigation-select"
|
|
aria-label="{ariaLabel || title}"
|
|
value="{selectedNav}"
|
|
@change="chooseMobileNavigation(event)"
|
|
>
|
|
{#each navigation as item}
|
|
<option
|
|
value="{item.value || item.label}"
|
|
selected="{selectedNav === (item.value || item.label)}"
|
|
>
|
|
{item.label}
|
|
</option>
|
|
{/each}
|
|
</select>
|
|
{/if}
|
|
</nav>
|
|
{/if}
|
|
|
|
{#if imageSrc && imagePosition !== "bottom"}
|
|
<div class="wire-next__card-media">
|
|
<img
|
|
src="{imageSrc}"
|
|
alt="{imageAlt}"
|
|
loading="lazy"
|
|
@load="$emit('load', { src: imageSrc })"
|
|
@error="$emit('error', { src: imageSrc })"
|
|
/>
|
|
</div>
|
|
{/if}
|
|
|
|
{#if alertTitle || alertDescription}
|
|
<aside class="wire-next__card-alert" role="status">
|
|
{#if alertTitle}<strong>{alertTitle}</strong>{/if}
|
|
{#if alertDescription}<span>{alertDescription}</span>{/if}
|
|
</aside>
|
|
{/if}
|
|
|
|
<div
|
|
class="wire-next__card-body"
|
|
data-scrollable="{scrollable}"
|
|
style="--wire-card-max-height: {maxHeight}"
|
|
>
|
|
{#if empty}
|
|
<div class="wire-next__card-empty">
|
|
<span class="{emptyIcon}" aria-hidden="true">
|
|
</span>
|
|
<strong>{emptyTitle}</strong>
|
|
</div>
|
|
{:else}
|
|
{#if title}<h3>{title}</h3>{/if}
|
|
{#if subtitle}<span class="wire-next__card-subtitle">{subtitle}</span>{/if}
|
|
{#if description}<p>{description}</p>{/if}
|
|
<slot />
|
|
{#if actionLabel}
|
|
<a
|
|
class="wire-next__card-action"
|
|
href="{actionHref || '#'}"
|
|
@click="$emit('action', { label: actionLabel, href: actionHref })"
|
|
>
|
|
{actionLabel}<span class="icon-[lucide--chevron-right]" aria-hidden="true">
|
|
</span>
|
|
</a>
|
|
{/if}
|
|
{/if}
|
|
</div>
|
|
|
|
{#if footer}<footer class="wire-next__card-footer">{footer}</footer>{/if}
|
|
|
|
{#if imageSrc && imagePosition === "bottom"}
|
|
<div class="wire-next__card-media">
|
|
<img
|
|
src="{imageSrc}"
|
|
alt="{imageAlt}"
|
|
loading="lazy"
|
|
@load="$emit('load', { src: imageSrc })"
|
|
@error="$emit('error', { src: imageSrc })"
|
|
/>
|
|
</div>
|
|
{/if}
|
|
{/if}
|
|
</article>
|
|
{/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>
|
|
}
|
|
}
|