Files
anwar-pi-website/web/src/app/(frontend)/subscription/faq.tsx
T
2026-10-09 16:20:55 +03:00

30 lines
893 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client'
import { useState } from 'react'
/* FAQ accordions — port of the subscription page's faq-button toggle. */
export default function Faq({ items }: { items: { q: string; a: string }[] }) {
const [openIdx, setOpenIdx] = useState<number | null>(0)
return (
<div className="faq-list">
{items.map((item, i) => {
const open = openIdx === i
return (
<article className={`faq-item${open ? ' open' : ''}`} key={i}>
<button
className="faq-button"
type="button"
aria-expanded={open}
onClick={() => setOpenIdx(open ? null : i)}
>
<span>{item.q}</span><span aria-hidden="true">{open ? '−' : '+'}</span>
</button>
<div className="faq-answer" hidden={!open}>{item.a}</div>
</article>
)
})}
</div>
)
}