Skip to content

Commit 69bee5d

Browse files
Merge branch 'main' into main
2 parents fbd09df + c52c526 commit 69bee5d

16 files changed

Lines changed: 926 additions & 168 deletions

media/brand.sketch

-918 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"jszip": "^3.10.1",
8383
"lru-cache": "^11.2.7",
8484
"lucide-react": "^1.7.0",
85+
"maath": "^0.10.8",
8586
"match-sorter": "^8.2.0",
8687
"mermaid": "^11.14.0",
8788
"postgres": "^3.4.8",

pnpm-lock.yaml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/shop/shirt.glb

1020 KB
Binary file not shown.
Lines changed: 49 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
1-
import { useLocation } from '@tanstack/react-router'
1+
import { Link, useLocation } from '@tanstack/react-router'
22
import { ShoppingCart } from 'lucide-react'
33
import { twMerge } from 'tailwind-merge'
44
import { useCart } from '~/hooks/useCart'
55
import { useCartDrawerStore } from '~/components/shop/cartDrawerStore'
66

7+
const badgeClasses = twMerge(
8+
'absolute -top-1 -right-1 min-w-[1.125rem] h-[1.125rem] px-1',
9+
'flex items-center justify-center rounded-full',
10+
'text-[0.65rem] font-bold leading-none',
11+
'bg-black text-white dark:bg-white dark:text-black',
12+
)
13+
14+
const buttonClasses = twMerge(
15+
'relative flex items-center justify-center',
16+
'h-9 w-9 rounded-lg transition-colors',
17+
'hover:bg-gray-500/10 text-gray-700 dark:text-gray-300',
18+
)
19+
720
/**
821
* Cart button in the main Navbar.
922
*
10-
* Visibility rules:
23+
* Behaviour:
24+
* • On /shop/* routes → opens the cart drawer (drawer is mounted in
25+
* ShopLayout, so it exists on these routes)
26+
* • Everywhere else → navigates to /shop/cart (no drawer mounted
27+
* outside the shop, and full navigation is the right UX anyway)
28+
*
29+
* Visibility:
1130
* • Always visible on /shop/* routes (even at zero items)
1231
* • Site-wide when the cart has at least one item
1332
* • Hidden elsewhere when the cart is empty
14-
*
15-
* Click opens the global CartDrawer — no navigation, so the user keeps
16-
* their place in the docs or blog while reviewing their cart.
1733
*/
1834
export function NavbarCartButton() {
1935
const { pathname } = useLocation()
@@ -23,30 +39,35 @@ export function NavbarCartButton() {
2339

2440
if (!onShopRoute && totalQuantity === 0) return null
2541

42+
const badge =
43+
totalQuantity > 0 ? (
44+
<span className={badgeClasses}>
45+
{totalQuantity > 99 ? '99+' : totalQuantity}
46+
</span>
47+
) : null
48+
49+
const label = totalQuantity > 0 ? `Cart (${totalQuantity} items)` : 'Cart'
50+
51+
// On shop routes: open the drawer (it's mounted in ShopLayout)
52+
if (onShopRoute) {
53+
return (
54+
<button
55+
type="button"
56+
onClick={openDrawer}
57+
aria-label={label}
58+
className={buttonClasses}
59+
>
60+
<ShoppingCart className="w-4 h-4" />
61+
{badge}
62+
</button>
63+
)
64+
}
65+
66+
// Everywhere else: navigate to the cart page
2667
return (
27-
<button
28-
type="button"
29-
onClick={openDrawer}
30-
aria-label={totalQuantity > 0 ? `Cart (${totalQuantity} items)` : 'Cart'}
31-
className={twMerge(
32-
'relative flex items-center justify-center',
33-
'h-9 w-9 rounded-lg transition-colors',
34-
'hover:bg-gray-500/10 text-gray-700 dark:text-gray-300',
35-
)}
36-
>
68+
<Link to="/shop/cart" aria-label={label} className={buttonClasses}>
3769
<ShoppingCart className="w-4 h-4" />
38-
{totalQuantity > 0 ? (
39-
<span
40-
className={twMerge(
41-
'absolute -top-1 -right-1 min-w-[1.125rem] h-[1.125rem] px-1',
42-
'flex items-center justify-center rounded-full',
43-
'text-[0.65rem] font-bold leading-none',
44-
'bg-black text-white dark:bg-white dark:text-black',
45-
)}
46-
>
47-
{totalQuantity > 99 ? '99+' : totalQuantity}
48-
</span>
49-
) : null}
50-
</button>
70+
{badge}
71+
</Link>
5172
)
5273
}

src/components/shop/CartDrawer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ export function CartDrawer({ open, onOpenChange }: CartDrawerProps) {
2828
<Dialog.Portal>
2929
<Dialog.Overlay
3030
className={twMerge(
31-
'fixed inset-0 z-50 bg-black/40',
31+
'fixed inset-0 z-[100] bg-black/40',
3232
'data-[state=open]:animate-in data-[state=open]:fade-in-0',
3333
'data-[state=closed]:animate-out data-[state=closed]:fade-out-0',
3434
)}
3535
/>
3636
<Dialog.Content
3737
className={twMerge(
38-
'fixed right-0 top-0 bottom-0 z-50 w-full sm:max-w-md flex flex-col',
38+
'fixed right-0 top-0 bottom-0 z-[100] w-full sm:max-w-md flex flex-col',
3939
'bg-white dark:bg-gray-950 shadow-xl border-l border-gray-200 dark:border-gray-800',
4040
'data-[state=open]:animate-in data-[state=open]:slide-in-from-right',
4141
'data-[state=closed]:animate-out data-[state=closed]:slide-out-to-right',

0 commit comments

Comments
 (0)