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.

contact.tsx 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { Mail, MapPin, MessageCircle, Phone } from 'lucide-react';
  2. import type { ReactNode } from 'react';
  3. import { cn } from '@/lib/utils';
  4. import type { ContactSection } from '../types';
  5. import { Container, SectionHeading } from '../ui';
  6. function Row({
  7. icon,
  8. href,
  9. children,
  10. }: {
  11. icon: ReactNode;
  12. href?: string;
  13. children: ReactNode;
  14. }) {
  15. const body = (
  16. <>
  17. <span className="flex size-9 shrink-0 items-center justify-center rounded-full bg-(--sf-surface) text-(--sf-primary)">
  18. {icon}
  19. </span>
  20. {children}
  21. </>
  22. );
  23. return (
  24. <li>
  25. {href ? (
  26. <a
  27. href={href}
  28. className="flex items-center gap-3 hover:underline"
  29. >
  30. {body}
  31. </a>
  32. ) : (
  33. <span className="flex items-center gap-3">{body}</span>
  34. )}
  35. </li>
  36. );
  37. }
  38. export function Contact({ section }: { section: ContactSection }) {
  39. const { heading, body, email, phone, whatsapp, address } = section.content;
  40. const card = section.variant === 'card';
  41. return (
  42. <section id={section.id} className="scroll-mt-20 py-16 md:py-20">
  43. <Container>
  44. <div
  45. className={cn(
  46. 'grid gap-8 md:grid-cols-2',
  47. card &&
  48. 'rounded-(--sf-radius-card) border border-(--sf-border) p-8 sm:p-10',
  49. )}
  50. >
  51. <SectionHeading heading={heading} subheading={body} />
  52. <ul className="space-y-4 text-sm">
  53. {whatsapp && (
  54. <Row
  55. icon={<MessageCircle className="size-4" />}
  56. href={`https://wa.me/${whatsapp}`}
  57. >
  58. Chat on WhatsApp
  59. </Row>
  60. )}
  61. {email && (
  62. <Row
  63. icon={<Mail className="size-4" />}
  64. href={`mailto:${email}`}
  65. >
  66. {email}
  67. </Row>
  68. )}
  69. {phone && (
  70. <Row
  71. icon={<Phone className="size-4" />}
  72. href={`tel:${phone.replace(/[^0-9+]/g, '')}`}
  73. >
  74. {phone}
  75. </Row>
  76. )}
  77. {address && (
  78. <Row icon={<MapPin className="size-4" />}>
  79. {address}
  80. </Row>
  81. )}
  82. </ul>
  83. </div>
  84. </Container>
  85. </section>
  86. );
  87. }