'use client'; /** * Cart link for the site header: icon plus a live item count. * * The header itself is a server component fed by merchant-configured Content, * so the count has to come from a small client island. It is a real LINK to * /cart (not a button that opens something), so keyboard and screen-reader * users reach the cart the same way everyone else does. * * `itemCount` is the store's own number. Before the cart's first answer it is * the count remembered from the previous visit, so the badge is right from the * first frame instead of flipping from nothing to 3 once the request lands. * The badge hides at zero; the accessible name carries the count, so the badge * itself is `aria-hidden`. */ import * as React from 'react'; import { ShoppingCart } from 'lucide-react'; import { SmartLink } from '@/core/lib/navigation'; import { useCart } from '@/core/providers/store-provider'; import { useTranslations } from '@/core/lib/translations'; export function HeaderCart() { const { itemCount } = useCart(); const t = useTranslations('nav'); const label = itemCount <= 0 ? t('cart') : itemCount === 1 ? t('cartCountOne') : t('cartCountOther', { count: String(itemCount) }); return ( ); }