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

257 lines
19 KiB
Plaintext

page FAQAccordioncomponent {
seo {
title = "FAQAccordion component"
description = "Reusable faqaccordion 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.64</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">FAQAccordion</span></nav><section class="doc-intro"><span class="eyebrow">core component</span><h1>FAQAccordion</h1><p>Reusable faqaccordion component.</p><div class="doc-meta"><span>@wrnexus/ui 0.2.64</span><span>13 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;FAQAccordion eyebrow=&quot;eyebrow&quot; title=&quot;Frequently asked questions&quot; description=&quot;description&quot; items=&quot;[]&quot; centered=&quot;true&quot; /&gt;</code></pre><p>Legacy mount name: <code>data-component=&quot;FAQAccordion&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>class</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</code></td></tr><tr><td><code>eyebrow</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;&quot;</code></td></tr><tr><td><code>title</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;Frequently asked questions&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>centered</code></td><td><code>boolean</code></td><td>Optional</td><td><code>true</code></td></tr><tr><td><code>compact</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>allowMultiple</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>defaultOpenIndex</code></td><td><code>number</code></td><td>Optional</td><td><code>0</code></td></tr><tr><td><code>showContact</code></td><td><code>boolean</code></td><td>Optional</td><td><code>false</code></td></tr><tr><td><code>contactText</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;Still have questions?&quot;</code></td></tr><tr><td><code>contactLabel</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;Contact support&quot;</code></td></tr><tr><td><code>contactHref</code></td><td><code>string</code></td><td>Optional</td><td><code>&quot;/support&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>click</code></li></ul></section><section id="source"><h2>Source contract</h2><p>Installed source: <code>components/FAQAccordion.wrn</code></p><pre data-language="wrn"><code>component FAQAccordion &#123;
props &#123;
class = &quot;&quot;
eyebrow = &quot;&quot;
title = &quot;Frequently asked questions&quot;
description = &quot;&quot;
items = []
centered = true
compact = false
allowMultiple = false
defaultOpenIndex = 0
showContact = false
contactText = &quot;Still have questions?&quot;
contactLabel = &quot;Contact support&quot;
contactHref = &quot;/support&quot;
&#125;
state openIndexes = defaultOpenIndex &gt;= 0 ? [defaultOpenIndex] : []
functions &#123;
function isOpen(index) &#123;
return openIndexes.includes(index)
&#125;
function toggleItem(index) &#123;
if (isOpen(index)) &#123;
openIndexes = openIndexes.filter(
(itemIndex) =&gt; itemIndex !== index
)
&#125; else if (allowMultiple) &#123;
openIndexes = [...openIndexes, index]
&#125; else &#123;
openIndexes = [index]
&#125;
&#125;
&#125;
view &#123;
&lt;section
aria-labelledby=&quot;faq-accordion-title&quot;
class=&quot;w-full px-5 sm:px-8 lg:px-10 xl:px-12 &#123;class&#125;&quot;
class:py-10=&quot;compact&quot;
class:sm:py-12=&quot;compact&quot;
class:py-14=&quot;!compact&quot;
class:sm:py-16=&quot;!compact&quot;
class:lg:py-20=&quot;!compact&quot;
class:hidden=&quot;items.length === 0&quot;
&gt;
&lt;div
class=&quot;mx-auto w-full&quot;
class:max-w-5xl=&quot;centered&quot;
class:max-w-7xl=&quot;!centered&quot;
&gt;
&lt;div
class=&quot;gap-10&quot;
class:flex=&quot;centered&quot;
class:flex-col=&quot;centered&quot;
class:grid=&quot;!centered&quot;
class:lg:grid-cols-[minmax(260px,0.7fr)_minmax(0,1.3fr)]=&quot;!centered&quot;
class:lg:items-start=&quot;!centered&quot;
class:lg:gap-14=&quot;!centered&quot;
&gt;
&lt;!-- Heading --&gt;
&lt;div
class=&quot;min-w-0&quot;
class:mx-auto=&quot;centered&quot;
class:max-w-3xl=&quot;centered&quot;
class:text-center=&quot;centered&quot;
class:max-w-xl=&quot;!centered&quot;
class:lg:sticky=&quot;!centered&quot;
class:lg:top-24=&quot;!centered&quot;
&gt;
&lt;!-- Eyebrow --&gt;
&lt;p
class=&quot;text-xs font-bold uppercase tracking-[0.18em] text-indigo-600 dark:text-indigo-400&quot;
class:hidden=&quot;eyebrow === ''&quot;
&gt;
&#123;eyebrow&#125;
&lt;/p&gt;
&lt;!-- Title --&gt;
&lt;h2
id=&quot;faq-accordion-title&quot;
class=&quot;font-bold leading-tight tracking-tight text-slate-950 dark:text-white&quot;
class:mt-3=&quot;eyebrow !== ''&quot;
class:text-2xl=&quot;compact&quot;
class:sm:text-3xl=&quot;compact&quot;
class:text-3xl=&quot;!compact&quot;
class:sm:text-4xl=&quot;!compact&quot;
&gt;
&#123;title&#125;
&lt;/h2&gt;
&lt;!-- Description --&gt;
&lt;p
class=&quot;mt-4 text-sm leading-7 text-slate-600 dark:text-slate-400&quot;
class:hidden=&quot;description === ''&quot;
class:sm:text-base=&quot;!compact&quot;
class:mx-auto=&quot;centered&quot;
class:max-w-2xl=&quot;centered&quot;
class:max-w-xl=&quot;!centered&quot;
&gt;
&#123;description&#125;
&lt;/p&gt;
&lt;!-- Contact card --&gt;
&lt;div
class=&quot;mt-7 rounded-2xl border border-indigo-200/80 bg-linear-to-br from-indigo-50 via-white to-violet-50 p-5 shadow-sm dark:border-indigo-500/20 dark:from-indigo-500/10 dark:via-white/[0.03] dark:to-violet-500/10&quot;
class:hidden=&quot;!showContact&quot;
&gt;
&lt;div
class=&quot;flex items-center gap-4&quot;
class:justify-center=&quot;centered&quot;
&gt;
&lt;span
class=&quot;grid h-11 w-11 shrink-0 place-items-center rounded-xl bg-white text-indigo-600 shadow-sm ring-1 ring-inset ring-indigo-200 dark:bg-white/5 dark:text-indigo-300 dark:ring-indigo-500/20&quot;
&gt;
&lt;span class=&quot;icon-[lucide--messages-square] h-5 w-5&quot; aria-hidden=&quot;true&quot; &gt;&lt;/span&gt;
&lt;/span&gt;
&lt;div
class=&quot;min-w-0&quot;
class:text-left=&quot;centered&quot;
&gt;
&lt;p class=&quot;text-sm font-semibold text-slate-950 dark:text-white&quot;&gt;
&#123;contactText&#125;
&lt;/p&gt;
&#123;#if contactLabel !== '' &amp;&amp; contactHref !== ''&#125;
&lt;a
href=&quot;&#123;contactHref&#125;&quot;
class=&quot;mt-1 inline-flex items-center gap-1.5 text-sm font-bold text-indigo-600 transition-colors duration-200 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300&quot;
&gt;
&#123;contactLabel&#125;
&lt;span class=&quot;icon-[lucide--arrow-right] h-4 w-4&quot; aria-hidden=&quot;true&quot; &gt;&lt;/span&gt;
&lt;/a&gt;
&#123;/if&#125;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;!-- Accordion --&gt;
&lt;div class=&quot;min-w-0&quot;&gt;
&lt;div class=&quot;space-y-3&quot;&gt;
&#123;#each items as item, index&#125;
&lt;article
class=&quot; overflow-hidden rounded-2xl border transition-[border-color,background-color,box-shadow,transform] duration-300 ease-out &#123;isOpen(index) ? 'border-indigo-200 bg-indigo-50/60 shadow-md shadow-indigo-950/5 dark:border-indigo-500/20 dark:bg-indigo-500/10' : 'border-slate-200 bg-white shadow-sm hover:-translate-y-0.5 hover:border-indigo-200 hover:bg-slate-50 dark:border-white/10 dark:bg-white/[0.03] dark:hover:border-indigo-500/20 dark:hover:bg-white/5' &#125; &quot;
&gt;
&lt;h3&gt;
&lt;button
type=&quot;button&quot;
@click=&quot;toggleItem(index)&quot;
aria-expanded=&quot;&#123;isOpen(index)&#125;&quot;
aria-controls=&quot;faq-answer-&#123;index&#125;&quot;
class=&quot;flex w-full items-center justify-between gap-5 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-indigo-500&quot;
class:px-4=&quot;compact&quot;
class:py-4=&quot;compact&quot;
class:px-5=&quot;!compact&quot;
class:py-5=&quot;!compact&quot;
class:sm:px-6=&quot;!compact&quot;
&gt;
&lt;span class=&quot;flex min-w-0 items-start gap-3&quot;&gt;
&lt;!-- Number --&gt;
&lt;span
class=&quot; mt-0.5 grid h-7 w-7 shrink-0 place-items-center rounded-lg text-xs font-bold transition-[background-color,color,transform] duration-300 ease-out &#123;isOpen(index) ? 'bg-indigo-600 text-white' : 'bg-slate-100 text-slate-500 dark:bg-white/5 dark:text-slate-400' &#125; &quot;
&gt;
&#123;index + 1&#125;
&lt;/span&gt;
&lt;!-- Question --&gt;
&lt;span
class=&quot;font-semibold leading-6 text-slate-950 dark:text-white&quot;
class:text-sm=&quot;compact&quot;
class:text-base=&quot;!compact&quot;
&gt;
&#123;item.question&#125;
&lt;/span&gt;
&lt;/span&gt;
&lt;!-- Toggle icon --&gt;
&lt;span
class=&quot; grid h-8 w-8 shrink-0 place-items-center rounded-lg transition-[background-color,color,transform] duration-300 ease-out &#123;isOpen(index) ? 'bg-indigo-100 text-indigo-700 dark:bg-indigo-500/15 dark:text-indigo-300' : 'bg-slate-100 text-slate-500 dark:bg-white/5 dark:text-slate-400' &#125; &quot;
&gt;
&lt;span class=&quot; icon-[lucide--chevron-down] h-4 w-4 transition-transform duration-300 ease-out &#123;isOpen(index) ? 'rotate-180' : 'rotate-0'&#125; &quot; aria-hidden=&quot;true&quot; &gt;&lt;/span&gt;
&lt;/span&gt;
&lt;/button&gt;
&lt;/h3&gt;
&lt;div
id=&quot;faq-answer-&#123;index&#125;&quot;
role=&quot;region&quot;
aria-hidden=&quot;&#123;!isOpen(index)&#125;&quot;
class=&quot; grid overflow-hidden transition-[grid-template-rows,opacity] duration-300 ease-out &#123;isOpen(index) ? 'grid-rows-[1fr] opacity-100' : 'grid-rows-[0fr] opacity-0' &#125; &quot;
&gt;
&lt;div class=&quot;min-h-0 overflow-hidden&quot;&gt;
&lt;div class=&quot;border-t border-indigo-200/60 dark:border-indigo-500/15&quot;&gt;
&lt;div
class=&quot; text-sm leading-7 text-slate-600 transition-[transform,opacity] duration-300 ease-out dark:text-slate-400 &#123;compact ? 'px-4 pb-4 pt-3' : 'px-5 pb-5 pt-4 sm:px-6 sm:pb-6 sm:pt-5' &#125; &#123;isOpen(index) ? 'translate-y-0 opacity-100' : '-translate-y-2 opacity-0' &#125; &quot;
&gt;
&lt;p class=&quot;m-0&quot;&gt;
&#123;item.answer&#125;
&lt;/p&gt;
&#123;#if item.linkLabel !== '' &amp;&amp; item.href !== ''&#125;
&lt;a
href=&quot;&#123;item.href&#125;&quot;
class=&quot; group inline-flex items-center gap-2 text-sm font-bold text-indigo-600 transition-colors duration-200 hover:text-indigo-500 dark:text-indigo-400 dark:hover:text-indigo-300 &quot;
&gt;
&#123;item.linkLabel&#125;
&lt;span class=&quot; icon-[lucide--arrow-up-right] h-4 w-4 transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5 &quot; aria-hidden=&quot;true&quot; &gt;&lt;/span&gt;
&lt;/a&gt;
&#123;/if&#125;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/article&gt;
&#123;/each&#125;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;!-- Tailwind safelist for utilities used by reactive class directives --&gt;
&lt;span class=&quot; hidden flex flex-col grid justify-center lg:gap-14 lg:grid-cols-[minmax(260px,0.7fr)_minmax(0,1.3fr)] lg:items-start lg:py-20 lg:sticky lg:top-24 max-w-2xl max-w-3xl max-w-5xl max-w-7xl max-w-xl mt-3 mx-auto px-4 px-5 py-4 py-5 py-10 py-14 sm:px-6 sm:py-12 sm:py-16 sm:text-base sm:text-3xl sm:text-4xl text-base text-center text-left text-sm text-2xl text-3xl grid-rows-[0fr] grid-rows-[1fr] opacity-0 opacity-100 -translate-y-2 translate-y-0 rotate-0 rotate-180 &quot; &gt;&lt;/span&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.2.64</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>
}
}