| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- import { cn } from '@/lib/utils';
- import { useStorefront } from '../context';
- import { storefrontText } from '../text';
- import type { FooterSection } from '../types';
- import { Container, SfLink } from '../ui';
- import { whatsappLink } from '../whatsapp';
-
- export function Footer({
- section,
- }: {
- section: Pick<FooterSection, 'variant' | 'content'>;
- }) {
- const { text, links } = section.content;
- const centered = section.variant === 'centered';
- const { storeName, shop, language } = useStorefront();
- const t = storefrontText(language);
-
- // columns: a fuller footer with the store name, its links, and help links.
- if (section.variant === 'columns') {
- return (
- <footer
- className="border-t border-(--sf-border) bg-(--sf-surface)"
- data-layout="columns"
- >
- <Container className="grid gap-10 py-14 text-sm sm:grid-cols-2 md:grid-cols-[2fr_1fr_1fr]">
- <div>
- <p className="sf-heading text-2xl font-semibold">
- {storeName}
- </p>
- <p className="mt-3 max-w-sm text-(--sf-muted)">
- {text}
- </p>
- </div>
- {links.length > 0 && (
- <nav aria-label="Footer">
- <p className="font-semibold">{t.footerExplore}</p>
- <ul className="mt-3 space-y-2 text-(--sf-muted)">
- {links.map((link) => (
- <li key={link.label + link.href}>
- <SfLink
- href={link.href}
- className="transition-colors hover:text-(--sf-fg)"
- >
- {link.label}
- </SfLink>
- </li>
- ))}
- </ul>
- </nav>
- )}
- <div>
- <p className="font-semibold">{t.footerHelp}</p>
- <ul className="mt-3 space-y-2 text-(--sf-muted)">
- <li>
- <SfLink
- href="/shop"
- className="transition-colors hover:text-(--sf-fg)"
- >
- {t.allProducts}
- </SfLink>
- </li>
- <li>
- <SfLink
- href="/cart"
- className="transition-colors hover:text-(--sf-fg)"
- >
- {t.cart}
- </SfLink>
- </li>
- {shop.whatsapp && (
- <li>
- <a
- href={whatsappLink(
- shop.whatsapp,
- t.whatsAppHello(storeName),
- )}
- target="_blank"
- rel="noreferrer"
- className="transition-colors hover:text-(--sf-fg)"
- >
- {t.chatOnWhatsApp}
- </a>
- </li>
- )}
- </ul>
- </div>
- </Container>
- </footer>
- );
- }
-
- return (
- <footer className="border-t border-(--sf-border)">
- <Container
- className={cn(
- 'flex flex-col gap-4 py-8 text-sm text-(--sf-muted)',
- centered
- ? 'items-center text-center'
- : 'sm:flex-row sm:items-center sm:justify-between',
- )}
- >
- <p>{text}</p>
- {links.length > 0 && (
- <nav aria-label="Footer" className="flex flex-wrap gap-5">
- {links.map((link) => (
- <SfLink
- key={link.label + link.href}
- href={link.href}
- className="transition-colors hover:text-(--sf-fg)"
- >
- {link.label}
- </SfLink>
- ))}
- </nav>
- )}
- </Container>
- </footer>
- );
- }
|