This commit is contained in:
eric
2026-03-27 18:20:36 -05:00
parent a8976b2eee
commit 326bad4336
34 changed files with 2787 additions and 996 deletions

View File

@@ -4,54 +4,75 @@ import { useState } from "react";
import { FAQ_ITEMS } from "@/app/data/vip.mock";
import styles from "../vip.module.css";
function ChevronDown() {
return (
<svg className={styles.faqChevron} width="18" height="18" viewBox="0 0 24 24" fill="none" aria-hidden>
<path
d="M6 9l6 6 6-6"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
);
}
export function FAQSection() {
const [openIndex, setOpenIndex] = useState<number | null>(null);
const [openIndex, setOpenIndex] = useState<number | null>(0);
return (
<section className={styles.section}>
<h2 className={styles.sectionTitle}>常见问题</h2>
<div
className="animate__animated animate__fadeInUp"
style={{ animationDelay: "0.2s", animationFillMode: "both" }}
>
{FAQ_ITEMS.map((item, i) => (
<div
key={i}
className={styles.card}
style={{
marginBottom: "0.75rem",
cursor: "pointer",
}}
onClick={() => setOpenIndex(openIndex === i ? null : i)}
>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
fontWeight: 500,
color: "var(--foreground)",
}}
>
{item.q}
<span style={{ fontSize: "1.2rem", transition: "transform 0.2s", transform: openIndex === i ? "rotate(180deg)" : "none" }}>
▼
</span>
</div>
{openIndex === i && (
<p
style={{
marginTop: "0.75rem",
fontSize: "0.9rem",
color: "var(--muted-foreground)",
lineHeight: 1.5,
}}
<section className={`${styles.section} ${styles.faqSection}`} aria-labelledby="faq-heading">
<div className={`${styles.faqInner} animate__animated animate__fadeInUp`} style={{ animationDelay: "0.15s", animationFillMode: "both" }}>
<p className={styles.faqEyebrow}>
<span className={styles.faqEyebrowDot} aria-hidden />
FAQ
</p>
<h2 id="faq-heading" className={styles.faqHeadline}>
常见问题
</h2>
<p className={styles.faqSub}>
购买前可快速了解会员权益与流程;点击问题展开详情。
</p>
<div className={styles.faqList} role="list">
{FAQ_ITEMS.map((item, i) => {
const open = openIndex === i;
const panelId = `faq-panel-${i}`;
const triggerId = `faq-trigger-${i}`;
return (
<div
key={i}
className={`${styles.faqItem} ${open ? styles.faqItemOpen : ""}`}
role="listitem"
>
{item.a}
</p>
)}
</div>
))}
<button
type="button"
id={triggerId}
className={styles.faqTrigger}
aria-expanded={open}
aria-controls={panelId}
onClick={() => setOpenIndex(open ? null : i)}
>
<span className={styles.faqIndex} aria-hidden>
{i + 1}
</span>
<span className={styles.faqQuestionText}>{item.q}</span>
<ChevronDown />
</button>
<div
id={panelId}
role="region"
aria-labelledby={triggerId}
className={`${styles.faqPanel} ${open ? styles.faqPanelOpen : ""}`}
>
<div className={styles.faqPanelInner}>
<p className={styles.faqAnswer}>{item.a}</p>
</div>
</div>
</div>
);
})}
</div>
</div>
</section>
);