From 3d52b8497b17569642eef219705ff623c2544afd Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Sun, 14 Jun 2026 20:56:37 -0600 Subject: [PATCH] Update merch nav dropdown --- src/components/Navbar.tsx | 182 +++++++++++++++++++++++++++++++++++--- 1 file changed, 168 insertions(+), 14 deletions(-) diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 7016b360b..ea841fe13 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -27,7 +27,7 @@ import { Newspaper, Paintbrush, ShieldCheck, - Shirt, + ShoppingBag, Sparkles, TrendingUp, User, @@ -60,6 +60,9 @@ import { CollapsibleTrigger, } from '~/components/Collapsible' import { groupToSlug } from '~/components/stack/stack-categories' +import { getProducts } from '~/utils/shop.functions' +import { formatMoney, shopifyImageUrl } from '~/utils/shopify-format' +import type { ProductListItem } from '~/utils/shopify-queries' type LogoProps = { title?: React.ComponentType | null @@ -264,19 +267,8 @@ const NAV_GROUPS = [ { key: 'merch', label: 'Merch', - sections: [ - { - label: 'Shop', - items: [ - { - label: 'New Apparel', - to: '/merch', - description: 'TanStack shirts, hoodies, and new drops.', - icon: Shirt, - }, - ], - }, - ], + to: '/shop', + sections: [], }, { key: 'support', @@ -694,6 +686,9 @@ function DesktopNavTrigger({ group }: { group: NavMenuGroup }) { type="button" data-menu-key={group.key} className={triggerClassName} + onMouseDown={(event) => { + event.preventDefault() + }} > {group.label} @@ -786,6 +781,10 @@ function MegaMenuContent({ return } + if (group.key === 'merch') { + return + } + return (
void + variant: 'desktop' | 'mobile' +}) { + const [products, setProducts] = React.useState>([]) + const [loading, setLoading] = React.useState(true) + + React.useEffect(() => { + let cancelled = false + + async function loadProducts() { + setLoading(true) + + try { + const page = await getProducts({ + data: { + first: 3, + sortKey: 'CREATED_AT', + reverse: true, + }, + }) + + if (!cancelled) { + setProducts(page.nodes) + } + } catch { + if (!cancelled) { + setProducts([]) + } + } finally { + if (!cancelled) { + setLoading(false) + } + } + } + + loadProducts() + + return () => { + cancelled = true + } + }, []) + + const allMerchItem: NavMenuItem = { + label: 'All Merch', + to: '/shop', + description: 'Browse all TanStack apparel, accessories, and stickers.', + icon: ShoppingBag, + } + + return ( +
+
+
+ Recent Products +
+
+ {loading + ? Array.from({ length: 3 }, (_, index) => ( +
+ +
+ ) +} + +function MerchProductLink({ + product, + onNavigate, + variant, +}: { + product: ProductListItem + onNavigate: () => void + variant: 'desktop' | 'mobile' +}) { + const image = product.featuredImage + const price = product.priceRange.minVariantPrice + + return ( + + + {image ? ( + {image.altText + ) : ( + + + + )} + + + + {product.title} + + + {formatMoney(price.amount, price.currencyCode)} + + + + ) +} + function MenuRail({ rail, onNavigate,