import { useState } from "preact/hooks"; export function QuestionList(props: { questions: FrequentlyAskedQuestion[]; }) { const [ open, setOpen ] = useState(null); const toggle = (index: number) => { setOpen(open === index ? null : index); }; return (
{props.questions.map((question, index: number) => (
toggle(index)} className={`w-full overflow-hidden border-l border-r border-t cursor-pointer ${open === index ? "bg-(--ptc) text-(--ptt)" : "bg-white"} ${index === 0 ? "rounded-t-2xl border-t border-(--ptc)" : ""} ${(index + 1) === props.questions.length ? "rounded-b-2xl border-b border-(--ptc) shadow-md" : "border-(--ptc)"}`} >

{question.question}

{question.answer}
))}
); }