From 6dae061425f3b51b05a83a48035d70496d4fb6a7 Mon Sep 17 00:00:00 2001 From: paco <34928425+pacocoursey@users.noreply.github.com> Date: Thu, 8 Oct 2020 18:37:11 -0600 Subject: [PATCH] Add error, empty, success states to cart sidebar --- .../cart/CartSidebarView/CartSidebarView.tsx | 59 ++++++++++++++----- components/icon/ArrowLeft.tsx | 11 +++- components/icon/Check.tsx | 21 +++++++ components/icon/index.ts | 1 + components/product/Swatch/Swatch.tsx | 19 +----- tailwind.config.js | 2 + 6 files changed, 78 insertions(+), 35 deletions(-) create mode 100644 components/icon/Check.tsx diff --git a/components/cart/CartSidebarView/CartSidebarView.tsx b/components/cart/CartSidebarView/CartSidebarView.tsx index a5d014d56..85824e6fb 100644 --- a/components/cart/CartSidebarView/CartSidebarView.tsx +++ b/components/cart/CartSidebarView/CartSidebarView.tsx @@ -1,7 +1,8 @@ import { FC } from 'react' +import cn from 'classnames' import { UserNav } from '@components/core' import { Button } from '@components/ui' -import { ArrowLeft } from '@components/icon' +import { ArrowLeft, Bag, Cross, Check } from '@components/icon' import { useUI } from '@components/ui/context' import { useCart } from '@lib/bigcommerce/cart' import CartItem from '../CartItem' @@ -15,15 +16,25 @@ const CartSidebarView: FC = () => { console.log('CART', data, isEmpty) + // This should come from the API via hook I guess + const error = null + const success = null + return ( - <> +
@@ -32,24 +43,42 @@ const CartSidebarView: FC = () => {
- {isEmpty ? ( -

- Your cart is currently empty -

- ) : ( -

- My Cart -

- )}
{isEmpty ? ( -
- +
+ + + +

+ Your cart is empty. +

+
+ ) : error ? ( +
+ + + +

+ We couldn’t process the purchase. Please check your card information + and try again. +

+
+ ) : success ? ( +
+ + + +

+ Thank you for your order. +

) : ( <>
+

+ My Cart +

    {items.map((item) => ( {
)} - +
) } diff --git a/components/icon/ArrowLeft.tsx b/components/icon/ArrowLeft.tsx index e85b956e6..ed80ca7a7 100644 --- a/components/icon/ArrowLeft.tsx +++ b/components/icon/ArrowLeft.tsx @@ -1,16 +1,21 @@ const ArrowLeft = ({ ...props }) => { return ( - + { + return ( + + + + ) +} + +export default Check diff --git a/components/icon/index.ts b/components/icon/index.ts index 047be8be7..725587c69 100644 --- a/components/icon/index.ts +++ b/components/icon/index.ts @@ -5,3 +5,4 @@ export { default as Cross } from './Cross' export { default as ArrowLeft } from './ArrowLeft' export { default as Plus } from './Plus' export { default as Minus } from './Minus' +export { default as Check } from './Check' diff --git a/components/product/Swatch/Swatch.tsx b/components/product/Swatch/Swatch.tsx index ea2fcbced..6b1222850 100644 --- a/components/product/Swatch/Swatch.tsx +++ b/components/product/Swatch/Swatch.tsx @@ -2,6 +2,7 @@ import cn from 'classnames' import { FC } from 'react' import s from './Swatch.module.css' import { Colors } from '@components/ui/types' +import { Check } from '@components/icon' import Button, { ButtonProps } from '@components/ui/Button' interface Props extends ButtonProps { @@ -37,7 +38,7 @@ const Swatch: FC = ({ className, size, color, active, ...props }) => { 'text-black': color === 'white', })} > - {Check} + )} {size} @@ -47,19 +48,3 @@ const Swatch: FC = ({ className, size, color, active, ...props }) => { export default Swatch -const Check = ( - - - -) diff --git a/tailwind.config.js b/tailwind.config.js index 0681596d6..4f0101c02 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -16,6 +16,8 @@ module.exports = { pink: '#FF0080', cyan: '#50E3C2', blue: '#0070F3', + green: '#37B679', + red: '#DA3C3C', primary: '#000', textColor: { primary: '#FFF',