119 lines
7.9 KiB
Plaintext
119 lines
7.9 KiB
Plaintext
page BackToTopcomponent {
|
|
seo {
|
|
title = "BackToTop component"
|
|
description = "Reusable back to top 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.2.66</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">BackToTop</span></nav><section class="doc-intro"><span class="eyebrow">core component</span><h1>BackToTop</h1><p>Reusable back to top component.</p><div class="doc-meta"><span>@wrnexus/ui 0.2.66</span><span>4 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><BackToTop
|
|
label="Back to top"
|
|
assistiveLabel="Return to the top of the page"
|
|
threshold="500"
|
|
/></code></pre><p>Legacy mount name: <code>data-component="BackToTop"</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>class</code></td><td><code>string</code></td><td>Optional</td><td><code>""</code></td></tr><tr><td><code>label</code></td><td><code>string</code></td><td>Optional</td><td><code>"Back to top"</code></td></tr><tr><td><code>assistiveLabel</code></td><td><code>string</code></td><td>Optional</td><td><code>"Return to the top of the page"</code></td></tr><tr><td><code>threshold</code></td><td><code>number</code></td><td>Optional</td><td><code>500</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>click</code></li></ul></section><section id="source"><h2>Source contract</h2><p>Installed source: <code>components/BackToTop.wrn</code></p><pre data-language="wrn"><code>component BackToTop {
|
|
props {
|
|
class = ""
|
|
label = "Back to top"
|
|
assistiveLabel = "Return to the top of the page"
|
|
threshold = 500
|
|
}
|
|
|
|
state visible = false
|
|
|
|
functions {
|
|
function updateBackToTopVisibility() {
|
|
visible = window.scrollY > threshold
|
|
}
|
|
|
|
function scrollToTop() {
|
|
window.scrollTo({
|
|
top: 0,
|
|
behavior: "smooth"
|
|
})
|
|
}
|
|
}
|
|
|
|
lifecycle {
|
|
mount {
|
|
updateBackToTopVisibility()
|
|
|
|
window.addEventListener(
|
|
"scroll",
|
|
updateBackToTopVisibility,
|
|
{ passive: true }
|
|
)
|
|
}
|
|
|
|
unmount {
|
|
window.removeEventListener(
|
|
"scroll",
|
|
updateBackToTopVisibility
|
|
)
|
|
}
|
|
}
|
|
|
|
watch visible {
|
|
console.debug(
|
|
"Back-to-top visibility:",
|
|
value,
|
|
previous
|
|
)
|
|
}
|
|
|
|
view {
|
|
<div
|
|
class="group fixed bottom-6 right-5 z-[70] flex items-center gap-2 transition-all duration-300 sm:right-6 lg:bottom-8 lg:right-8 {class}"
|
|
class:pointer-events-none="!visible"
|
|
class:translate-y-5="!visible"
|
|
class:scale-90="!visible"
|
|
class:opacity-0="!visible"
|
|
class:pointer-events-auto="visible"
|
|
class:translate-y-0="visible"
|
|
class:scale-100="visible"
|
|
class:opacity-100="visible"
|
|
>
|
|
<!-- Hover label -->
|
|
<span
|
|
class="pointer-events-none hidden translate-x-2 whitespace-nowrap rounded-xl border border-slate-200 bg-white/95 px-3 py-2 text-xs font-semibold text-slate-700 opacity-0 shadow-lg shadow-slate-950/10 backdrop-blur-xl transition-all duration-200 group-hover:translate-x-0 group-hover:opacity-100 dark:border-white/10 dark:bg-slate-900/95 dark:text-slate-200 dark:shadow-black/30 sm:block"
|
|
>
|
|
{label}
|
|
</span>
|
|
<!-- Gradient border wrapper -->
|
|
<div
|
|
class="relative rounded-2xl bg-linear-to-br from-indigo-500 via-violet-500 to-cyan-500 p-px shadow-xl shadow-indigo-600/20 transition duration-300 group-hover:-translate-y-1 group-hover:shadow-2xl group-hover:shadow-indigo-600/30"
|
|
>
|
|
<!-- Glow -->
|
|
<div aria-hidden="true" class="absolute inset-1 rounded-2xl bg-indigo-500/20 opacity-0 blur-xl transition-opacity duration-300 group-hover:opacity-100" >
|
|
</div>
|
|
<button
|
|
type="button"
|
|
@click="scrollToTop()"
|
|
aria-label="{label}"
|
|
title="{label}"
|
|
class="relative grid h-12 w-12 place-items-center rounded-[15px] bg-white/95 text-indigo-700 backdrop-blur-xl transition duration-300 hover:bg-indigo-600 hover:text-white focus:outline-none focus-visible:ring-2 focus-visible:ring-indigo-500 focus-visible:ring-offset-2 active:scale-95 dark:bg-slate-900/95 dark:text-indigo-300 dark:hover:bg-indigo-500 dark:hover:text-white dark:focus-visible:ring-offset-slate-950 sm:h-13 sm:w-13"
|
|
>
|
|
<!-- Arrow -->
|
|
<span class="icon-[lucide--arrow-up] h-5 w-5 transition-transform duration-300 group-hover:-translate-y-0.5" aria-hidden="true" >
|
|
</span>
|
|
<span class="sr-only">
|
|
{assistiveLabel}
|
|
</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
}
|
|
}
|
|
</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.2.66</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>
|
|
}
|
|
}
|