feat: complete dynamic JSON-driven photo tools frontend connected to FastAPI backend
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
'use client';
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { ChevronDown } from 'lucide-react';
|
||||
import { resolveLocalised } from '@/types';
|
||||
|
||||
interface FaqSectionProps {
|
||||
title?: any;
|
||||
items?: Array<{
|
||||
q: string;
|
||||
a: string;
|
||||
}>;
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
export function FaqSection({
|
||||
title,
|
||||
items = [],
|
||||
locale = 'en',
|
||||
}: FaqSectionProps) {
|
||||
const [openIndex, setOpenIndex] = useState<number | null>(0);
|
||||
|
||||
if (!items || items.length === 0) return null;
|
||||
|
||||
return (
|
||||
<section className="py-12 lg:py-16">
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
{title && (
|
||||
<h2 className="text-3xl font-bold text-slate-900 dark:text-white mb-8 text-center">
|
||||
{resolveLocalised(title, locale)}
|
||||
</h2>
|
||||
)}
|
||||
|
||||
<div className="space-y-3">
|
||||
{items.map((item, idx) => {
|
||||
const isOpen = openIndex === idx;
|
||||
return (
|
||||
<div
|
||||
key={idx}
|
||||
className="rounded-2xl border border-slate-200 dark:border-slate-800 bg-white dark:bg-slate-900 overflow-hidden shadow-sm transition-all"
|
||||
>
|
||||
<button
|
||||
onClick={() => setOpenIndex(isOpen ? null : idx)}
|
||||
className="w-full p-5 text-left flex items-center justify-between gap-4 font-semibold text-slate-900 dark:text-white hover:text-blue-600 dark:hover:text-blue-400 transition-colors"
|
||||
>
|
||||
<span className="text-base">{item.q}</span>
|
||||
<ChevronDown
|
||||
className={`w-5 h-5 text-slate-400 shrink-0 transition-transform duration-200 ${
|
||||
isOpen ? 'rotate-180 text-blue-600' : ''
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
|
||||
{isOpen && (
|
||||
<div className="px-5 pb-5 text-sm text-slate-600 dark:text-slate-400 leading-relaxed border-t border-slate-100 dark:border-slate-800/60 pt-3">
|
||||
{item.a}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user