diff --git a/app/components/header/desktop-header.tsx b/app/components/header/desktop-header.tsx index df1fcb4d..3bf5fb70 100644 --- a/app/components/header/desktop-header.tsx +++ b/app/components/header/desktop-header.tsx @@ -8,7 +8,6 @@ import { useThemeSettings } from "@weaverse/hydrogen"; import { cva } from "class-variance-authority"; import { Suspense } from "react"; import useWindowScroll from "react-use/esm/useWindowScroll"; -import { DialogDemo } from "~/components/drawer"; import { IconUser } from "~/components/icons"; import { Logo } from "~/components/logo"; import { cn } from "~/lib/cn"; @@ -73,7 +72,6 @@ export function DesktopHeader() {
- {/* */} {}} diff --git a/app/components/tooltip.tsx b/app/components/tooltip.tsx index 1e711623..6886a94e 100644 --- a/app/components/tooltip.tsx +++ b/app/components/tooltip.tsx @@ -30,7 +30,7 @@ export let TooltipContent = forwardRef( ref={ref} className={cn( "animate-slide-down-and-fade", - "z-50 px-4 rounded py-1 shadow-sm text-background bg-body", + "z-50 px-3 py-1 shadow-sm text-background bg-body", className, )} align="center" diff --git a/app/sections/collection-filters/filters.tsx b/app/sections/collection-filters/filters.tsx index c2282417..908e81a6 100644 --- a/app/sections/collection-filters/filters.tsx +++ b/app/sections/collection-filters/filters.tsx @@ -44,18 +44,22 @@ export function Filters({ className }: { className?: string }) { appliedFilters: AppliedFilter[]; } >(); + let appliedFiltersKeys = appliedFilters + .map((filter) => filter.label) + .join("-"); let filters = collection.products.filters as Filter[]; return ( filter.id) : []} > {filters.map((filter: Filter) => { let asColorSwatch = enableColorSwatch && COLORS_FILTERS.includes(filter.label); + let asButton = displayAsButtonFor.includes(filter.label); return (
{filter.values?.map((option) => { @@ -108,9 +113,15 @@ export function Filters({ className }: { className?: string }) { } default: return ( - name === option.label); let optionConf = options.find(({ name }) => { return name.toLowerCase() === option.label.toLowerCase(); @@ -179,6 +190,7 @@ function ListItemFilter({ shape, }), checked ? "p-1 border-line" : "border-line-subtle", + option.count === 0 && "diagonal", )} onClick={() => handleCheckedChange(!checked)} > @@ -195,37 +207,56 @@ function ListItemFilter({ - {showFiltersCount ? ( - - {option.label}{" "} - ({option.count}) - - ) : ( - option.label - )} + ); } + if (displayAs === "button") { + return ( + + ); + } + return ( - {option.label}{" "} - ({option.count}) - - ) : ( - option.label - ) + } + className={clsx(option.count === 0 && "line-through text-body-subtle")} /> ); } +function FilterLabel({ + option, + showFiltersCount, +}: { option: Filter["values"][0]; showFiltersCount: boolean }) { + if (showFiltersCount) { + return ( + + {option.label} ({option.count}) + + ); + } + return option.label; +} + // const PRICE_RANGE_FILTER_DEBOUNCE = 500; function PriceRangeFilter({ max, min }: { max?: number; min?: number }) { diff --git a/app/sections/collection-filters/products-pagination.tsx b/app/sections/collection-filters/products-pagination.tsx index 33897166..014d48b5 100644 --- a/app/sections/collection-filters/products-pagination.tsx +++ b/app/sections/collection-filters/products-pagination.tsx @@ -1,4 +1,10 @@ -import { useLoaderData, useNavigate } from "@remix-run/react"; +import { X } from "@phosphor-icons/react"; +import { + useLoaderData, + useLocation, + useNavigate, + useSearchParams, +} from "@remix-run/react"; import { Pagination } from "@shopify/hydrogen"; import clsx from "clsx"; import { useEffect } from "react"; @@ -6,6 +12,7 @@ import { useInView } from "react-intersection-observer"; import type { CollectionDetailsQuery } from "storefrontapi.generated"; import Link from "~/components/link"; import { getImageLoadingPriority } from "~/lib/const"; +import { getAppliedFilterLink, type AppliedFilter } from "~/lib/filter"; import { ProductCard } from "~/modules/product-card"; export function ProductsPagination({ @@ -19,58 +26,87 @@ export function ProductsPagination({ loadPrevText: string; loadMoreText: string; }) { - let { collection } = useLoaderData< + let { collection, appliedFilters } = useLoaderData< CollectionDetailsQuery & { collections: Array<{ handle: string; title: string }>; + appliedFilters: AppliedFilter[]; } >(); + let [params] = useSearchParams(); + let location = useLocation(); + let { pathname } = location; let { ref, inView } = useInView(); return ( - - {({ - nodes, - isLoading, - nextPageUrl, - previousPageUrl, - hasNextPage, - hasPreviousPage, - state, - }) => ( -
- {hasPreviousPage && ( - - {isLoading ? "Loading..." : loadPrevText} - - )} - - {hasNextPage && ( - - {isLoading ? "Loading..." : loadMoreText} - - )} +
+ {appliedFilters.length > 0 ? ( +
+
+ {appliedFilters.map((filter: AppliedFilter) => { + let { label } = filter; + return ( + + {label} + + + ); + })} +
+ + Clear all filters +
- )} - + ) : null} + + {({ + nodes, + isLoading, + nextPageUrl, + previousPageUrl, + hasNextPage, + hasPreviousPage, + state, + }) => ( +
+ {hasPreviousPage && ( + + {isLoading ? "Loading..." : loadPrevText} + + )} + + {hasNextPage && ( + + {isLoading ? "Loading..." : loadMoreText} + + )} +
+ )} +
+
); } diff --git a/app/sections/collection-filters/sort.tsx b/app/sections/collection-filters/sort.tsx index 6b444966..a58c33b9 100644 --- a/app/sections/collection-filters/sort.tsx +++ b/app/sections/collection-filters/sort.tsx @@ -1,6 +1,7 @@ -import { CaretDown } from "@phosphor-icons/react"; +import { CaretDown, CheckCircle } from "@phosphor-icons/react"; import * as DropdownMenu from "@radix-ui/react-dropdown-menu"; -import { Link, useLocation, useSearchParams } from "@remix-run/react"; +import { useLocation, useSearchParams } from "@remix-run/react"; +import Link from "~/components/link"; import { cn } from "~/lib/cn"; import type { SortParam } from "~/lib/filter"; @@ -68,7 +69,7 @@ export function Sort() { to={sortUrl} className={cn( "hover:underline underline-offset-[6px] hover:outline-none", - currentSortValue === key && "underline", + currentSortValue === key && "font-bold", )} > {label}