|
1 | 1 | import Link from "next/link"; |
| 2 | +import { useTheme } from "next-themes"; |
2 | 3 |
|
3 | 4 | import BoldCopy from "@/animata/text/bold-copy"; |
4 | 5 | import ComponentLinkWrapper from "@/components/component-link-wrapper"; |
5 | | -import { cn } from "@/lib/utils"; |
| 6 | +import { |
| 7 | + Accordion, |
| 8 | + AccordionContent, |
| 9 | + AccordionItem, |
| 10 | + AccordionTrigger, |
| 11 | +} from "@/components/ui/accordion"; |
6 | 12 |
|
7 | 13 | import Highlight from "./highlight"; |
8 | 14 |
|
@@ -55,43 +61,48 @@ const faq = [ |
55 | 61 |
|
56 | 62 | function FaqItem({ index }: { index: number }) { |
57 | 63 | const item = faq[index]; |
58 | | - const count = ( |
59 | | - <BoldCopy |
60 | | - text={String(index + 1)} |
61 | | - className="w-fit bg-transparent px-0 md:px-0" |
62 | | - textClassName="text-md md:text-xl group-hover:text-2xl group-hover:md:text-5xl transition-all" |
63 | | - backgroundTextClassName="text-2xl md:text-5xl" |
64 | | - /> |
65 | | - ); |
66 | | - |
67 | 64 | return ( |
68 | | - <div |
69 | | - key={`question-${index}`} |
70 | | - className={cn({ |
71 | | - "mb-4": index !== faq.length - 1, |
72 | | - })} |
73 | | - > |
74 | | - <h3 className="relative flex flex-shrink-0 flex-wrap items-center gap-4"> |
75 | | - {count} |
76 | | - <span className="inline-block w-3/4 text-lg font-medium md:text-xl">{item.question}</span> |
77 | | - </h3> |
78 | | - <div className="flex gap-4"> |
79 | | - <div className="invisible h-0">{count}</div> |
80 | | - <div className="text-muted-foreground">{item.answer}</div> |
81 | | - </div> |
82 | | - </div> |
| 65 | + <AccordionItem value={`question-${index}`} className="w-full px-4 md:px-0"> |
| 66 | + <AccordionTrigger className="w-full"> |
| 67 | + <span className="inline-block text-sm font-medium md:text-base">{item.question}</span> |
| 68 | + </AccordionTrigger> |
| 69 | + <AccordionContent> |
| 70 | + <div className="text-gray-900 dark:text-slate-50">{item.answer}</div> |
| 71 | + </AccordionContent> |
| 72 | + </AccordionItem> |
83 | 73 | ); |
84 | 74 | } |
85 | 75 |
|
86 | 76 | export default function FAQSection() { |
| 77 | + const { resolvedTheme } = useTheme(); |
| 78 | + const color = resolvedTheme === "dark" ? "#ffffff12" : "#444cf710"; |
87 | 79 | return ( |
88 | | - <section id="faq" className="relative mx-auto max-w-5xl"> |
89 | | - <ComponentLinkWrapper link="/docs/text/bold-copy" className="w-full"> |
90 | | - <BoldCopy text="FAQ" className="mb-4 border border-gray-200 dark:border-zinc-800" /> |
91 | | - </ComponentLinkWrapper> |
92 | | - {faq.map((_, index) => { |
93 | | - return <FaqItem key={`item-${index}`} index={index} />; |
94 | | - })} |
95 | | - </section> |
| 80 | + <div |
| 81 | + className="relative border-b border-t border-border pb-4" |
| 82 | + style={{ |
| 83 | + backgroundImage: `radial-gradient(${color} 1px, transparent 1px)`, |
| 84 | + backgroundSize: "calc(10px) calc(10px)", |
| 85 | + }} |
| 86 | + > |
| 87 | + <div className="absolute inset-0 left-1/2 z-0 aspect-square h-[120%] -translate-x-1/2 rounded-full bg-gradient-to-br from-gray-100 to-gray-50 blur-3xl dark:from-zinc-900 dark:to-zinc-800" /> |
| 88 | + <section id="faq" className="mx-auto flex max-w-xl flex-col gap-4 py-16"> |
| 89 | + <ComponentLinkWrapper className="mx-auto px-4" link="/docs/text/bold-copy"> |
| 90 | + <BoldCopy |
| 91 | + text="FAQ" |
| 92 | + textClassName="leading-none" |
| 93 | + backgroundTextClassName="leading-none" |
| 94 | + className="bg-transparent" |
| 95 | + /> |
| 96 | + <div className="relative z-10 -mt-2 block text-center text-xs leading-none text-muted-foreground md:-mt-4 md:text-base"> |
| 97 | + You ask. We answer. |
| 98 | + </div> |
| 99 | + </ComponentLinkWrapper> |
| 100 | + <Accordion collapsible type="single" className="relative"> |
| 101 | + {faq.map((_, index) => { |
| 102 | + return <FaqItem key={`item-${index}`} index={index} />; |
| 103 | + })} |
| 104 | + </Accordion> |
| 105 | + </section> |
| 106 | + </div> |
96 | 107 | ); |
97 | 108 | } |
0 commit comments