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.

footer.tsx 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import { cn } from '@/lib/utils';
  2. import { useStorefront } from '../context';
  3. import { StoreLogo } from '../logo';
  4. import { storefrontText } from '../text';
  5. import type { FooterSection } from '../types';
  6. import { Container, SfLink } from '../ui';
  7. import { whatsappLink } from '../whatsapp';
  8. export function Footer({
  9. section,
  10. }: {
  11. section: Pick<FooterSection, 'variant' | 'content'>;
  12. }) {
  13. const { text, links } = section.content;
  14. const centered = section.variant === 'centered';
  15. const { storeName, shop, language } = useStorefront();
  16. const t = storefrontText(language);
  17. // columns: a fuller footer with the store name, its links, and help links.
  18. if (section.variant === 'columns') {
  19. return (
  20. <footer
  21. className="border-t border-(--sf-border) bg-(--sf-surface)"
  22. data-layout="columns"
  23. >
  24. <Container className="grid gap-10 py-14 text-sm sm:grid-cols-2 md:grid-cols-[2fr_1fr_1fr]">
  25. <div>
  26. {shop.logo ? (
  27. <StoreLogo
  28. logo={shop.logo}
  29. name={storeName}
  30. className="h-10 md:h-11"
  31. />
  32. ) : (
  33. <p className="sf-heading text-2xl font-semibold">
  34. {storeName}
  35. </p>
  36. )}
  37. <p className="mt-3 max-w-sm text-(--sf-muted)">
  38. {text}
  39. </p>
  40. </div>
  41. {links.length > 0 && (
  42. <nav aria-label="Footer">
  43. <p className="font-semibold">{t.footerExplore}</p>
  44. <ul className="mt-3 space-y-2 text-(--sf-muted)">
  45. {links.map((link) => (
  46. <li key={link.label + link.href}>
  47. <SfLink
  48. href={link.href}
  49. className="transition-colors hover:text-(--sf-fg)"
  50. >
  51. {link.label}
  52. </SfLink>
  53. </li>
  54. ))}
  55. </ul>
  56. </nav>
  57. )}
  58. <div>
  59. <p className="font-semibold">{t.footerHelp}</p>
  60. <ul className="mt-3 space-y-2 text-(--sf-muted)">
  61. <li>
  62. <SfLink
  63. href="/shop"
  64. className="transition-colors hover:text-(--sf-fg)"
  65. >
  66. {t.allProducts}
  67. </SfLink>
  68. </li>
  69. <li>
  70. <SfLink
  71. href="/cart"
  72. className="transition-colors hover:text-(--sf-fg)"
  73. >
  74. {t.cart}
  75. </SfLink>
  76. </li>
  77. {shop.whatsapp && (
  78. <li>
  79. <a
  80. href={whatsappLink(
  81. shop.whatsapp,
  82. t.whatsAppHello(storeName),
  83. )}
  84. target="_blank"
  85. rel="noreferrer"
  86. className="transition-colors hover:text-(--sf-fg)"
  87. >
  88. {t.chatOnWhatsApp}
  89. </a>
  90. </li>
  91. )}
  92. </ul>
  93. </div>
  94. </Container>
  95. </footer>
  96. );
  97. }
  98. return (
  99. <footer className="border-t border-(--sf-border)">
  100. <Container
  101. className={cn(
  102. 'flex flex-col gap-4 py-8 text-sm text-(--sf-muted)',
  103. centered
  104. ? 'items-center text-center'
  105. : 'sm:flex-row sm:items-center sm:justify-between',
  106. )}
  107. >
  108. <div
  109. className={cn(
  110. 'flex flex-col gap-3',
  111. centered ? 'items-center' : 'items-start',
  112. )}
  113. >
  114. {shop.logo && (
  115. <StoreLogo
  116. logo={shop.logo}
  117. name={storeName}
  118. className="h-8 md:h-9"
  119. />
  120. )}
  121. <p>{text}</p>
  122. </div>
  123. {links.length > 0 && (
  124. <nav aria-label="Footer" className="flex flex-wrap gap-5">
  125. {links.map((link) => (
  126. <SfLink
  127. key={link.label + link.href}
  128. href={link.href}
  129. className="transition-colors hover:text-(--sf-fg)"
  130. >
  131. {link.label}
  132. </SfLink>
  133. ))}
  134. </nav>
  135. )}
  136. </Container>
  137. </footer>
  138. );
  139. }