Skip to content

Commit 001f922

Browse files
committed
Merge main and reconcile Themivo with responsive Quickview layouts
2 parents 9249ec2 + 8bad38c commit 001f922

31 files changed

Lines changed: 502 additions & 104 deletions

‎app/components/cart/cart-best-sellers.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,12 @@ export function CartBestSellers({
187187
products={products}
188188
/>
189189
</div>
190-
<div className="flex justify-center gap-2">
190+
<div className="flex select-none justify-center gap-2">
191191
<ArrowButton
192192
type="button"
193193
onClick={() => scrollRail(-1)}
194194
disabled={!canScroll.previous}
195-
className="disabled:pointer-events-none disabled:text-(--color-text-light)"
195+
className="disabled:text-(--color-text-light)"
196196
tone="neutral"
197197
aria-label={t("product.previousRecommendations")}
198198
>
@@ -202,7 +202,7 @@ export function CartBestSellers({
202202
type="button"
203203
onClick={() => scrollRail(1)}
204204
disabled={!canScroll.next}
205-
className="disabled:pointer-events-none disabled:text-(--color-text-light)"
205+
className="disabled:text-(--color-text-light)"
206206
tone="neutral"
207207
aria-label={t("product.nextRecommendations")}
208208
>

‎app/components/layout/desktop-menu.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Link from "~/components/link";
99
import { useHeaderMenu } from "~/hooks/use-header-menu";
1010
import { useLocale } from "~/hooks/use-locale";
1111
import type { SingleMenuItem } from "~/types/menu";
12+
import { MEDIA_NAVBAR_DESKTOP } from "~/utils/breakpoints";
1213
import { cn } from "~/utils/cn";
1314
import { navigateToMenuItem } from "~/utils/menu-navigation";
1415

@@ -41,7 +42,7 @@ export function DesktopMenu() {
4142
}, [location.key]);
4243

4344
useEffect(() => {
44-
const desktop = window.matchMedia("(min-width: 1280px)");
45+
const desktop = window.matchMedia(MEDIA_NAVBAR_DESKTOP);
4546
const closeOnCompact = () => {
4647
if (!desktop.matches) {
4748
setValue("");
@@ -61,7 +62,7 @@ export function DesktopMenu() {
6162
skipDelayDuration={300}
6263
value={value}
6364
onValueChange={setValue}
64-
className="hidden h-full xl:flex"
65+
className="hidden h-full navbar:flex"
6566
>
6667
<NavigationMenu.List className="flex h-full items-center justify-center gap-8 pt-1">
6768
{menuItems.map((menuItem) => {

‎app/components/layout/header.tsx‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ const variants = cva("", {
3232
},
3333
padding: {
3434
full: "",
35-
stretch: "px-4 md:px-8 xl:px-10",
36-
fixed: "mx-auto px-4 md:px-8 xl:px-10",
35+
stretch: "px-4 md:px-8 navbar:px-8 lg:px-10",
36+
fixed: "mx-auto px-4 md:px-8 navbar:px-8 lg:px-10",
3737
},
3838
},
3939
});
@@ -80,11 +80,11 @@ export function Header() {
8080
"bg-(--color-header-bg) hover:bg-(--color-header-bg-hover)",
8181
"text-(--color-header-text) hover:text-(--color-header-text)",
8282
"border-line-subtle border-b",
83-
designSystemPreset !== "custom" && "max-desktop:h-(--height-nav)",
83+
designSystemPreset !== "custom" && "max-navbar:h-(--height-nav)",
8484
variants({ padding: headerWidth }),
8585
designSystemPreset !== "custom" &&
8686
headerWidth !== "full" &&
87-
"sm:max-desktop:px-8",
87+
"sm:max-navbar:px-8",
8888
scrolled ? "shadow-none" : "shadow-none",
8989
headerPosition,
9090
isTransparent
@@ -109,15 +109,15 @@ export function Header() {
109109
<div
110110
className={cn(
111111
"grid grid-cols-[1fr_auto_1fr] items-center",
112-
designSystemPreset !== "custom" && "max-desktop:gap-x-2.5",
112+
designSystemPreset !== "custom" && "max-navbar:gap-x-2.5",
113113
variants({ width: headerWidth }),
114-
designSystemPreset !== "custom" && "max-desktop:h-full",
114+
designSystemPreset !== "custom" && "max-navbar:h-full",
115115
)}
116116
>
117117
<div
118118
className={cn(
119119
"col-start-1 row-start-1 flex items-center gap-4 justify-self-start",
120-
!isCompactDesktop && "xl:hidden",
120+
!isCompactDesktop && "navbar:hidden",
121121
)}
122122
>
123123
<MobileMenu showOnDesktop={isCompactDesktop} />
@@ -130,14 +130,14 @@ export function Header() {
130130
<div
131131
className={cn(
132132
"col-start-2 row-start-1 flex items-center justify-self-center",
133-
!isCompactDesktop && "xl:col-start-1 xl:justify-self-start",
133+
!isCompactDesktop && "navbar:col-start-1 navbar:justify-self-start",
134134
)}
135135
>
136136
<Logo />
137137
</div>
138138

139139
{!isCompactDesktop ? (
140-
<div className="col-start-2 row-start-1 hidden h-full justify-self-center xl:block">
140+
<div className="col-start-2 row-start-1 hidden h-full justify-self-center navbar:block">
141141
<DesktopMenu />
142142
</div>
143143
) : null}

‎app/components/layout/mobile-menu.tsx‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ import * as Collapsible from "@radix-ui/react-collapsible";
88
import * as Dialog from "@radix-ui/react-dialog";
99
import { useTranslation } from "@weaverse/hydrogen";
1010
import { AnimatePresence, motion, useReducedMotion } from "framer-motion";
11-
import { type Ref, useRef, useState } from "react";
11+
import { type Ref, useEffect, useRef, useState } from "react";
1212
import { Image } from "~/components/image";
1313
import Link from "~/components/link";
1414
import { useHeaderMenu } from "~/hooks/use-header-menu";
1515
import type { SingleMenuItem } from "~/types/menu";
16+
import { MEDIA_NAVBAR_DESKTOP } from "~/utils/breakpoints";
1617
import { cn } from "~/utils/cn";
1718

1819
type HeaderMenuItem = ReturnType<typeof useHeaderMenu>[number];
@@ -31,9 +32,20 @@ export function MobileMenu({
3132
);
3233
const [open, setOpen] = useState(false);
3334

35+
useEffect(() => {
36+
const desktop = window.matchMedia(MEDIA_NAVBAR_DESKTOP);
37+
const closeOnDesktop = () => {
38+
if (desktop.matches && !showOnDesktop) {
39+
setOpen(false);
40+
}
41+
};
42+
desktop.addEventListener("change", closeOnDesktop);
43+
return () => desktop.removeEventListener("change", closeOnDesktop);
44+
}, [showOnDesktop]);
45+
3446
const triggerClassName = cn(
3547
"relative size-5 items-center justify-center focus-visible:outline-hidden before:absolute before:-inset-2",
36-
showOnDesktop ? "flex" : "flex xl:hidden",
48+
showOnDesktop ? "flex" : "flex navbar:hidden",
3749
);
3850

3951
if (!menuItems.length) {

‎app/components/layout/predictive-search/PopularSearch.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function PopularSearch({
7373
>
7474
<span
7575
className={cn(
76-
"font-semibold text-xs uppercase tracking-[0.02em]",
76+
"font-body font-semibold text-sm uppercase leading-[1.6] tracking-[0.02em] text-body-subtle",
7777
headingClassName,
7878
)}
7979
>

‎app/components/layout/predictive-search/search-desktop/index.tsx‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import Link from "~/components/link";
1616
import { usePredictiveSearch } from "~/hooks/use-predictive-search";
1717
import { usePrefixPathWithLocale } from "~/hooks/use-prefix-path-with-locale";
1818
import type { NormalizedPredictiveSearchResultItem } from "~/types/predictive-search";
19+
import { MEDIA_NAVBAR_DESKTOP } from "~/utils/breakpoints";
1920
import { PopularSearch } from "../PopularSearch";
2021
import { withPinnedCollections } from "../pinned-collections";
2122
import { PredictiveSearchForm } from "../search-form";
@@ -59,6 +60,20 @@ export function PredictiveSearchButtonDesktop({ setIsSearchOpen }) {
5960
// oxlint-disable-next-line react/exhaustive-deps -- close the dialog after navigation
6061
}, [location]);
6162

63+
useEffect(() => {
64+
const desktop = window.matchMedia(MEDIA_NAVBAR_DESKTOP);
65+
const closeOnModeChange = () => {
66+
if (!desktop.matches) {
67+
setOpen(false);
68+
setIsSearchOpen(false);
69+
resetSearchState();
70+
}
71+
};
72+
desktop.addEventListener("change", closeOnModeChange);
73+
return () => desktop.removeEventListener("change", closeOnModeChange);
74+
// oxlint-disable-next-line react/exhaustive-deps -- reset only when crossing the navbar boundary
75+
}, [setIsSearchOpen]);
76+
6277
function clearSearchDebounce() {
6378
if (debounceRef.current) {
6479
clearTimeout(debounceRef.current);
@@ -99,7 +114,7 @@ export function PredictiveSearchButtonDesktop({ setIsSearchOpen }) {
99114
>
100115
<Dialog.Trigger
101116
asChild
102-
className="relative hidden size-5 items-center justify-center focus-visible:outline-hidden before:absolute before:-inset-2 xl:flex"
117+
className="relative hidden size-5 items-center justify-center focus-visible:outline-hidden before:absolute before:-inset-2 navbar:flex"
103118
>
104119
<button type="button" aria-label={t("accessibility.openSearch")}>
105120
<MagnifyingGlassIcon aria-hidden="true" className="size-5" />
@@ -236,8 +251,8 @@ export function PredictiveSearchButtonDesktop({ setIsSearchOpen }) {
236251
{!(hasSearched || loading) && (
237252
<div className="py-7">
238253
<PopularSearch
239-
className="mx-0 w-[258px] max-w-full pb-6"
240-
headingClassName="flex h-7 w-full items-start gap-2 self-stretch border-[#D8D8D8] border-b"
254+
className="mx-0 w-[258px] max-w-full gap-5 pb-6"
255+
headingClassName="block w-full"
241256
itemClassName="font-normal text-sm tracking-[0.01em]"
242257
useSearchHistory
243258
/>

‎app/components/layout/predictive-search/search-mobile/index.tsx‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { useLocation, useNavigate } from "react-router";
99
import Link from "~/components/link";
1010
import { usePredictiveSearch } from "~/hooks/use-predictive-search";
1111
import { usePrefixPathWithLocale } from "~/hooks/use-prefix-path-with-locale";
12+
import { MEDIA_NAVBAR_DESKTOP } from "~/utils/breakpoints";
1213
import { PopularSearch } from "../PopularSearch";
1314
import { withPinnedCollections } from "../pinned-collections";
1415
import { PredictiveSearchForm } from "../search-form";
@@ -32,6 +33,20 @@ export function PredictiveSearchButtonMobile({ setIsSearchOpen }) {
3233
// oxlint-disable-next-line react/exhaustive-deps -- close the dialog after navigation
3334
}, [location]);
3435

36+
useEffect(() => {
37+
const desktop = window.matchMedia(MEDIA_NAVBAR_DESKTOP);
38+
const closeOnModeChange = () => {
39+
if (desktop.matches) {
40+
setOpen(false);
41+
setIsSearchOpen(false);
42+
resetSearchState();
43+
}
44+
};
45+
desktop.addEventListener("change", closeOnModeChange);
46+
return () => desktop.removeEventListener("change", closeOnModeChange);
47+
// oxlint-disable-next-line react/exhaustive-deps -- reset only when crossing the navbar boundary
48+
}, [setIsSearchOpen]);
49+
3550
function resetSearchState() {
3651
if (debounceRef.current) {
3752
clearTimeout(debounceRef.current);
@@ -63,7 +78,7 @@ export function PredictiveSearchButtonMobile({ setIsSearchOpen }) {
6378
>
6479
<Dialog.Trigger
6580
asChild
66-
className="relative flex size-5 items-center justify-center focus-visible:outline-none before:absolute before:-inset-2 xl:hidden"
81+
className="relative flex size-5 items-center justify-center focus-visible:outline-none before:absolute before:-inset-2 navbar:hidden"
6782
>
6883
<button type="button" aria-label={t("accessibility.openSearch")}>
6984
<MagnifyingGlass aria-hidden="true" className="size-5" />
@@ -192,7 +207,7 @@ export function PredictiveSearchButtonMobile({ setIsSearchOpen }) {
192207
{!hasSearched && !loading ? (
193208
<PopularSearch
194209
className="mx-0 w-full max-w-none"
195-
headingClassName="block w-full border-[#D8D8D8] border-b pb-[11px] font-body font-semibold text-[14px] uppercase leading-[160%] tracking-[0.28px] text-[var(--color-text-subtle,#524B46)]"
210+
headingClassName="block w-full pb-[11px]"
196211
itemClassName="font-normal text-sm"
197212
/>
198213
) : loading ? (

‎app/components/product/product-media.tsx‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ export function ProductMedia(props: ProductMediaProps) {
422422
navigationVariant === "quick-shop" &&
423423
"ml-[12.5px] size-12 !rounded-xl !border-transparent !bg-white/80 p-3 !text-body",
424424
navigationVariant !== "quick-shop" && shapeClass(arrowsShape),
425+
navigationVariant === "product-page" &&
426+
navigationStyle === "sides" &&
427+
"max-lg:bg-white/80!",
425428
)}
426429
aria-label={t("product.previousMedia")}
427430
>
@@ -455,6 +458,9 @@ export function ProductMedia(props: ProductMediaProps) {
455458
navigationVariant === "quick-shop" &&
456459
"mr-[12.5px] size-12 !rounded-xl !border-transparent !bg-white/80 p-3 !text-body",
457460
navigationVariant !== "quick-shop" && shapeClass(arrowsShape),
461+
navigationVariant === "product-page" &&
462+
navigationStyle === "sides" &&
463+
"max-lg:bg-white/80!",
458464
)}
459465
aria-label={t("product.nextMedia")}
460466
>

‎app/components/product/quick-shop-frame.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { useEffect, useState } from "react";
22
import { MEDIA_MOBILE } from "~/utils/breakpoints";
33

44
// Mobile Quick View keeps the page visible around a centered, scrollable panel.
5-
// Inline gutters use the spacing scale; the height is relative to the viewport.
5+
// Match the 400 × 872 design while leaving room around shorter viewports.
66
export const QUICK_SHOP_MOBILE_FRAME_CLASS =
7-
"left-4 right-[calc(var(--spacing)*4+var(--quick-view-locked-gap,0px))] top-1/2 h-[75dvh] -translate-y-1/2";
7+
"left-[calc((100%-var(--quick-view-locked-gap,0px))/2)] top-1/2 h-[calc(100dvh-var(--spacing)*8)] max-h-[872px] w-[calc(100%-var(--quick-view-locked-gap,0px)-var(--spacing)*8)] max-w-[400px] -translate-x-1/2 -translate-y-1/2";
88

99
export const QUICK_SHOP_DESKTOP_FRAME_CLASS =
10-
"top-1/2 left-[calc((100%-var(--quick-view-locked-gap,0px))/2)] w-[calc(100%-var(--quick-view-locked-gap,0px)-48px)] max-w-[1375px] -translate-x-1/2 -translate-y-1/2";
10+
"top-1/2 left-[calc((100%-var(--quick-view-locked-gap,0px))/2)] w-[calc(100%-var(--quick-view-locked-gap,0px)-var(--spacing)*12)] max-w-[801px] lg:max-w-[1375px] -translate-x-1/2 -translate-y-1/2";
1111

1212
export const QUICK_SHOP_DESKTOP_SURFACE_CLASS =
13-
"relative max-h-[calc(100dvh-48px)] w-full overflow-y-auto rounded-xl bg-background p-6";
13+
"relative h-[min(783px,calc(100dvh-var(--spacing)*12))] max-h-[calc(100dvh-var(--spacing)*12)] w-full overflow-y-auto rounded-xl bg-background p-6 lg:h-auto";
1414

1515
export const QUICK_SHOP_MOBILE_SURFACE_CLASS =
1616
"h-full w-full overflow-hidden rounded-(--radius-md) bg-background";

‎app/components/product/quick-shop.tsx‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,19 @@ export function QuickShop({
186186
productTitle={product.title}
187187
onImage
188188
useAspenAppearance={useAspenImageAppearance}
189-
className={clsx("absolute z-20", imagePosition)}
189+
className={clsx(
190+
"absolute z-20",
191+
imagePosition,
192+
useAspenImageAppearance && "max-md:right-9",
193+
)}
190194
/>
191195
)}
192196
</div>
193197

194198
<div
195199
className={clsx(
196200
"flex min-w-0 flex-col text-sm",
197-
isDesktop ? "gap-8" : "gap-6",
201+
isDesktop ? "gap-6 lg:gap-8" : "gap-6",
198202
)}
199203
>
200204
<div className="flex flex-col gap-4">
@@ -226,7 +230,12 @@ export function QuickShop({
226230
quantityAvailable={selectedVariant?.quantityAvailable}
227231
/>
228232

229-
<div className={clsx("flex flex-col", isDesktop ? "gap-7" : "gap-6")}>
233+
<div
234+
className={clsx(
235+
"flex flex-col",
236+
isDesktop ? "gap-6 lg:gap-7" : "gap-6",
237+
)}
238+
>
230239
{productOptions && productOptions.length > 0 && (
231240
<QuickShopVariants
232241
productOptions={productOptions}
@@ -519,13 +528,13 @@ export function QuickShopTrigger({
519528
type="button"
520529
onClick={closeAllDrawers}
521530
aria-label={t("product.closeQuickShop")}
522-
className="absolute top-4 right-5 z-30 flex size-5 items-center justify-center"
531+
className="absolute top-1 right-2 z-30 flex size-11 items-center justify-center"
523532
>
524533
<XIcon className="size-5" />
525534
</button>
526535

527536
<ScrollArea rootClassName="min-h-0 flex-1" size="sm">
528-
<div className="px-5 pt-10 pb-8">
537+
<div className="p-5">
529538
{productLoading ? (
530539
<QuickShopSkeleton />
531540
) : data ? (

0 commit comments

Comments
 (0)