AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { Plus } from 'lucide-react';
  2. import { cn } from '@/lib/utils';
  3. import type { FaqSection } from '../types';
  4. import { Container, SectionHeading } from '../ui';
  5. export function Faq({ section }: { section: FaqSection }) {
  6. const { heading, items } = section.content;
  7. const twoColumn = section.variant === 'two-column';
  8. // cards: every answer showing, in a grid of cards. Good for a few short questions.
  9. if (section.variant === 'cards') {
  10. return (
  11. <section
  12. id={section.id}
  13. className="sf-section scroll-mt-20 py-16 md:py-20"
  14. data-layout="cards"
  15. >
  16. <Container>
  17. <SectionHeading heading={heading} />
  18. <dl className="mt-10 grid gap-5 md:grid-cols-2">
  19. {items.map((item) => (
  20. <div
  21. key={item.question}
  22. className="sf-card rounded-(--sf-radius-card) border border-(--sf-border) p-6"
  23. >
  24. <dt className="font-semibold">
  25. {item.question}
  26. </dt>
  27. <dd className="mt-2 leading-relaxed text-(--sf-muted)">
  28. {item.answer}
  29. </dd>
  30. </div>
  31. ))}
  32. </dl>
  33. </Container>
  34. </section>
  35. );
  36. }
  37. return (
  38. <section
  39. id={section.id}
  40. className="sf-section scroll-mt-20 py-16 md:py-20"
  41. >
  42. <Container
  43. className={cn(
  44. twoColumn
  45. ? 'grid gap-10 md:grid-cols-[1fr_2fr]'
  46. : 'max-w-3xl',
  47. )}
  48. >
  49. <SectionHeading heading={heading} />
  50. <div
  51. className={cn(
  52. 'divide-y divide-(--sf-border) border-y border-(--sf-border)',
  53. !twoColumn && 'mt-8',
  54. )}
  55. >
  56. {items.map((item) => (
  57. <details key={item.question} className="group py-5">
  58. <summary className="flex cursor-pointer list-none items-center justify-between gap-4 font-medium [&::-webkit-details-marker]:hidden">
  59. {item.question}
  60. <Plus
  61. aria-hidden
  62. className="size-4 shrink-0 text-(--sf-muted) transition-transform group-open:rotate-45"
  63. />
  64. </summary>
  65. <p className="mt-3 max-w-2xl leading-relaxed text-(--sf-muted)">
  66. {item.answer}
  67. </p>
  68. </details>
  69. ))}
  70. </div>
  71. </Container>
  72. </section>
  73. );
  74. }