begin modal ui edits

This commit is contained in:
StephDietz 2023-07-06 20:22:38 -05:00
parent 1918c25f4a
commit 6c373ad58a
8 changed files with 813 additions and 835 deletions

View File

@ -3,9 +3,9 @@ import LoadingDots from 'components/loading-dots';
import { useRouter } from 'next/navigation'; import { useRouter } from 'next/navigation';
import clsx from 'clsx'; import clsx from 'clsx';
import { removeItem } from 'components/cart/actions';
import type { CartItem } from 'lib/shopify/types'; import type { CartItem } from 'lib/shopify/types';
import { useTransition } from 'react'; import { useTransition } from 'react';
import { removeItem } from 'components/cart/actions';
export default function DeleteItemButton({ item }: { item: CartItem }) { export default function DeleteItemButton({ item }: { item: CartItem }) {
const router = useRouter(); const router = useRouter();
@ -28,7 +28,7 @@ export default function DeleteItemButton({ item }: { item: CartItem }) {
}} }}
disabled={isPending} disabled={isPending}
className={clsx( className={clsx(
'ease flex min-w-[36px] max-w-[36px] items-center justify-center border px-2 transition-all duration-200 hover:border-gray-800 hover:bg-gray-100 dark:border-gray-700 dark:hover:border-gray-600 dark:hover:bg-gray-900', 'ease flex h-4 w-4 items-center justify-center rounded-full bg-base-gray-900 transition-all duration-200 ',
{ {
'cursor-not-allowed px-0': isPending 'cursor-not-allowed px-0': isPending
} }
@ -37,7 +37,7 @@ export default function DeleteItemButton({ item }: { item: CartItem }) {
{isPending ? ( {isPending ? (
<LoadingDots className="bg-black dark:bg-white" /> <LoadingDots className="bg-black dark:bg-white" />
) : ( ) : (
<CloseIcon className="hover:text-accent-3 mx-[1px] h-4 w-4" /> <CloseIcon className="hover:text-accent-3 mx-[1px] h-4 w-4 text-black " />
)} )}
</button> </button>
); );

View File

@ -42,7 +42,7 @@ export default function EditItemQuantityButton({
}} }}
disabled={isPending} disabled={isPending}
className={clsx( className={clsx(
'ease flex min-w-[36px] max-w-[36px] items-center justify-center border px-2 transition-all duration-200 hover:border-gray-800 hover:bg-gray-100 dark:border-gray-700 dark:hover:border-gray-600 dark:hover:bg-gray-900', 'ease flex h-full min-w-[36px] max-w-[36px] flex-none items-center justify-center rounded-full px-2 transition-all duration-200 hover:border-gray-800 hover:opacity-80',
{ {
'cursor-not-allowed': isPending, 'cursor-not-allowed': isPending,
'ml-auto': type === 'minus' 'ml-auto': type === 'minus'
@ -52,9 +52,9 @@ export default function EditItemQuantityButton({
{isPending ? ( {isPending ? (
<LoadingDots className="bg-black dark:bg-white" /> <LoadingDots className="bg-black dark:bg-white" />
) : type === 'plus' ? ( ) : type === 'plus' ? (
<PlusIcon className="h-4 w-4" /> <PlusIcon className="w-4 h-4" />
) : ( ) : (
<MinusIcon className="h-4 w-4" /> <MinusIcon className="w-4 h-4" />
)} )}
</button> </button>
); );

View File

@ -5,8 +5,7 @@ import Image from 'next/image';
import Link from 'next/link'; import Link from 'next/link';
import CartIcon from 'components/icons/cart'; import CartIcon from 'components/icons/cart';
import CloseIcon from 'components/icons/close'; import ShoppingCartIcon from 'components/icons/shopping-cart';
import ShoppingBagIcon from 'components/icons/shopping-bag';
import Price from 'components/price'; import Price from 'components/price';
import { DEFAULT_OPTION } from 'lib/constants'; import { DEFAULT_OPTION } from 'lib/constants';
import type { Cart } from 'lib/shopify/types'; import type { Cart } from 'lib/shopify/types';
@ -78,27 +77,23 @@ export default function CartModal({ cart, cartIdUpdated }: { cart: Cart; cartIdU
leaveFrom="translate-x-0" leaveFrom="translate-x-0"
leaveTo="translate-x-full" leaveTo="translate-x-full"
> >
<Dialog.Panel className="fixed bottom-0 right-0 top-0 flex h-full w-full flex-col bg-white p-6 text-black dark:bg-black dark:text-white md:w-3/5 lg:w-2/5"> <Dialog.Panel className="fixed bottom-0 right-0 top-0 flex h-full w-full flex-col bg-white/90 p-6 text-black backdrop-blur-xl dark:bg-black/90 dark:text-white md:w-[390px]">
<div className="flex items-center justify-between"> <div className="flex items-center justify-between">
<p className="text-lg font-bold">My Cart</p> <p className="text-lg font-semibold">My Cart</p>
<button
aria-label="Close cart" <button aria-label="Close cart" onClick={closeCart} data-testid="close-cart">
onClick={closeCart} <CartIcon quantity={cart.totalQuantity} />
className="text-black transition-colors hover:text-gray-500 dark:text-gray-100"
data-testid="close-cart"
>
<CloseIcon className="h-7" />
</button> </button>
</div> </div>
{cart.lines.length === 0 ? ( {cart.lines.length === 0 ? (
<div className="mt-20 flex w-full flex-col items-center justify-center overflow-hidden"> <div className="flex flex-col items-center justify-center w-full mt-20 overflow-hidden">
<ShoppingBagIcon className="h-16" /> <ShoppingCartIcon className="h-16" />
<p className="mt-6 text-center text-2xl font-bold">Your cart is empty.</p> <p className="mt-6 text-2xl font-bold text-center">Your cart is empty.</p>
</div> </div>
) : ( ) : (
<div className="flex h-full flex-col justify-between overflow-hidden"> <div className="flex flex-col justify-between h-full overflow-hidden">
<ul className="flex-grow overflow-auto p-6"> <ul className="flex-grow p-6 overflow-auto">
{cart.lines.map((item, i) => { {cart.lines.map((item, i) => {
const merchandiseSearchParams = {} as MerchandiseSearchParams; const merchandiseSearchParams = {} as MerchandiseSearchParams;
@ -114,54 +109,61 @@ export default function CartModal({ cart, cartIdUpdated }: { cart: Cart; cartIdU
); );
return ( return (
<li key={i} data-testid="cart-item"> <li key={i} data-testid="cart-item" className="flex flex-col">
<Link <Link
className="flex flex-row space-x-4 py-4" className="flex flex-row py-4 space-x-4"
href={merchandiseUrl} href={merchandiseUrl}
onClick={closeCart} onClick={closeCart}
> >
<div className="relative h-16 w-16 cursor-pointer overflow-hidden bg-white"> <div className="relative rounded-md border border-dark-gray-4 bg-white/[6.6%] hover:bg-white/[8.7%]">
<Image <div className="absolute right-0 -mt-2 -mr-2">
className="h-full w-full object-cover" <DeleteItemButton item={item} />
width={64} </div>
height={64} <div className="w-16 h-16 overflow-hidden rounded-md cursor-pointer">
alt={ <Image
item.merchandise.product.featuredImage.altText || className="object-cover w-full h-full "
item.merchandise.product.title width={64}
} height={64}
src={item.merchandise.product.featuredImage.url} alt={
/> item.merchandise.product.featuredImage.altText ||
item.merchandise.product.title
}
src={item.merchandise.product.featuredImage.url}
/>
</div>
</div> </div>
<div className="flex flex-1 flex-col text-base">
<span className="font-semibold"> <div className="flex flex-col flex-1 text-base">
<span className="leading-tight">
{item.merchandise.product.title} {item.merchandise.product.title}
</span> </span>
{item.merchandise.title !== DEFAULT_OPTION ? ( {item.merchandise.title !== DEFAULT_OPTION ? (
<p className="text-sm" data-testid="cart-product-variant"> <p className="font-semibold " data-testid="cart-product-variant">
{item.merchandise.title} {item.merchandise.title}
</p> </p>
) : null} ) : null}
</div> </div>
<Price <div className="flex flex-col justify-between h-16">
className="flex flex-col justify-between space-y-2 text-sm" <Price
amount={item.cost.totalAmount.amount} className="flex flex-col justify-between space-y-2 text-sm"
currencyCode={item.cost.totalAmount.currencyCode} amount={item.cost.totalAmount.amount}
/> currencyCode={item.cost.totalAmount.currencyCode}
/>
<div className="flex flex-row items-center ml-auto border rounded-full h-9 border-dark-gray-4">
<EditItemQuantityButton item={item} type="minus" />
<p className="">
<span className="w-full px-2 text-sm">{item.quantity}</span>
</p>
<EditItemQuantityButton item={item} type="plus" />
</div>
</div>
</Link> </Link>
<div className="flex h-9 flex-row">
<DeleteItemButton item={item} />
<p className="ml-2 flex w-full items-center justify-center border dark:border-gray-700">
<span className="w-full px-2">{item.quantity}</span>
</p>
<EditItemQuantityButton item={item} type="minus" />
<EditItemQuantityButton item={item} type="plus" />
</div>
</li> </li>
); );
})} })}
</ul> </ul>
<div className="border-t border-gray-200 pt-2 text-sm text-black dark:text-white"> <div className="pt-2 text-sm text-black border-t border-gray-200 dark:text-white">
<div className="mb-2 flex items-center justify-between"> <div className="flex items-center justify-between mb-2">
<p>Subtotal</p> <p>Subtotal</p>
<Price <Price
className="text-right" className="text-right"
@ -169,7 +171,7 @@ export default function CartModal({ cart, cartIdUpdated }: { cart: Cart; cartIdU
currencyCode={cart.cost.subtotalAmount.currencyCode} currencyCode={cart.cost.subtotalAmount.currencyCode}
/> />
</div> </div>
<div className="mb-2 flex items-center justify-between"> <div className="flex items-center justify-between mb-2">
<p>Taxes</p> <p>Taxes</p>
<Price <Price
className="text-right" className="text-right"
@ -177,11 +179,11 @@ export default function CartModal({ cart, cartIdUpdated }: { cart: Cart; cartIdU
currencyCode={cart.cost.totalTaxAmount.currencyCode} currencyCode={cart.cost.totalTaxAmount.currencyCode}
/> />
</div> </div>
<div className="mb-2 flex items-center justify-between border-b border-gray-200 pb-2"> <div className="flex items-center justify-between pb-2 mb-2 border-b border-gray-200">
<p>Shipping</p> <p>Shipping</p>
<p className="text-right">Calculated at checkout</p> <p className="text-right">Calculated at checkout</p>
</div> </div>
<div className="mb-2 flex items-center justify-between font-bold"> <div className="flex items-center justify-between mb-2 font-bold">
<p>Total</p> <p>Total</p>
<Price <Price
className="text-right" className="text-right"
@ -192,7 +194,7 @@ export default function CartModal({ cart, cartIdUpdated }: { cart: Cart; cartIdU
</div> </div>
<a <a
href={cart.checkoutUrl} href={cart.checkoutUrl}
className="flex w-full items-center justify-center bg-black p-3 text-sm font-medium uppercase text-white opacity-90 hover:opacity-100 dark:bg-white dark:text-black" className="flex items-center justify-center w-full p-3 text-sm font-medium text-white uppercase bg-black opacity-90 hover:opacity-100 dark:bg-white dark:text-black"
> >
<span>Proceed to Checkout</span> <span>Proceed to Checkout</span>
</a> </a>

View File

@ -1,5 +1,5 @@
import clsx from 'clsx'; import clsx from 'clsx';
import ShoppingBagIcon from './shopping-bag'; import ShoppingCartIcon from './shopping-cart';
export default function CartIcon({ export default function CartIcon({
className, className,
@ -9,15 +9,15 @@ export default function CartIcon({
quantity?: number; quantity?: number;
}) { }) {
return ( return (
<div className="relative"> <div className="relative flex h-11 w-11 items-center justify-center rounded-md border border-dark-gray-4 text-black transition-colors dark:text-gray-100">
<ShoppingBagIcon <ShoppingCartIcon
className={clsx( className={clsx(
'h-6 transition-all ease-in-out hover:scale-110 hover:text-gray-500 dark:hover:text-gray-300', 'h-6 transition-all ease-in-out hover:scale-110 hover:text-gray-500 dark:hover:text-gray-300',
className className
)} )}
/> />
{quantity ? ( {quantity ? (
<div className="absolute bottom-0 left-0 -mb-3 -ml-3 flex h-5 w-5 items-center justify-center rounded-full border-2 border-white bg-black text-xs text-white dark:border-black dark:bg-white dark:text-black"> <div className="absolute right-0 top-0 -mr-2 -mt-2 h-4 w-4 rounded bg-blue-500 text-[11px] font-medium">
{quantity} {quantity}
</div> </div>
) : null} ) : null}

View File

@ -1,19 +0,0 @@
export default function ShoppingBagIcon({ className }: { className?: string }) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 20 22"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
shapeRendering="geometricPrecision"
className={className}
>
<path d="M4 1L1 5V19C1 19.5304 1.21071 20.0391 1.58579 20.4142C1.96086 20.7893 2.46957 21 3 21H17C17.5304 21 18.0391 20.7893 18.4142 20.4142C18.7893 20.0391 19 19.5304 19 19V5L16 1H4Z" />
<path d="M1 5H19" />
<path d="M14 9C14 10.0609 13.5786 11.0783 12.8284 11.8284C12.0783 12.5786 11.0609 13 10 13C8.93913 13 7.92172 12.5786 7.17157 11.8284C6.42143 11.0783 6 10.0609 6 9" />
</svg>
);
}

View File

@ -0,0 +1,34 @@
export default function ShoppingCartIcon({ className }: { className?: string }) {
return (
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_137_611)">
<path
d="M6.00004 14.6667C6.36823 14.6667 6.66671 14.3682 6.66671 14C6.66671 13.6319 6.36823 13.3334 6.00004 13.3334C5.63185 13.3334 5.33337 13.6319 5.33337 14C5.33337 14.3682 5.63185 14.6667 6.00004 14.6667Z"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M13.3333 14.6667C13.7015 14.6667 14 14.3682 14 14C14 13.6319 13.7015 13.3334 13.3333 13.3334C12.9651 13.3334 12.6666 13.6319 12.6666 14C12.6666 14.3682 12.9651 14.6667 13.3333 14.6667Z"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M0.666626 0.666687H3.33329L5.11996 9.59335C5.18092 9.90028 5.3479 10.176 5.59166 10.3722C5.83541 10.5684 6.14042 10.6727 6.45329 10.6667H12.9333C13.2462 10.6727 13.5512 10.5684 13.7949 10.3722C14.0387 10.176 14.2057 9.90028 14.2666 9.59335L15.3333 4.00002H3.99996"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
</g>
<defs>
<clipPath id="clip0_137_611">
<rect width="16" height="16" fill="currentColor" />
</clipPath>
</defs>
</svg>
);
}

1467
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,9 @@ module.exports = {
hotPink: '#FF1966', hotPink: '#FF1966',
dark: '#111111', dark: '#111111',
light: '#FAFAFA', light: '#FAFAFA',
violetDark: '#4c2889' violetDark: '#4c2889',
'dark-gray-4': '#2E2E2E',
'base-gray-900': '#666666'
}, },
keyframes: { keyframes: {
fadeIn: { fadeIn: {