AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

whatsapp.tsx 1.3KB

12345678910111213141516171819202122232425262728293031323334
  1. import { MessageCircle } from 'lucide-react';
  2. import { useStorefront } from './context';
  3. import { storefrontText } from './text';
  4. export function whatsappLink(number: string, text: string): string {
  5. return `https://wa.me/${number}?text=${encodeURIComponent(text)}`;
  6. }
  7. /**
  8. * A round "chat on WhatsApp" button in the corner of every store page.
  9. * Shows only when the merchant has set a WhatsApp number.
  10. */
  11. export function WhatsAppButton() {
  12. const { shop, language, storeName } = useStorefront();
  13. const t = storefrontText(language);
  14. if (!shop.whatsapp) {
  15. return null;
  16. }
  17. return (
  18. <a
  19. href={whatsappLink(shop.whatsapp, t.whatsAppHello(storeName))}
  20. target="_blank"
  21. rel="noreferrer"
  22. className="sf-whatsapp fixed right-4 bottom-4 z-30 inline-flex items-center gap-2 rounded-full bg-[#25D366] px-4 py-3 text-sm font-semibold text-[#073B1C] shadow-lg transition-transform hover:scale-105 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#25D366] sm:right-6 sm:bottom-6"
  23. data-test="whatsapp-button"
  24. >
  25. <MessageCircle className="size-5" aria-hidden="true" />
  26. <span className="hidden sm:inline">{t.chatOnWhatsApp}</span>
  27. <span className="sr-only sm:hidden">{t.chatOnWhatsApp}</span>
  28. </a>
  29. );
  30. }