Branchwell

Jotley / website · jotley.ai / src / app / components / FAQAccordion.tsx

Raw 1.5 KB on 9f5272c5f39b346af9e28d5fc68fe05aab70ce39
1'use client';
2
3import { useId, useState } from 'react';
4import { FAQS } from '@/lib/faqs';
5
6export default function FAQAccordion({ reveal = false, supportDetails = false }: { reveal?: boolean; supportDetails?: boolean }) {
7 const id = useId();
8 const [openQuestion, setOpenQuestion] = useState<string | null>(null);
9
10 return (
11 <div className="faq-list">
12 {FAQS.filter(({ q }) => supportDetails || q !== "What can my AI agent do with Jotley on Mac?").map(({ q, a }, index) => {
13 const open = openQuestion === q;
14 const answerId = `${id}-answer-${index}`;
15
16 return (
17 <div className={reveal ? 'reveal' : undefined} key={q}>
18 <div className={`faq-item${open ? ' open' : ''}`}>
19 <h3>
20 <button
21 type="button"
22 className="faq-q"
23 aria-expanded={open}
24 aria-controls={answerId}
25 onClick={() => setOpenQuestion(open ? null : q)}
26 >
27 {q}
28 <span className="pm" aria-hidden="true">
29 <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth={2.4}>
30 <path d="M12 5v14M5 12h14" strokeLinecap="round" />
31 </svg>
32 </span>
33 </button>
34 </h3>
35 <div id={answerId} className="faq-a" inert={!open}>
36 <div><p>{a}</p></div>
37 </div>
38 </div>
39 </div>
40 );
41 })}
42 </div>
43 );
44}