From 77fcbc15965afc2d77782f7ee3f4bdecefd58f93 Mon Sep 17 00:00:00 2001 From: Binoy Patel Date: Fri, 16 Sep 2022 11:15:46 -0400 Subject: [PATCH] Update styles for product list --- packages/nextjs/components/Card.tsx | 9 +++++---- packages/nextjs/components/CategoryList.tsx | 5 ++--- packages/nextjs/components/ProductList.tsx | 14 +++++++------ packages/nextjs/pages/index.tsx | 22 ++------------------- 4 files changed, 17 insertions(+), 33 deletions(-) diff --git a/packages/nextjs/components/Card.tsx b/packages/nextjs/components/Card.tsx index 7af4d3df..ced11598 100644 --- a/packages/nextjs/components/Card.tsx +++ b/packages/nextjs/components/Card.tsx @@ -5,8 +5,8 @@ import { Image } from "./Image"; interface Props { title: string; - price: string | number; - children: React.ReactNode; + price?: string | number; + subTitle?: string; to: string; className?: string; imageProps: { @@ -15,13 +15,14 @@ interface Props { }; } -export const Card: React.FC = ({ to, children, title, price, imageProps, className = "" }) => { +export const Card: React.FC = ({ to, subTitle, title, price, imageProps, className = "" }) => { return ( {imageProps.alt}

{title}

- ${price} + {price && ${price}} + {subTitle && {subTitle}}
); diff --git a/packages/nextjs/components/CategoryList.tsx b/packages/nextjs/components/CategoryList.tsx index 37220340..de77cc72 100644 --- a/packages/nextjs/components/CategoryList.tsx +++ b/packages/nextjs/components/CategoryList.tsx @@ -18,9 +18,8 @@ export const CategoryList = ({ items }: CategoryListProps) => { src: category.images?.[0]?.images ?? "", alt: category.images?.[0]?.name ?? "", }} - > - {category.name} - + title={category.name ?? ""} + /> ))} diff --git a/packages/nextjs/components/ProductList.tsx b/packages/nextjs/components/ProductList.tsx index bacf9a83..e4d6f915 100644 --- a/packages/nextjs/components/ProductList.tsx +++ b/packages/nextjs/components/ProductList.tsx @@ -9,18 +9,20 @@ export const ProductList = ({ items }: Props) => { if (!items) return null; return ( -
    - {items.map((product) => ( -
  • +
      + {items.map((product, i) => ( +
    • - {product.name} - + />
    • ))}
    diff --git a/packages/nextjs/pages/index.tsx b/packages/nextjs/pages/index.tsx index 8b277ebd..a9b05a93 100644 --- a/packages/nextjs/pages/index.tsx +++ b/packages/nextjs/pages/index.tsx @@ -6,7 +6,7 @@ import { setCachingHeaders } from "utils/setCachingHeaders"; import { SanityType } from "utils/consts"; import { Button } from "components/Button"; import { FiArrowRight } from "react-icons/fi"; -import { Card } from "components/Card"; +import { ProductList } from "components/ProductList"; const Home: NextPage = () => { const [{ data }] = useGetProductsAndCategoriesQuery(); @@ -25,25 +25,7 @@ const Home: NextPage = () => {

    Our bestsellers

    -
    - {data?.allProduct.map((product, i) => ( - <> - -

    {product.name}

    -
    - {i !== data.allProduct.length - 1 && } - - ))} -
    +