From 913e7a1809d961708bc93bb14e80414c8cec1f3f Mon Sep 17 00:00:00 2001 From: Chloe Date: Mon, 6 May 2024 17:02:10 +0700 Subject: [PATCH] feat: modify PLP layout Signed-off-by: Chloe --- app/globals.css | 6 -- app/search/[collection]/page.tsx | 51 ++++++++-- app/search/layout.tsx | 13 +-- components/breadcrumb/breadcrumb-home.tsx | 15 +++ components/breadcrumb/index.tsx | 39 +++++++- components/layout/navbar/index.tsx | 23 +---- components/layout/navbar/main-menu.tsx | 95 +++++++++++++++++++ components/layout/navbar/mobile-menu.tsx | 29 ++++-- components/layout/search/filters/index.tsx | 30 ++++++ .../layout/search/sorting-menu/index.tsx | 49 ++++++++++ .../layout/search/sorting-menu/item.tsx | 36 +++++++ tailwind.config.js | 1 + 12 files changed, 333 insertions(+), 54 deletions(-) create mode 100644 components/breadcrumb/breadcrumb-home.tsx create mode 100644 components/layout/navbar/main-menu.tsx create mode 100644 components/layout/search/filters/index.tsx create mode 100644 components/layout/search/sorting-menu/index.tsx create mode 100644 components/layout/search/sorting-menu/item.tsx diff --git a/app/globals.css b/app/globals.css index 0a6d36768..21bbc4a01 100644 --- a/app/globals.css +++ b/app/globals.css @@ -2,12 +2,6 @@ @tailwind components; @tailwind utilities; -@media (prefers-color-scheme: dark) { - html { - color-scheme: dark; - } -} - @supports (font: -apple-system-body) and (-webkit-appearance: none) { img[loading='lazy'] { clip-path: inset(0.6px); diff --git a/app/search/[collection]/page.tsx b/app/search/[collection]/page.tsx index 25416d544..181186fe4 100644 --- a/app/search/[collection]/page.tsx +++ b/app/search/[collection]/page.tsx @@ -2,9 +2,14 @@ import { getCollection, getCollectionProducts } from 'lib/shopify'; import { Metadata } from 'next'; import { notFound } from 'next/navigation'; +import Breadcrumb from 'components/breadcrumb'; +import BreadcrumbHome from 'components/breadcrumb/breadcrumb-home'; import Grid from 'components/grid'; import ProductGridItems from 'components/layout/product-grid-items'; +import Filters from 'components/layout/search/filters'; +import SortingMenu from 'components/layout/search/sorting-menu'; import { defaultSort, sorting } from 'lib/constants'; +import { Suspense } from 'react'; export const runtime = 'edge'; @@ -33,17 +38,43 @@ export default async function CategoryPage({ }) { const { sort } = searchParams as { [key: string]: string }; const { sortKey, reverse } = sorting.find((item) => item.slug === sort) || defaultSort; - const products = await getCollectionProducts({ collection: params.collection, sortKey, reverse }); + const productsData = getCollectionProducts({ collection: params.collection, sortKey, reverse }); + const collectionData = getCollection(params.collection); + + const [products, collection] = await Promise.all([productsData, collectionData]); return ( -
- {products.length === 0 ? ( -

{`No products found in this collection`}

- ) : ( - - - - )} -
+ <> +
+ }> + + +
+ {collection ? ( +
+

{collection.title}

+

{collection.description}

+
+ ) : null} +
+ +
+
+ {products.length === 0 ? ( +

{`No products found in this collection`}

+ ) : ( + + +
+ + + +
+
+ )} +
+ ); } diff --git a/app/search/layout.tsx b/app/search/layout.tsx index 011d41e8b..7bdb8cf47 100644 --- a/app/search/layout.tsx +++ b/app/search/layout.tsx @@ -1,21 +1,10 @@ import Footer from 'components/layout/footer'; -import Collections from 'components/layout/search/collections'; -import FilterList from 'components/layout/search/filter'; -import { sorting } from 'lib/constants'; import { Suspense } from 'react'; export default function SearchLayout({ children }: { children: React.ReactNode }) { return ( -
-
- -
-
{children}
-
- -
-
+
{children}