+
+
+
+ )}
+
+
+ );
+}
diff --git a/app/components/header/desktop-header.tsx b/app/components/header/desktop-header.tsx
index 3bf5fb70..2146924f 100644
--- a/app/components/header/desktop-header.tsx
+++ b/app/components/header/desktop-header.tsx
@@ -13,9 +13,9 @@ import { Logo } from "~/components/logo";
import { cn } from "~/lib/cn";
import { useIsHomePath } from "~/lib/utils";
import type { RootLoader } from "~/root";
+import { CartDrawer } from "./cart-drawer";
import { DesktopMenu } from "./menu/desktop-menu";
import { PredictiveSearchButton } from "./predictive-search";
-import { CartCount } from "./cart-count";
let variants = cva("", {
variants: {
@@ -72,11 +72,7 @@ export function DesktopHeader() {
- {}}
- isTransparent={isTransparent}
- />
+
diff --git a/app/components/header/index.tsx b/app/components/header/index.tsx
index 33f5e605..e70e7004 100644
--- a/app/components/header/index.tsx
+++ b/app/components/header/index.tsx
@@ -1,21 +1,13 @@
-import { Await, useRouteLoaderData } from "@remix-run/react";
-import { CartForm, type CartReturn } from "@shopify/hydrogen";
-import { Suspense, useEffect } from "react";
+import { CartForm } from "@shopify/hydrogen";
+import { useEffect } from "react";
import { useCartFetchers } from "~/hooks/use-cart-fetchers";
-import { Cart } from "~/modules/cart";
-import type { RootLoader } from "~/root";
-import { CartLoading } from "../../modules/cart-loading";
-import { Drawer, useDrawer } from "../../modules/drawer";
+import { useDrawer } from "../../modules/drawer";
import { DesktopHeader } from "./desktop-header";
import { MobileHeader } from "./mobile-header";
import { ScrollingAnnouncement } from "./scrolling-announcement";
export function Header() {
- let {
- isOpen: isCartOpen,
- openDrawer: openCart,
- closeDrawer: closeCart,
- } = useDrawer();
+ let { isOpen: isCartOpen, openDrawer: openCart } = useDrawer();
let addToCartFetchers = useCartFetchers(CartForm.ACTIONS.LinesAdd);
// toggle cart drawer when adding to cart
@@ -26,38 +18,9 @@ export function Header() {
return (
<>
- {/* */}
-
+
>
);
}
-
-function CartDrawer({
- isOpen,
- onClose,
-}: {
- isOpen: boolean;
- onClose: () => void;
-}) {
- const rootData = useRouteLoaderData("root");
-
- return (
-
-
- }>
-
- {(cart) => (
-
- )}
-
-
-
-
- );
-}
diff --git a/app/components/header/menu/mobile-menu.tsx b/app/components/header/menu/mobile-menu.tsx
index 2c846322..08855fa1 100644
--- a/app/components/header/menu/mobile-menu.tsx
+++ b/app/components/header/menu/mobile-menu.tsx
@@ -1,7 +1,6 @@
import { CaretRight, List, X } from "@phosphor-icons/react";
import * as Collapsible from "@radix-ui/react-collapsible";
import * as Dialog from "@radix-ui/react-dialog";
-import * as VisuallyHidden from "@radix-ui/react-visually-hidden";
import { forwardRef } from "react";
import Link from "~/components/link";
import { ScrollArea } from "~/components/scroll-area";
@@ -39,13 +38,12 @@ export function MobileMenu() {
}
aria-describedby={undefined}
>
-
- Mobile menu
-
+
+
Menu
+
-
Menu
diff --git a/app/components/header/mobile-header.tsx b/app/components/header/mobile-header.tsx
index abea793b..293f3ae7 100644
--- a/app/components/header/mobile-header.tsx
+++ b/app/components/header/mobile-header.tsx
@@ -13,14 +13,10 @@ import { Logo } from "~/components/logo";
import { cn } from "~/lib/cn";
import { useIsHomePath } from "~/lib/utils";
import type { RootLoader } from "~/root";
-import { CartCount } from "./cart-count";
+import { CartDrawer } from "./cart-drawer";
import { MobileMenu } from "./menu/mobile-menu";
-export function MobileHeader({
- openCart,
-}: {
- openCart: () => void;
-}) {
+export function MobileHeader() {
let isHome = useIsHomePath();
let { enableTransparentHeader } = useThemeSettings();
let { y } = useWindowScroll();
@@ -65,11 +61,7 @@ export function MobileHeader({
-
+
);
diff --git a/app/data/cache.ts b/app/data/cache.ts
index 18cf198e..dd6dc591 100644
--- a/app/data/cache.ts
+++ b/app/data/cache.ts
@@ -7,7 +7,7 @@ import {
export function routeHeaders({ loaderHeaders }: { loaderHeaders: Headers }) {
// Keep the same cache-control headers when loading the page directly
- // versus when transititioning to the page from other areas in the app
+ // versus when transitioning to the page from other areas in the app
return {
"Cache-Control": loaderHeaders.get("Cache-Control"),
};
diff --git a/app/data/fragments.ts b/app/data/fragments.ts
index 87294b4c..6012066c 100644
--- a/app/data/fragments.ts
+++ b/app/data/fragments.ts
@@ -44,6 +44,16 @@ export const PRODUCT_CARD_FRAGMENT = `#graphql
publishedAt
handle
vendor
+ priceRange {
+ minVariantPrice {
+ amount
+ currencyCode
+ }
+ maxVariantPrice {
+ amount
+ currencyCode
+ }
+ }
variants(first: 10) {
nodes {
id
diff --git a/app/data/queries.ts b/app/data/queries.ts
index f86712e0..ec8d112d 100644
--- a/app/data/queries.ts
+++ b/app/data/queries.ts
@@ -207,6 +207,40 @@ export let COLLECTION_QUERY = `#graphql
startCursor
}
}
+ highestPriceProduct: products(first: 1, sortKey: PRICE, reverse: true) {
+ nodes {
+ id
+ title
+ handle
+ priceRange {
+ minVariantPrice {
+ amount
+ currencyCode
+ }
+ maxVariantPrice {
+ amount
+ currencyCode
+ }
+ }
+ }
+ }
+ lowestPriceProduct: products(first: 1, sortKey: PRICE) {
+ nodes {
+ id
+ title
+ handle
+ priceRange {
+ minVariantPrice {
+ amount
+ currencyCode
+ }
+ maxVariantPrice {
+ amount
+ currencyCode
+ }
+ }
+ }
+ }
}
collections(first: 100) {
edges {
diff --git a/app/hooks/use-closest-weaverse-item.ts b/app/hooks/use-closest-weaverse-item.ts
index 69657a91..943b9435 100644
--- a/app/hooks/use-closest-weaverse-item.ts
+++ b/app/hooks/use-closest-weaverse-item.ts
@@ -5,7 +5,7 @@ export function useClosestWeaverseItem(selector: string) {
let [weaverseId, setWeaverseId] = useState("");
let weaverseItem = useItemInstance(weaverseId);
- // biome-ignore lint/correctness/useExhaustiveDependencies:
+ // biome-ignore lint/correctness/useExhaustiveDependencies: assuming `selector` does not change
useEffect(() => {
if (!weaverseItem) {
let target = document.querySelector(selector);
diff --git a/app/lib/collections.ts b/app/lib/collections.ts
new file mode 100644
index 00000000..9ce69223
--- /dev/null
+++ b/app/lib/collections.ts
@@ -0,0 +1,42 @@
+import type { ProductCollectionSortKeys } from "@shopify/hydrogen/storefront-api-types";
+import type { SortParam } from "~/modules/sort-filter";
+
+export let getSortValuesFromParam = (
+ sortParam: SortParam | null,
+): {
+ sortKey: ProductCollectionSortKeys;
+ reverse: boolean;
+} => {
+ switch (sortParam) {
+ case "price-high-low":
+ return {
+ sortKey: "PRICE",
+ reverse: true,
+ };
+ case "price-low-high":
+ return {
+ sortKey: "PRICE",
+ reverse: false,
+ };
+ case "best-selling":
+ return {
+ sortKey: "BEST_SELLING",
+ reverse: false,
+ };
+ case "newest":
+ return {
+ sortKey: "CREATED",
+ reverse: true,
+ };
+ case "featured":
+ return {
+ sortKey: "MANUAL",
+ reverse: false,
+ };
+ default:
+ return {
+ sortKey: "RELEVANCE",
+ reverse: false,
+ };
+ }
+};
diff --git a/app/lib/filter.ts b/app/lib/filter.ts
index 788e0442..67613578 100644
--- a/app/lib/filter.ts
+++ b/app/lib/filter.ts
@@ -28,35 +28,34 @@ export function getAppliedFilterLink(
}
export function getFilterLink(
- rawInput: string | ProductFilter,
+ input: string | ProductFilter,
params: URLSearchParams,
location: ReturnType,
) {
- const paramsClone = new URLSearchParams(params);
- const newParams = filterInputToParams(rawInput, paramsClone);
+ let newParams = filterInputToParams(input, new URLSearchParams(params));
return `${location.pathname}?${newParams.toString()}`;
}
export function filterInputToParams(
- rawInput: string | ProductFilter,
+ input: string | ProductFilter,
params: URLSearchParams,
) {
- const input =
- typeof rawInput === "string"
- ? (JSON.parse(rawInput) as ProductFilter)
- : rawInput;
+ let filter =
+ typeof input === "string" ? (JSON.parse(input) as ProductFilter) : input;
- Object.entries(input).forEach(([key, value]) => {
- if (params.has(`${FILTER_URL_PREFIX}${key}`, JSON.stringify(value))) {
- return;
+ for (let [k, v] of Object.entries(filter)) {
+ let key = `${FILTER_URL_PREFIX}${k}`;
+ let value = JSON.stringify(v);
+ if (params.has(key, value)) {
+ return params;
}
- if (key === "price") {
+ if (k === "price") {
// For price, we want to overwrite
- params.set(`${FILTER_URL_PREFIX}${key}`, JSON.stringify(value));
+ params.set(key, value);
} else {
- params.append(`${FILTER_URL_PREFIX}${key}`, JSON.stringify(value));
+ params.append(key, value);
}
- });
+ }
return params;
}
diff --git a/app/modules/cart.tsx b/app/modules/cart.tsx
index fc9c1b16..1818f2eb 100644
--- a/app/modules/cart.tsx
+++ b/app/modules/cart.tsx
@@ -55,7 +55,7 @@ export function CartDetails({