From bc65a3c7f9aed36b4236b3559d5e90884d5ed130 Mon Sep 17 00:00:00 2001 From: Stephanie Dietz <49788645+StephDietz@users.noreply.github.com> Date: Thu, 13 Jul 2023 15:24:56 -0500 Subject: [PATCH] Separate cart-icon into open-cart and close-cart (#1071) --- components/cart/close-cart.tsx | 10 ++++++++++ components/cart/modal.tsx | 7 ++++--- .../{icons/cart.tsx => cart/open-cart.tsx} | 18 ++++++------------ components/layout/navbar/index.tsx | 4 ++-- 4 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 components/cart/close-cart.tsx rename components/{icons/cart.tsx => cart/open-cart.tsx} (53%) diff --git a/components/cart/close-cart.tsx b/components/cart/close-cart.tsx new file mode 100644 index 000000000..b653ee044 --- /dev/null +++ b/components/cart/close-cart.tsx @@ -0,0 +1,10 @@ +import { XMarkIcon } from '@heroicons/react/24/outline'; +import clsx from 'clsx'; + +export default function CloseCart({ className }: { className?: string }) { + return ( +
+ +
+ ); +} diff --git a/components/cart/modal.tsx b/components/cart/modal.tsx index be2bbd78c..f07479d57 100644 --- a/components/cart/modal.tsx +++ b/components/cart/modal.tsx @@ -2,7 +2,6 @@ import { Dialog, Transition } from '@headlessui/react'; import { ShoppingCartIcon } from '@heroicons/react/24/outline'; -import CartIcon from 'components/icons/cart'; import Price from 'components/price'; import { DEFAULT_OPTION } from 'lib/constants'; import type { Cart } from 'lib/shopify/types'; @@ -11,8 +10,10 @@ import Image from 'next/image'; import Link from 'next/link'; import { Fragment, useEffect, useRef, useState } from 'react'; import { useCookies } from 'react-cookie'; +import CloseCart from './close-cart'; import DeleteItemButton from './delete-item-button'; import EditItemQuantityButton from './edit-item-quantity-button'; +import OpenCart from './open-cart'; type MerchandiseSearchParams = { [key: string]: string; @@ -52,7 +53,7 @@ export default function CartModal({ cart, cartIdUpdated }: { cart: Cart; cartIdU return ( <> @@ -81,7 +82,7 @@ export default function CartModal({ cart, cartIdUpdated }: { cart: Cart; cartIdU

My Cart

diff --git a/components/icons/cart.tsx b/components/cart/open-cart.tsx similarity index 53% rename from components/icons/cart.tsx rename to components/cart/open-cart.tsx index e2212627c..331ca4527 100644 --- a/components/icons/cart.tsx +++ b/components/cart/open-cart.tsx @@ -1,24 +1,18 @@ -import { ShoppingCartIcon, XMarkIcon } from '@heroicons/react/24/outline'; +import { ShoppingCartIcon } from '@heroicons/react/24/outline'; import clsx from 'clsx'; -export default function CartIcon({ +export default function OpenCart({ className, - quantity, - icon + quantity }: { className?: string; quantity?: number; - icon?: string; }) { return (
- {icon === 'close' ? ( - - ) : ( - - )} + {quantity ? (
diff --git a/components/layout/navbar/index.tsx b/components/layout/navbar/index.tsx index ba483a2cc..2ea9e3ce8 100644 --- a/components/layout/navbar/index.tsx +++ b/components/layout/navbar/index.tsx @@ -1,5 +1,5 @@ import Cart from 'components/cart'; -import CartIcon from 'components/icons/cart'; +import OpenCart from 'components/cart/open-cart'; import LogoSquare from 'components/logo-square'; import { getMenu } from 'lib/shopify'; import { Menu } from 'lib/shopify/types'; @@ -48,7 +48,7 @@ export default async function Navbar() {
- }> + }>