From 06b5b23d01c7a1f979573e619a03a7af0b48a7dc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 1 Sep 2021 13:41:07 +0700 Subject: [PATCH 01/19] :sparkles: feat: CardItemCheckout :%s --- pages/test.tsx | 15 +++++----- .../CardItemCheckout.module.scss | 29 +++++++++++++++++++ .../CardItemCheckout/CardItemCheckout.tsx | 29 +++++++++++++++++++ src/components/common/index.ts | 1 + 4 files changed, 67 insertions(+), 7 deletions(-) create mode 100644 src/components/common/CardItemCheckout/CardItemCheckout.module.scss create mode 100644 src/components/common/CardItemCheckout/CardItemCheckout.tsx diff --git a/pages/test.tsx b/pages/test.tsx index a0d99978c..24d55e9ac 100644 --- a/pages/test.tsx +++ b/pages/test.tsx @@ -1,6 +1,7 @@ import { useState } from 'react' import { ButtonCommon, + CardItemCheckout, Layout, ModalCommon, ModalConfirm, @@ -19,7 +20,7 @@ const dataTest = [ weight: '250g', category: 'VEGGIE', price: 'Rp 27.500', - imageSrc: image5.src, + imageSrc: image7.src, }, { name: 'Tomato', @@ -410,12 +411,12 @@ export default function Test() { } return ( <> - open - - Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nisi qui, esse eos nobis soluta suscipit aliquid nostrum corporis. Nihil eligendi similique recusandae minus mollitia aliquam, molestias fugit tenetur voluptatibus maiores et. Quaerat labore corporis inventore nostrum, amet autem exercitationem eligendi? - - - + +
+ + test + +
) } diff --git a/src/components/common/CardItemCheckout/CardItemCheckout.module.scss b/src/components/common/CardItemCheckout/CardItemCheckout.module.scss new file mode 100644 index 000000000..374529453 --- /dev/null +++ b/src/components/common/CardItemCheckout/CardItemCheckout.module.scss @@ -0,0 +1,29 @@ +.warpper{ + max-width: 49.9rem; + max-height: 12rem; + padding:1.6rem 0; + @apply flex items-center; + .image{ + min-width: 13.3rem; + max-width: 8.8rem; + margin: 0.8rem; + @apply flex justify-center items-center; + img{ + width: 100%; + height: 100%; + } + } + .right{ + width: 100%; + .name{ + color: var(--text-active); + margin-bottom: 0.5erm; + } + .quantity { + @apply flex justify-between text-label; + .price{ + color: var(--text-base); + } + } + } +} \ No newline at end of file diff --git a/src/components/common/CardItemCheckout/CardItemCheckout.tsx b/src/components/common/CardItemCheckout/CardItemCheckout.tsx new file mode 100644 index 000000000..dd9fb14c5 --- /dev/null +++ b/src/components/common/CardItemCheckout/CardItemCheckout.tsx @@ -0,0 +1,29 @@ +import React from 'react' +import s from "./CardItemCheckout.module.scss" +import { ProductProps } from 'src/utils/types.utils' +interface CardItemCheckoutProps extends ProductProps { + quantity:number +} + +const CardItemCheckout = ({imageSrc,name,price,weight,quantity,category}: CardItemCheckoutProps) => { + return ( +
+
+ image +
+
+
+ {`${name} (${weight})`} +
+
+ Quantity: +
+ {`${quantity} x ${price}`} +
+
+
+
+ ) +} + +export default CardItemCheckout diff --git a/src/components/common/index.ts b/src/components/common/index.ts index f3d73ad96..b4d2591cb 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -33,3 +33,4 @@ export { default as ModalConfirm} from "./ModalConfirm/ModalConfirm" export { default as ModalInfo} from "./ModalInfo/ModalInfo" export { default as ProductList} from "./ProductList/ProductList" export { default as ModalCreateUserInfo} from './ModalCreateUserInfo/ModalCreateUserInfo' +export { default as CardItemCheckout} from './CardItemCheckout/CardItemCheckout' From 7ece18782d43b680ed0a917829c2b7e07112d247 Mon Sep 17 00:00:00 2001 From: sonnguyenkieio Date: Mon, 6 Sep 2021 14:07:33 +0700 Subject: [PATCH 02/19] :sparkles: feat: Tab Common --- src/components/common/TabCommon/TabCommon.tsx | 50 +++++++++++++++---- .../common/TabCommon/TabItem/TabItem.tsx | 9 ++-- 2 files changed, 44 insertions(+), 15 deletions(-) diff --git a/src/components/common/TabCommon/TabCommon.tsx b/src/components/common/TabCommon/TabCommon.tsx index d07cf06e8..67fe107a6 100644 --- a/src/components/common/TabCommon/TabCommon.tsx +++ b/src/components/common/TabCommon/TabCommon.tsx @@ -1,46 +1,74 @@ -import React, { useState } from "react" +import React, { useState, RefObject, useEffect, useRef } from "react" import s from './TabCommon.module.scss' import TabItem from './TabItem/TabItem' interface TabCommonProps { - + changeTab: (target:string) => void; } -const TabCommon = ({ } : TabCommonProps) => { +const TabCommon = ({ changeTab } : TabCommonProps) => { const active = "active", unActive = ""; - const [item1Active, setItem1Active] = useState(active); const [item2Active, setItem2Active] = useState(unActive); const [item3Active, setItem3Active] = useState(unActive); + const item1 = useRef(null); + const item2 = useRef(null); + const item3 = useRef(null); + const slider = useRef(null); + + function slide(ref: RefObject) { + const width = ref.current.offsetWidth; + const left = ref.current.offsetLeft; + + slider.current.style.width = (width-48).toString()+"px"; + slider.current.style.left = left.toString()+"px"; + } + function toggleItem1():void { setItem1Active(active) + changeTab("waiting") setItem2Active(unActive) setItem3Active(unActive) + slide(item1) } + function toggleItem2():void { setItem2Active(active) + changeTab("delivering") setItem1Active(unActive) setItem3Active(unActive) + slide(item2) } function toggleItem3():void { setItem3Active(active) + changeTab("delivered") setItem1Active(unActive) setItem2Active(unActive) + slide(item3) } + useEffect(() => { + slide(item1); + }, []) + return ( -
-
- Wait for Comfirmation - Delivering - Delivered -
-
+
    +
  • + Wait for Comfirmation +
  • +
  • + Delivering +
  • +
  • + Delivered +
  • +
    +
) } diff --git a/src/components/common/TabCommon/TabItem/TabItem.tsx b/src/components/common/TabCommon/TabItem/TabItem.tsx index a889ee68b..62de3c595 100644 --- a/src/components/common/TabCommon/TabItem/TabItem.tsx +++ b/src/components/common/TabCommon/TabItem/TabItem.tsx @@ -4,13 +4,14 @@ import s from './TabItem.module.scss' interface TabItemProps { active: string; - target?: string; - children?: string; + children: string; + onClick: () => void; } -const TabItem = ({ active = "", children } : TabItemProps) => { +const TabItem = ({ active = "", children, onClick } : TabItemProps) => { + return ( - {children} From cc36116ae468cfb172309f8592dfb95805769c1b Mon Sep 17 00:00:00 2001 From: sonnguyenkieio Date: Mon, 6 Sep 2021 14:09:17 +0700 Subject: [PATCH 03/19] :sparkles: feat: Account Navigation --- .../AccountNavigation/AccountNavigation.tsx | 39 ++++++++++++++----- .../components/AccountNavigationItem.tsx | 7 ++-- 2 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/components/modules/account/AccountNavigation/AccountNavigation.tsx b/src/components/modules/account/AccountNavigation/AccountNavigation.tsx index fd289edc9..15ecd3a31 100644 --- a/src/components/modules/account/AccountNavigation/AccountNavigation.tsx +++ b/src/components/modules/account/AccountNavigation/AccountNavigation.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react" +import React, { useState, useRef, RefObject, useEffect } from "react" import s from './AccountNavigation.module.scss' import AccountNavigationItem from './components/AccountNavigationItem' @@ -10,39 +10,58 @@ interface AccountNavigationProps { const AccountNavigation = ({ } : AccountNavigationProps) => { const active = "active", unActive = ""; - const [item1Active, setItem1Active] = useState(active); - const [item2Active, setItem2Active] = useState(unActive); + const [item1Active, setItem1Active] = useState(unActive); + const [item2Active, setItem2Active] = useState(active); const [item3Active, setItem3Active] = useState(unActive); + const item1 = useRef(null); + const item2 = useRef(null); + const item3 = useRef(null); + const slider = useRef(null); + + function slide(ref: RefObject) { + const top = ref.current.offsetTop; + slider.current.style.top = top.toString()+"px"; + } + function toggleItem1():void { setItem1Active(active) setItem2Active(unActive) setItem3Active(unActive) + slide(item1); } function toggleItem2():void { setItem2Active(active) setItem1Active(unActive) setItem3Active(unActive) + slide(item2); } function toggleItem3():void { setItem3Active(active) setItem1Active(unActive) setItem2Active(unActive) + slide(item3); } + + useEffect(() => { + slide(item2); + }, []) + return (
-
- Customer Information -
-
- Your Orders +
+ Customer Information
-
- Favourites +
+ Your Orders
+
+ Favourites +
+
) } diff --git a/src/components/modules/account/AccountNavigation/components/AccountNavigationItem.tsx b/src/components/modules/account/AccountNavigation/components/AccountNavigationItem.tsx index 47cd537f0..8bb18cb58 100644 --- a/src/components/modules/account/AccountNavigation/components/AccountNavigationItem.tsx +++ b/src/components/modules/account/AccountNavigation/components/AccountNavigationItem.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { RefObject } from "react"; import classNames from "classnames"; import s from './AccountNavigationItem.module.scss' @@ -6,11 +6,12 @@ interface AccountNavigationItemProps { children?: string; active?: string; target?: string; + onClick: () => void; } -const AccountNavigationItem = ({ children, active="" } : AccountNavigationItemProps) => { +const AccountNavigationItem = ({ children, active="", onClick } : AccountNavigationItemProps) => { return ( -
{children} From 757cb68319d65c3acf895115b39dc351fd7762ad Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2021 09:17:59 +0700 Subject: [PATCH 04/19] :sparkles: feat: collapse checkout custom form shipping form :%s --- pages/test.tsx | 370 +----------------- .../InputCommon/InputCommon.module.scss | 4 +- .../common/InputCommon/InputCommon.tsx | 1 + .../common/ModalCommon/ModalCommon.tsx | 2 +- .../hooks}/useClickOutSide.ts | 2 +- src/components/icons/Shipping.tsx | 20 + src/components/icons/index.ts | 3 +- .../CheckoutBill/CheckoutBill.module.scss | 0 .../components/CheckoutBill/CheckoutBill.tsx | 23 ++ .../CheckoutCollapse.module.scss | 39 ++ .../CheckoutCollapse/CheckoutCollapse.tsx | 48 +++ .../CustomerInfoForm.module.scss | 13 + .../CustomerInfoForm/CustomerInfoForm.tsx | 51 +++ .../PaymentInfoForm.module.scss | 0 .../PaymentInfoForm/PaymentInfoForm.tsx | 15 + .../ShippingInfoForm.module.scss | 36 ++ .../ShippingInfoForm/ShippingInfoForm.tsx | 93 +++++ src/utils/types.utils.ts | 13 + 18 files changed, 375 insertions(+), 358 deletions(-) rename src/{utils => components/hooks}/useClickOutSide.ts (92%) create mode 100644 src/components/icons/Shipping.tsx create mode 100644 src/components/modules/checkout/components/CheckoutBill/CheckoutBill.module.scss create mode 100644 src/components/modules/checkout/components/CheckoutBill/CheckoutBill.tsx create mode 100644 src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.module.scss create mode 100644 src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.tsx create mode 100644 src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.module.scss create mode 100644 src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.tsx create mode 100644 src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.module.scss create mode 100644 src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.tsx create mode 100644 src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.module.scss create mode 100644 src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.tsx diff --git a/pages/test.tsx b/pages/test.tsx index 24d55e9ac..7f40661be 100644 --- a/pages/test.tsx +++ b/pages/test.tsx @@ -1,15 +1,12 @@ import { useState } from 'react' import { - ButtonCommon, CardItemCheckout, Layout, - ModalCommon, - ModalConfirm, - ModalInfo, - ProductCarousel, - ProductList, } from 'src/components/common' import PaginationCommon from 'src/components/common/PaginationCommon/PaginationCommon' +import CheckoutCollapse from 'src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse' +import CustomerInfoForm from 'src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm' +import ShippingInfoForm from 'src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm' import image5 from '../public/assets/images/image5.png' import image6 from '../public/assets/images/image6.png' import image7 from '../public/assets/images/image7.png' @@ -22,146 +19,6 @@ const dataTest = [ price: 'Rp 27.500', imageSrc: image7.src, }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Cucumber', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image6.src, - }, { name: 'Carrot', weight: '250g', @@ -197,209 +54,6 @@ const dataTest = [ price: 'Rp 27.500', imageSrc: image8.src, }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Carrot', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - }, - { - name: 'Salad', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image8.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Carrot', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - }, - { - name: 'Salad', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image8.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Carrot', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - }, - { - name: 'Salad', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image8.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Carrot', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - }, - { - name: 'Salad', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image8.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Carrot', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - }, - { - name: 'Salad', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image8.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Cucumber', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image6.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Cucumber', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image6.src, - }, - { - name: 'Carrot', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - }, - { - name: 'Salad', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image8.src, - }, - { - name: 'Carrot', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - }, - { - name: 'Salad', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image8.src, - }, - { - name: 'Carrot', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - }, - { - name: 'Salad', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image8.src, - }, - { - name: 'Carrot', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - }, - { - name: 'Salad', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image8.src, - }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - }, - { - name: 'Cucumber', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image6.src, - }, ] export default function Test() { const [visible, setVisible] = useState(false) @@ -409,13 +63,23 @@ export default function Test() { const onOpen = () => { setVisible(true) } + const [visible2, setVisible2] = useState(false) + const onClose2 = () => { + setVisible2(false) + } + const onOpen2 = () => { + setVisible2(true) + } return ( <> -
- - test - +
+ + + + + +
) diff --git a/src/components/common/InputCommon/InputCommon.module.scss b/src/components/common/InputCommon/InputCommon.module.scss index acfc07647..6b12d2bbd 100644 --- a/src/components/common/InputCommon/InputCommon.module.scss +++ b/src/components/common/InputCommon/InputCommon.module.scss @@ -15,9 +15,9 @@ .icon + .inputCommon { padding-left: 4.8rem; } - + .inputCommon { - @apply block w-full transition-all duration-200 rounded; + @apply block w-full transition-all duration-200 rounded bg-white; padding: 1.2rem 1.6rem; border: 1px solid var(--border-line); &:hover, diff --git a/src/components/common/InputCommon/InputCommon.tsx b/src/components/common/InputCommon/InputCommon.tsx index 943b0a632..0389c99b3 100644 --- a/src/components/common/InputCommon/InputCommon.tsx +++ b/src/components/common/InputCommon/InputCommon.tsx @@ -6,6 +6,7 @@ import s from './InputCommon.module.scss'; type Ref = { focus: () => void + getValue: () => string | number } | null; interface Props { children?: React.ReactNode, diff --git a/src/components/common/ModalCommon/ModalCommon.tsx b/src/components/common/ModalCommon/ModalCommon.tsx index 75222c162..7f9bc07d8 100644 --- a/src/components/common/ModalCommon/ModalCommon.tsx +++ b/src/components/common/ModalCommon/ModalCommon.tsx @@ -1,6 +1,6 @@ import React, { useRef } from 'react' import { Close } from 'src/components/icons' -import { useOnClickOutside } from 'src/utils/useClickOutSide' +import { useOnClickOutside } from 'src/components/hooks/useClickOutSide' import s from './ModalCommon.module.scss' export interface ModalCommonProps { onClose: () => void diff --git a/src/utils/useClickOutSide.ts b/src/components/hooks/useClickOutSide.ts similarity index 92% rename from src/utils/useClickOutSide.ts rename to src/components/hooks/useClickOutSide.ts index d68e742fb..ff69007a8 100644 --- a/src/utils/useClickOutSide.ts +++ b/src/components/hooks/useClickOutSide.ts @@ -1,5 +1,5 @@ import { RefObject, useEffect } from 'react' -import { MouseAndTouchEvent } from './types.utils' +import { MouseAndTouchEvent } from '../../utils/types.utils' export function useOnClickOutside( ref: RefObject, diff --git a/src/components/icons/Shipping.tsx b/src/components/icons/Shipping.tsx new file mode 100644 index 000000000..2288c142c --- /dev/null +++ b/src/components/icons/Shipping.tsx @@ -0,0 +1,20 @@ +import React from 'react' + +const Shipping = () => { + return ( + + + + ) +} + +export default Shipping diff --git a/src/components/icons/index.ts b/src/components/icons/index.ts index 3473bb29e..8bdbb1740 100644 --- a/src/components/icons/index.ts +++ b/src/components/icons/index.ts @@ -23,4 +23,5 @@ export { default as IconPasswordCross } from './IconPasswordCross' export { default as IconError } from './IconError' export { default as IconCheck } from './IconCheck' export { default as IconPlus } from './IconPlus' -export { default as IconMinus } from './IconMinus' \ No newline at end of file +export { default as IconMinus } from './IconMinus' +export { default as Shipping} from './Shipping' \ No newline at end of file diff --git a/src/components/modules/checkout/components/CheckoutBill/CheckoutBill.module.scss b/src/components/modules/checkout/components/CheckoutBill/CheckoutBill.module.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/components/modules/checkout/components/CheckoutBill/CheckoutBill.tsx b/src/components/modules/checkout/components/CheckoutBill/CheckoutBill.tsx new file mode 100644 index 000000000..96bb74d3f --- /dev/null +++ b/src/components/modules/checkout/components/CheckoutBill/CheckoutBill.tsx @@ -0,0 +1,23 @@ +import React from 'react' +import s from "CheckoutBill.module.scss" +interface CheckoutBillProps { + +} + +const CheckoutBill = ({}: CheckoutBillProps) => { + return ( +
+
+ +
+
+ +
+
+ +
+
+ ) +} + +export default CheckoutBill diff --git a/src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.module.scss b/src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.module.scss new file mode 100644 index 000000000..b34630fed --- /dev/null +++ b/src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.module.scss @@ -0,0 +1,39 @@ +.warpper{ + .header{ + @apply flex justify-between; + padding-bottom: 3.2rem; + .left{ + @apply flex items-center; + .number{ + width: 3.2rem; + height: 3.2rem; + border-radius: 100%; + border: 1px solid var(--text-active); + color: var(--text-active); + @apply flex justify-center items-center font-bold; + &.visible{ + background-color: var(--text-active); + border: none; + color: var(--white); + } + } + .title{ + padding-left: 2.4rem; + @apply font-bold select-none cursor-pointer; + color: var(--text-active); + } + } + .edit{ + @apply font-bold cursor-pointer; + text-decoration-line: underline; + margin-right: 5.6rem; + } + } + .body{ + height: 0; + @apply overflow-hidden; + &.show{ + height: initial; + } + } +} \ No newline at end of file diff --git a/src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.tsx b/src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.tsx new file mode 100644 index 000000000..b4825730a --- /dev/null +++ b/src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.tsx @@ -0,0 +1,48 @@ +import classNames from 'classnames' +import React from 'react' +import s from './CheckoutCollapse.module.scss' +interface CheckoutCollapseProps { + visible: boolean + id: number + children: React.ReactNode + title: string + isEdit: boolean + onClose: () => void + onOpen: () => void +} + +const CheckoutCollapse = ({ + children, + id, + title, + isEdit, + visible, + onOpen, + onClose, +}: CheckoutCollapseProps) => { + const handleTitleClick = () => { + if(visible){ + onClose && onClose() + }else{ + onOpen && onOpen() + } + } + return ( +
+
+
+
+ {id} +
+
+ {title} +
+
+ {isEdit &&
{'Edit'}
} +
+
{children}
+
+ ) +} + +export default CheckoutCollapse diff --git a/src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.module.scss b/src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.module.scss new file mode 100644 index 000000000..f5b7ddcde --- /dev/null +++ b/src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.module.scss @@ -0,0 +1,13 @@ +@import "../../../../../styles/utilities"; +.warpper{ + @apply u-form; + padding: 0 5.6rem; + .bottom{ + margin-top: 2.4rem; + @apply flex justify-between items-center; + .note{ + font-size: 1.2rem; + line-height: 2rem; + } + } +} \ No newline at end of file diff --git a/src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.tsx b/src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.tsx new file mode 100644 index 000000000..a821c66eb --- /dev/null +++ b/src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.tsx @@ -0,0 +1,51 @@ +import Link from 'next/link' +import React, { useRef } from 'react' +import { ButtonCommon, Inputcommon } from 'src/components/common' +import InputCommon from 'src/components/common/InputCommon/InputCommon' +import s from './CustomerInfoForm.module.scss' +interface CustomerInfoFormProps { + onConfirm?: ()=>void +} + +const CustomerInfoForm = ({}: CustomerInfoFormProps) => { + const nameRef = useRef>(null); + const emailRef = useRef>(null); + + + + const handleConfirmClick = () => { + return { + name:nameRef?.current?.getValue(), + email:emailRef.current?.getValue() + } + } + + return ( +
+
+ + +
+
+
+ By clicking continue you agree to Casper's{' '} + { + + terms and conditions + + }{' '} + and{' '} + { + + privacy policy + + } + . +
+ Continue to Shipping +
+
+ ) +} + +export default CustomerInfoForm diff --git a/src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.module.scss b/src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.module.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.tsx b/src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.tsx new file mode 100644 index 000000000..4b8410177 --- /dev/null +++ b/src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.tsx @@ -0,0 +1,15 @@ +import React from 'react' + +interface PaymentInfoFormProps { + +} + +const PaymentInfoForm = (props: PaymentInfoFormProps) => { + return ( +
+ +
+ ) +} + +export default PaymentInfoForm diff --git a/src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.module.scss b/src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.module.scss new file mode 100644 index 000000000..439fb2628 --- /dev/null +++ b/src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.module.scss @@ -0,0 +1,36 @@ +@import "../../../../../styles/utilities"; +.warpper{ + @apply u-form; + padding: 0 5.6rem; + .bottom{ + margin-top: 2.4rem; + @apply flex justify-between items-center; + .note{ + font-size: 1.2rem; + line-height: 2rem; + } + } + .line{ + >div{ + width: 50%; + } + } + .method{ + width: 100%; + height: 5.6rem; + padding: 1.6rem; + border-radius: 0.8rem; + @apply flex justify-between items-center border border-solid border-line bg-gray; + .left{ + @apply flex; + .name{ + margin-left: 1.6rem; + color: var(--text-active); + } + } + .price{ + font-weight: bold; + color: var(--text-active); + } + } +} \ No newline at end of file diff --git a/src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.tsx b/src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.tsx new file mode 100644 index 000000000..d8c858399 --- /dev/null +++ b/src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.tsx @@ -0,0 +1,93 @@ +import React, { useRef } from 'react' +import { ButtonCommon, Inputcommon, SelectCommon } from 'src/components/common' +import s from './ShippingInfoForm.module.scss' +import Link from 'next/link' +import { CustomInputCommon } from 'src/utils/type.utils' +import { Shipping } from 'src/components/icons' + +interface ShippingInfoFormProps {} + +const option = [ + { + name: 'Hồ Chí Minh', + }, + { + name: 'Hà Nội', + }, +] + +const ShippingInfoForm = ({}: ShippingInfoFormProps) => { + const addressRef = useRef(null) + const cityRef = useRef(null) + const stateRef = useRef(null) + const codeRef = useRef(null) + const phoneRef = useRef(null) + const handleConfirmClick = () => { + return { + address: addressRef?.current?.getValue(), + city: cityRef.current?.getValue(), + state: stateRef?.current?.getValue(), + code: codeRef.current?.getValue(), + phone: phoneRef?.current?.getValue(), + } + } + + return ( +
+
+ + +
+ State + +
+ +
+
+
+ +
+
+ Standard Delivery Method +
+
+
+
+ Free +
+
+
+
+
+
+ By clicking continue you agree to Casper's{' '} + { + + terms and conditions + + }{' '} + and{' '} + { + + privacy policy + + } + . +
+ + Continue to Payment + +
+
+ ) +} + +export default ShippingInfoForm diff --git a/src/utils/types.utils.ts b/src/utils/types.utils.ts index 2c99df73a..6fa8df0e8 100644 --- a/src/utils/types.utils.ts +++ b/src/utils/types.utils.ts @@ -20,4 +20,17 @@ export interface RecipeProps { imageSrc: string } +export interface CheckOutForm { + name: string + email:string + address: string + city:string + state:string + code:number + phone:number + method:string + shipping_fee:number +} + + export type MouseAndTouchEvent = MouseEvent | TouchEvent \ No newline at end of file From ec8b9fbcdf2707768e69e5cee363149d7f9dac3e Mon Sep 17 00:00:00 2001 From: sonnguyenkieio <89386072+sonnguyenkieio@users.noreply.github.com> Date: Tue, 7 Sep 2021 12:14:34 +0700 Subject: [PATCH 05/19] :sparkles: feat: Tab Common --- src/components/common/TabCommon/TabCommon.tsx | 77 +++++-------------- 1 file changed, 19 insertions(+), 58 deletions(-) diff --git a/src/components/common/TabCommon/TabCommon.tsx b/src/components/common/TabCommon/TabCommon.tsx index 67fe107a6..60a2649f6 100644 --- a/src/components/common/TabCommon/TabCommon.tsx +++ b/src/components/common/TabCommon/TabCommon.tsx @@ -1,75 +1,36 @@ -import React, { useState, RefObject, useEffect, useRef } from "react" +import React, { RefObject, useEffect } from "react" import s from './TabCommon.module.scss' import TabItem from './TabItem/TabItem' interface TabCommonProps { - changeTab: (target:string) => void; + tabs: {ref:RefObject, tabName: string, active: boolean, onClick: (tabIndex: number, tabPane: string) => void}[]; + defaultActiveTab: number; + sliderRef : RefObject; + slideToTab: (ref: any) => void; } -const TabCommon = ({ changeTab } : TabCommonProps) => { - const active = "active", unActive = ""; - const [item1Active, setItem1Active] = useState(active); - const [item2Active, setItem2Active] = useState(unActive); - const [item3Active, setItem3Active] = useState(unActive); - - const item1 = useRef(null); - const item2 = useRef(null); - const item3 = useRef(null); - const slider = useRef(null); - - function slide(ref: RefObject) { - const width = ref.current.offsetWidth; - const left = ref.current.offsetLeft; - - slider.current.style.width = (width-48).toString()+"px"; - slider.current.style.left = left.toString()+"px"; - } - - function toggleItem1():void { - setItem1Active(active) - changeTab("waiting") - - setItem2Active(unActive) - setItem3Active(unActive) - slide(item1) - } - - function toggleItem2():void { - setItem2Active(active) - changeTab("delivering") - - setItem1Active(unActive) - setItem3Active(unActive) - slide(item2) - } - function toggleItem3():void { - setItem3Active(active) - changeTab("delivered") - - setItem1Active(unActive) - setItem2Active(unActive) - slide(item3) - } +const TabCommon = ({ tabs, defaultActiveTab, sliderRef, slideToTab } : TabCommonProps) => { useEffect(() => { - slide(item1); + slideToTab(tabs[defaultActiveTab].ref); }, []) return (
    -
  • - Wait for Comfirmation -
  • -
  • - Delivering -
  • -
  • - Delivered -
  • -
    + { + tabs.map((tab) => { + return ( +
  • + {tab.tabName} +
  • + ) + }) + } + +
) } -export default TabCommon; \ No newline at end of file +export default TabCommon; From ceb144ee57d281267466b921ae51a82913804cc8 Mon Sep 17 00:00:00 2001 From: sonnguyenkieio <89386072+sonnguyenkieio@users.noreply.github.com> Date: Tue, 7 Sep 2021 12:15:14 +0700 Subject: [PATCH 06/19] :sparkles: feat: Tab Common --- .../common/TabCommon/TabCommon.module.scss | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/components/common/TabCommon/TabCommon.module.scss b/src/components/common/TabCommon/TabCommon.module.scss index 9e5fbc1df..3d3473d82 100644 --- a/src/components/common/TabCommon/TabCommon.module.scss +++ b/src/components/common/TabCommon/TabCommon.module.scss @@ -1,15 +1,21 @@ @import '../../../styles/utilities'; -.tabCommonOutSide { - @apply spacing-horizontal; - - .tabCommon { - @apply flex; - position: relative; - border-bottom: 2px solid #FBFBFB; - padding-top: 1.6rem; - padding-bottom: 1.6rem; - width: 100%; +.tabCommon { + @apply flex; + position: relative; + border-bottom: 2px solid #FBFBFB; + padding-top: 1.6rem; + padding-bottom: 1.6rem; + width: 100%; + + .slider { + @apply inline-block; + height: .2rem; + border-radius: 3px; + background-color: var(--primary); + position: absolute; + z-index: 1200; + bottom: 0; + transition: all .4s linear; } } - From 0eb29aed2967a064d7ba12bed4122362139ca0bd Mon Sep 17 00:00:00 2001 From: sonnguyenkieio <89386072+sonnguyenkieio@users.noreply.github.com> Date: Tue, 7 Sep 2021 12:16:04 +0700 Subject: [PATCH 07/19] :sparkles: feat: Tab Common --- src/components/common/TabCommon/TabItem/TabItem.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/components/common/TabCommon/TabItem/TabItem.tsx b/src/components/common/TabCommon/TabItem/TabItem.tsx index 62de3c595..6881c2aca 100644 --- a/src/components/common/TabCommon/TabItem/TabItem.tsx +++ b/src/components/common/TabCommon/TabItem/TabItem.tsx @@ -1,22 +1,19 @@ -import classNames from "classnames"; import React from "react" import s from './TabItem.module.scss' interface TabItemProps { - active: string; + active: boolean; children: string; - onClick: () => void; + onClick: (tabIndex: number, tabPane: string) => void; } -const TabItem = ({ active = "", children, onClick } : TabItemProps) => { +const TabItem = ({ active = false, children, onClick } : TabItemProps) => { return ( - + {children} ) } -export default TabItem; \ No newline at end of file +export default TabItem; From b4c2c9a4b30692b3f91543db03006326c2146fbd Mon Sep 17 00:00:00 2001 From: sonnguyenkieio <89386072+sonnguyenkieio@users.noreply.github.com> Date: Tue, 7 Sep 2021 12:16:26 +0700 Subject: [PATCH 08/19] :sparkles: feat: Tab Common --- .../common/TabCommon/TabItem/TabItem.module.scss | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/common/TabCommon/TabItem/TabItem.module.scss b/src/components/common/TabCommon/TabItem/TabItem.module.scss index efb10f1f4..bdbb0b66a 100644 --- a/src/components/common/TabCommon/TabItem/TabItem.module.scss +++ b/src/components/common/TabCommon/TabItem/TabItem.module.scss @@ -5,10 +5,16 @@ padding-top: 1.6rem; padding-bottom: 1.6rem; - &.active { - @apply font-bold; - border-bottom: 2px solid var(--primary); + &:hover { + @apply cursor-pointer; } +} + +.tabItemActive { + @apply font-bold; + margin-right: 4.8rem; + padding-top: 1.6rem; + padding-bottom: 1.6rem; &:hover { @apply cursor-pointer; From 859f645c03189b2fd0f3b4ed8c75e01f85a84d11 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Sep 2021 14:41:53 +0700 Subject: [PATCH 09/19] :hammer: refactor: checkout :%s --- pages/test.tsx | 46 ++++++++----------- .../CardItemCheckout/CardItemCheckout.tsx | 2 +- .../CheckoutBill/CheckoutBill.module.scss | 9 ++++ .../common/CheckoutBill/CheckoutBill.tsx | 30 ++++++++++++ .../CheckoutCollapse.module.scss | 0 .../CheckoutCollapse/CheckoutCollapse.tsx | 0 .../CustomerInfoForm.module.scss | 2 +- .../CustomerInfoForm/CustomerInfoForm.tsx | 0 .../PaymentInfoForm.module.scss | 0 .../PaymentInfoForm/PaymentInfoForm.tsx | 4 +- .../ShippingInfoForm.module.scss | 3 +- .../ShippingInfoForm/ShippingInfoForm.tsx | 0 src/components/common/index.ts | 4 ++ .../components/CheckoutBill/CheckoutBill.tsx | 23 ---------- .../CheckoutBill.module.scss => index.ts} | 0 15 files changed, 69 insertions(+), 54 deletions(-) create mode 100644 src/components/common/CheckoutBill/CheckoutBill.module.scss create mode 100644 src/components/common/CheckoutBill/CheckoutBill.tsx rename src/components/{modules/checkout/components => common}/CheckoutCollapse/CheckoutCollapse.module.scss (100%) rename src/components/{modules/checkout/components => common}/CheckoutCollapse/CheckoutCollapse.tsx (100%) rename src/components/{modules/checkout/components => common}/CustomerInfoForm/CustomerInfoForm.module.scss (84%) rename src/components/{modules/checkout/components => common}/CustomerInfoForm/CustomerInfoForm.tsx (100%) rename src/components/{modules/checkout/components => common}/PaymentInfoForm/PaymentInfoForm.module.scss (100%) rename src/components/{modules/checkout/components => common}/PaymentInfoForm/PaymentInfoForm.tsx (55%) rename src/components/{modules/checkout/components => common}/ShippingInfoForm/ShippingInfoForm.module.scss (94%) rename src/components/{modules/checkout/components => common}/ShippingInfoForm/ShippingInfoForm.tsx (100%) delete mode 100644 src/components/modules/checkout/components/CheckoutBill/CheckoutBill.tsx rename src/components/modules/checkout/{components/CheckoutBill/CheckoutBill.module.scss => index.ts} (100%) diff --git a/pages/test.tsx b/pages/test.tsx index 7f40661be..c1e1f5d5f 100644 --- a/pages/test.tsx +++ b/pages/test.tsx @@ -1,23 +1,26 @@ import { useState } from 'react' import { CardItemCheckout, + CheckoutBill, + CustomerInfoForm, Layout, + ShippingInfoForm, } from 'src/components/common' +import { CardItemCheckoutProps } from 'src/components/common/CardItemCheckout/CardItemCheckout' +import CheckoutCollapse from 'src/components/common/CheckoutCollapse/CheckoutCollapse' import PaginationCommon from 'src/components/common/PaginationCommon/PaginationCommon' -import CheckoutCollapse from 'src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse' -import CustomerInfoForm from 'src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm' -import ShippingInfoForm from 'src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm' import image5 from '../public/assets/images/image5.png' import image6 from '../public/assets/images/image6.png' import image7 from '../public/assets/images/image7.png' import image8 from '../public/assets/images/image8.png' -const dataTest = [ +const dataTest:CardItemCheckoutProps[] = [ { name: 'Tomato', weight: '250g', category: 'VEGGIE', price: 'Rp 27.500', imageSrc: image7.src, + quantity:10 }, { name: 'Carrot', @@ -25,6 +28,7 @@ const dataTest = [ category: 'VEGGIE', price: 'Rp 27.500', imageSrc: image7.src, + quantity:1 }, { name: 'Salad', @@ -32,6 +36,7 @@ const dataTest = [ category: 'VEGGIE', price: 'Rp 27.500', imageSrc: image8.src, + quantity:2 }, { name: 'Tomato', @@ -39,20 +44,7 @@ const dataTest = [ category: 'VEGGIE', price: 'Rp 27.500', imageSrc: image5.src, - }, - { - name: 'Carrot', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - }, - { - name: 'Salad', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image8.src, + quantity:9 }, ] export default function Test() { @@ -72,14 +64,16 @@ export default function Test() { } return ( <> - -
- - - - - - +
+
+ + + + + + +
+
) diff --git a/src/components/common/CardItemCheckout/CardItemCheckout.tsx b/src/components/common/CardItemCheckout/CardItemCheckout.tsx index dd9fb14c5..e67057aa6 100644 --- a/src/components/common/CardItemCheckout/CardItemCheckout.tsx +++ b/src/components/common/CardItemCheckout/CardItemCheckout.tsx @@ -1,7 +1,7 @@ import React from 'react' import s from "./CardItemCheckout.module.scss" import { ProductProps } from 'src/utils/types.utils' -interface CardItemCheckoutProps extends ProductProps { +export interface CardItemCheckoutProps extends ProductProps { quantity:number } diff --git a/src/components/common/CheckoutBill/CheckoutBill.module.scss b/src/components/common/CheckoutBill/CheckoutBill.module.scss new file mode 100644 index 000000000..9c002b2e5 --- /dev/null +++ b/src/components/common/CheckoutBill/CheckoutBill.module.scss @@ -0,0 +1,9 @@ +.warpper{ + max-width: 56.3rem; + @apply flex justify-between flex-col; + .bot{ + .promo{ + padding: 3.2rem; + } + } +} \ No newline at end of file diff --git a/src/components/common/CheckoutBill/CheckoutBill.tsx b/src/components/common/CheckoutBill/CheckoutBill.tsx new file mode 100644 index 000000000..5493565cd --- /dev/null +++ b/src/components/common/CheckoutBill/CheckoutBill.tsx @@ -0,0 +1,30 @@ +import React from 'react' +import s from "./CheckoutBill.module.scss" +import { CardItemCheckout } from '..' +import { CardItemCheckoutProps } from '../CardItemCheckout/CardItemCheckout' + +interface CheckoutBillProps { + data: CardItemCheckoutProps[] +} + +const CheckoutBill = ({data}: CheckoutBillProps) => { + return ( +
+
+ {data.map((item,index)=>{ + return + })} +
+
+
+ +
+
+ +
+
+
+ ) +} + +export default CheckoutBill diff --git a/src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.module.scss b/src/components/common/CheckoutCollapse/CheckoutCollapse.module.scss similarity index 100% rename from src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.module.scss rename to src/components/common/CheckoutCollapse/CheckoutCollapse.module.scss diff --git a/src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.tsx b/src/components/common/CheckoutCollapse/CheckoutCollapse.tsx similarity index 100% rename from src/components/modules/checkout/components/CheckoutCollapse/CheckoutCollapse.tsx rename to src/components/common/CheckoutCollapse/CheckoutCollapse.tsx diff --git a/src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.module.scss b/src/components/common/CustomerInfoForm/CustomerInfoForm.module.scss similarity index 84% rename from src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.module.scss rename to src/components/common/CustomerInfoForm/CustomerInfoForm.module.scss index f5b7ddcde..f31bc57b0 100644 --- a/src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.module.scss +++ b/src/components/common/CustomerInfoForm/CustomerInfoForm.module.scss @@ -1,4 +1,4 @@ -@import "../../../../../styles/utilities"; +@import "../../../styles/utilities"; .warpper{ @apply u-form; padding: 0 5.6rem; diff --git a/src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.tsx b/src/components/common/CustomerInfoForm/CustomerInfoForm.tsx similarity index 100% rename from src/components/modules/checkout/components/CustomerInfoForm/CustomerInfoForm.tsx rename to src/components/common/CustomerInfoForm/CustomerInfoForm.tsx diff --git a/src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.module.scss b/src/components/common/PaymentInfoForm/PaymentInfoForm.module.scss similarity index 100% rename from src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.module.scss rename to src/components/common/PaymentInfoForm/PaymentInfoForm.module.scss diff --git a/src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.tsx b/src/components/common/PaymentInfoForm/PaymentInfoForm.tsx similarity index 55% rename from src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.tsx rename to src/components/common/PaymentInfoForm/PaymentInfoForm.tsx index 4b8410177..6ba65dc43 100644 --- a/src/components/modules/checkout/components/PaymentInfoForm/PaymentInfoForm.tsx +++ b/src/components/common/PaymentInfoForm/PaymentInfoForm.tsx @@ -1,13 +1,13 @@ import React from 'react' +import TabCommon from 'src/components/common/TabCommon/TabCommon' interface PaymentInfoFormProps { } -const PaymentInfoForm = (props: PaymentInfoFormProps) => { +const PaymentInfoForm = ({}: PaymentInfoFormProps) => { return (
-
) } diff --git a/src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.module.scss b/src/components/common/ShippingInfoForm/ShippingInfoForm.module.scss similarity index 94% rename from src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.module.scss rename to src/components/common/ShippingInfoForm/ShippingInfoForm.module.scss index 439fb2628..acda6bc56 100644 --- a/src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.module.scss +++ b/src/components/common/ShippingInfoForm/ShippingInfoForm.module.scss @@ -1,4 +1,5 @@ -@import "../../../../../styles/utilities"; +@import "../../../styles/utilities"; + .warpper{ @apply u-form; padding: 0 5.6rem; diff --git a/src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.tsx b/src/components/common/ShippingInfoForm/ShippingInfoForm.tsx similarity index 100% rename from src/components/modules/checkout/components/ShippingInfoForm/ShippingInfoForm.tsx rename to src/components/common/ShippingInfoForm/ShippingInfoForm.tsx diff --git a/src/components/common/index.ts b/src/components/common/index.ts index bf7ac1d93..fb4f8daf5 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -37,3 +37,7 @@ export { default as CardItemCheckout} from './CardItemCheckout/CardItemCheckout' export { default as CardBlog} from './CardBlog/CardBlog' export { default as RelevantBlogPosts} from './RelevantBlogPosts/RelevantBlogPosts' export { default as CollapseCommon} from './CollapseCommon/CollapseCommon' +export { default as CheckoutBill} from './CheckoutBill/CheckoutBill' +export { default as CustomerInfoForm} from './CustomerInfoForm/CustomerInfoForm' +export { default as ShippingInfoForm} from './ShippingInfoForm/ShippingInfoForm' +export { default as PaymentInfoForm} from './PaymentInfoForm/PaymentInfoForm' diff --git a/src/components/modules/checkout/components/CheckoutBill/CheckoutBill.tsx b/src/components/modules/checkout/components/CheckoutBill/CheckoutBill.tsx deleted file mode 100644 index 96bb74d3f..000000000 --- a/src/components/modules/checkout/components/CheckoutBill/CheckoutBill.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react' -import s from "CheckoutBill.module.scss" -interface CheckoutBillProps { - -} - -const CheckoutBill = ({}: CheckoutBillProps) => { - return ( -
-
- -
-
- -
-
- -
-
- ) -} - -export default CheckoutBill diff --git a/src/components/modules/checkout/components/CheckoutBill/CheckoutBill.module.scss b/src/components/modules/checkout/index.ts similarity index 100% rename from src/components/modules/checkout/components/CheckoutBill/CheckoutBill.module.scss rename to src/components/modules/checkout/index.ts From 69e685b55c03a4711e4b7eb87c2648f5304db85b Mon Sep 17 00:00:00 2001 From: sonnguyenkieio <89386072+sonnguyenkieio@users.noreply.github.com> Date: Tue, 7 Sep 2021 15:44:00 +0700 Subject: [PATCH 10/19] :sparkles: feat: Tab Common --- src/components/common/TabCommon/TabCommon.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/common/TabCommon/TabCommon.tsx b/src/components/common/TabCommon/TabCommon.tsx index 60a2649f6..b837004d6 100644 --- a/src/components/common/TabCommon/TabCommon.tsx +++ b/src/components/common/TabCommon/TabCommon.tsx @@ -4,7 +4,7 @@ import s from './TabCommon.module.scss' import TabItem from './TabItem/TabItem' interface TabCommonProps { - tabs: {ref:RefObject, tabName: string, active: boolean, onClick: (tabIndex: number, tabPane: string) => void}[]; + tabs: {ref:RefObject, tabName: string, active: boolean, onClick: (tabIndex: number, tabPane?: string) => void}[]; defaultActiveTab: number; sliderRef : RefObject; slideToTab: (ref: any) => void; From 4f964266516723ce33fe81b2658e49ab106d72f3 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2021 09:25:46 +0700 Subject: [PATCH 11/19] :hammer: refactor: collapse checkout :%s --- components/auth/ForgotPassword.tsx | 78 ------- components/auth/LoginView.tsx | 104 --------- components/auth/SignUpView.tsx | 114 --------- components/auth/index.ts | 3 - components/cart/CartItem/CartItem.module.css | 32 --- components/cart/CartItem/CartItem.tsx | 151 ------------ components/cart/CartItem/index.ts | 1 - .../CartSidebarView.module.css | 11 - .../cart/CartSidebarView/CartSidebarView.tsx | 129 ----------- components/cart/CartSidebarView/index.ts | 1 - components/cart/index.ts | 2 - .../CheckoutSidebarView.module.css | 7 - .../CheckoutSidebarView.tsx | 89 -------- .../checkout/CheckoutSidebarView/index.ts | 1 - .../PaymentMethodView.module.css | 17 -- .../PaymentMethodView/PaymentMethodView.tsx | 84 ------- .../checkout/PaymentMethodView/index.ts | 1 - .../PaymentWidget/PaymentWidget.module.css | 4 - .../checkout/PaymentWidget/PaymentWidget.tsx | 29 --- components/checkout/PaymentWidget/index.ts | 1 - .../ShippingView/ShippingView.module.css | 21 -- .../checkout/ShippingView/ShippingView.tsx | 78 ------- components/checkout/ShippingView/index.ts | 1 - .../ShippingWidget/ShippingWidget.module.css | 4 - .../ShippingWidget/ShippingWidget.tsx | 33 --- components/checkout/ShippingWidget/index.ts | 1 - components/common/Avatar/Avatar.tsx | 24 -- components/common/Avatar/index.ts | 1 - .../common/FeatureBar/FeatureBar.module.css | 7 - components/common/FeatureBar/FeatureBar.tsx | 39 ---- components/common/FeatureBar/index.ts | 1 - components/common/Footer/Footer.module.css | 13 -- components/common/Footer/Footer.tsx | 117 ---------- components/common/Footer/index.ts | 1 - components/common/Head/Head.tsx | 18 -- components/common/Head/index.ts | 1 - .../HomeAllProductsGrid.module.css | 7 - .../HomeAllProductsGrid.tsx | 47 ---- .../common/HomeAllProductsGrid/index.ts | 1 - .../common/I18nWidget/I18nWidget.module.css | 46 ---- components/common/I18nWidget/I18nWidget.tsx | 101 -------- components/common/I18nWidget/index.ts | 1 - components/common/Layout/Layout.module.css | 4 - components/common/Layout/Layout.tsx | 126 ---------- components/common/Layout/index.ts | 1 - components/common/Navbar/Navbar.module.css | 35 --- components/common/Navbar/Navbar.tsx | 53 ----- components/common/Navbar/NavbarRoot.tsx | 33 --- components/common/Navbar/index.ts | 1 - .../common/Searchbar/Searchbar.module.css | 29 --- components/common/Searchbar/Searchbar.tsx | 63 ----- components/common/Searchbar/index.ts | 1 - .../SidebarLayout/SidebarLayout.module.css | 20 -- .../common/SidebarLayout/SidebarLayout.tsx | 50 ---- components/common/SidebarLayout/index.ts | 1 - .../common/UserNav/DropdownMenu.module.css | 24 -- components/common/UserNav/DropdownMenu.tsx | 125 ---------- components/common/UserNav/UserNav.module.css | 40 ---- components/common/UserNav/UserNav.tsx | 63 ----- components/common/UserNav/index.ts | 1 - components/common/index.ts | 9 - components/icons/ArrowLeft.tsx | 27 --- components/icons/ArrowRight.tsx | 28 --- components/icons/Bag.tsx | 33 --- components/icons/Check.tsx | 21 -- components/icons/ChevronDown.tsx | 20 -- components/icons/ChevronLeft.tsx | 20 -- components/icons/ChevronRight.tsx | 20 -- components/icons/ChevronUp.tsx | 20 -- components/icons/CreditCard.tsx | 21 -- components/icons/Cross.tsx | 21 -- components/icons/DoubleChevron.tsx | 22 -- components/icons/Github.tsx | 20 -- components/icons/Heart.tsx | 22 -- components/icons/Info.tsx | 22 -- components/icons/MapPin.tsx | 20 -- components/icons/Minus.tsx | 15 -- components/icons/Moon.tsx | 20 -- components/icons/Plus.tsx | 22 -- components/icons/Star.tsx | 16 -- components/icons/Sun.tsx | 28 --- components/icons/Trash.tsx | 43 ---- components/icons/Vercel.tsx | 40 ---- components/icons/index.ts | 22 -- .../ProductCard/ProductCard.module.css | 114 --------- .../product/ProductCard/ProductCard.tsx | 132 ----------- components/product/ProductCard/index.ts | 1 - .../product/ProductOptions/ProductOptions.tsx | 50 ---- components/product/ProductOptions/index.ts | 1 - .../ProductSidebar/ProductSidebar.module.css | 84 ------- .../product/ProductSidebar/ProductSidebar.tsx | 89 -------- components/product/ProductSidebar/index.ts | 1 - .../ProductSlider/ProductSlider.module.css | 64 ------ .../product/ProductSlider/ProductSlider.tsx | 136 ----------- components/product/ProductSlider/index.ts | 1 - .../ProductSliderControl.module.css | 29 --- .../ProductSliderControl.tsx | 31 --- .../product/ProductSliderControl/index.ts | 1 - .../product/ProductTag/ProductTag.module.css | 30 --- components/product/ProductTag/ProductTag.tsx | 36 --- components/product/ProductTag/index.ts | 1 - .../ProductView/ProductView.module.css | 60 ----- .../product/ProductView/ProductView.tsx | 109 --------- components/product/ProductView/index.ts | 1 - components/product/Swatch/Swatch.module.css | 54 ----- components/product/Swatch/Swatch.tsx | 62 ----- components/product/Swatch/index.ts | 1 - components/product/helpers.ts | 32 --- components/product/index.ts | 5 - components/ui/Button/Button.module.css | 48 ---- components/ui/Button/Button.tsx | 73 ------ components/ui/Button/index.ts | 2 - components/ui/Collapse/Collapse.module.css | 25 -- components/ui/Collapse/Collapse.tsx | 46 ---- components/ui/Collapse/index.ts | 2 - components/ui/Container/Container.tsx | 27 --- components/ui/Container/index.ts | 1 - components/ui/Grid/Grid.module.css | 154 ------------- components/ui/Grid/Grid.tsx | 34 --- components/ui/Grid/index.ts | 1 - components/ui/Hero/Hero.module.css | 30 --- components/ui/Hero/Hero.tsx | 33 --- components/ui/Hero/index.ts | 1 - components/ui/Input/Input.module.css | 7 - components/ui/Input/Input.tsx | 37 --- components/ui/Input/index.ts | 1 - components/ui/Link/Link.tsx | 11 - components/ui/Link/index.ts | 1 - .../ui/LoadingDots/LoadingDots.module.css | 33 --- components/ui/LoadingDots/LoadingDots.tsx | 13 -- components/ui/LoadingDots/index.ts | 1 - components/ui/Logo/Logo.tsx | 21 -- components/ui/Logo/index.ts | 1 - components/ui/Marquee/Marquee.module.css | 22 -- components/ui/Marquee/Marquee.tsx | 39 ---- components/ui/Marquee/index.ts | 1 - components/ui/Modal/Modal.module.css | 17 -- components/ui/Modal/Modal.tsx | 59 ----- components/ui/Modal/index.ts | 1 - components/ui/Quantity/Quantity.module.css | 27 --- components/ui/Quantity/Quantity.tsx | 62 ----- components/ui/Quantity/index.ts | 2 - components/ui/README.md | 3 - components/ui/Rating/Rating.tsx | 27 --- components/ui/Rating/index.ts | 2 - components/ui/Sidebar/Sidebar.module.css | 14 -- components/ui/Sidebar/Sidebar.tsx | 46 ---- components/ui/Sidebar/index.ts | 1 - components/ui/Skeleton/Skeleton.module.css | 48 ---- components/ui/Skeleton/Skeleton.tsx | 57 ----- components/ui/Skeleton/index.ts | 1 - components/ui/Text/Text.module.css | 15 -- components/ui/Text/Text.tsx | 70 ------ components/ui/Text/index.ts | 1 - components/ui/context.tsx | 216 ------------------ components/ui/index.ts | 16 -- .../WishlistButton/WishlistButton.module.css | 33 --- .../WishlistButton/WishlistButton.tsx | 84 ------- components/wishlist/WishlistButton/index.ts | 1 - components/wishlist/index.ts | 1 - grocery-vercel-commerce | 1 - next.config.js | 4 + pages/404.tsx | 22 +- pages/[...pages].tsx | 86 ------- pages/cart.tsx | 50 ---- pages/demo.tsx | 13 ++ pages/index.tsx | 32 +-- pages/product/[slug].tsx | 82 +------ pages/test.tsx | 23 +- .../BreadcrumbCommon.module.scss | 6 +- .../BreadcrumbCommon/BreadcrumbCommon.tsx | 45 ++-- .../BreadcrumbItem/BreadcrumbItem.module.scss | 5 + .../BreadcrumbItem/BreadcrumbItem.tsx | 3 +- .../BreadcrumbSeparator.tsx | 2 +- .../ButtonCommon/ButtonCommon.module.scss | 8 +- .../CarouselCommon/CarouselCommon.module.scss | 1 + .../common/CartDrawer/CartDrawer.module.scss | 12 + .../common/CartDrawer/CartDrawer.tsx | 35 +++ .../CartCheckoutButton.module.scss | 6 + .../CartCheckoutButton/CartCheckoutButton.tsx | 13 ++ .../CartMessage/CartMessage.module.scss | 16 ++ .../components/CartMessage/CartMessage.tsx | 18 ++ .../CartRecommendation.module.scss | 26 +++ .../CartRecommendation/CartRecommendation.tsx | 43 ++++ .../ProductCartItem.module.scss | 54 +++++ .../ProductCartItem/ProductCartItem.tsx | 56 +++++ .../ProductsInCart/ProductsInCart.module.scss | 9 + .../ProductsInCart/ProductsInCart.tsx | 30 +++ .../CheckoutBill/CheckoutBill.module.scss | 37 ++- .../common/CheckoutBill/CheckoutBill.tsx | 54 +++-- .../CheckoutCollapse/CheckoutCollapse.tsx | 15 +- .../CustomerInfoForm/CustomerInfoForm.tsx | 33 +-- .../DrawerCommon/DrawerCommon.module.scss | 52 +++++ .../common/DrawerCommon/DrawerCommon.tsx | 36 +++ src/components/common/Header/Header.tsx | 2 +- .../HeaderMenu/HeaderMenu.module.scss | 5 +- .../components/HeaderMenu/HeaderMenu.tsx | 7 +- .../ImgWithLink/ImgWithLink.module.scss | 9 + .../common/ImgWithLink/ImgWithLink.tsx | 18 ++ src/components/common/Layout/Layout.tsx | 16 +- .../InfoProducts/InfoProducts.module.scss | 23 ++ .../InfoProducts/InfoProducts.tsx | 26 +++ .../ListProductWithInfo.module.scss | 48 ++++ .../ListProductWithInfo.tsx | 51 +++++ src/components/common/Logo/Logo.module.scss | 8 +- src/components/common/Logo/Logo.tsx | 20 +- .../MenuDropdown/MenuDropdown.module.scss | 13 ++ .../common/MenuDropdown/MenuDropdown.tsx | 4 +- .../ProductCard/ProductCard.module.scss | 6 +- .../common/ProductCard/ProductCard.tsx | 9 + .../ProductNotSell/ProductNotSell.module.scss | 27 +++ .../ProductNotSell/ProductNotSell.tsx | 28 +++ .../common/QuanittyInput/QuanittyInput.tsx | 6 +- .../common/RecipeCard/RecipeCard.module.scss | 3 + .../RecipeDetail/RecipeDetail.module.scss | 0 .../common/RecipeDetail/RecipeDetail.tsx | 23 ++ .../RecipeBriefInfo.module.scss | 19 ++ .../RecipeBriefInfo/RecipeBriefInfo.tsx | 29 +++ .../RecipeDetailInfo.module.scss | 61 +++++ .../RecipeDetailInfo/RecipeDetailInfo.tsx | 59 +++++ .../RecipeIngredient.module.scss | 21 ++ .../RecipeIngredient/RecipeIngredient.tsx | 33 +++ .../common/ScrollToTop/ScrollTarget.tsx | 15 -- .../common/ScrollToTop/ScrollToTop.tsx | 7 +- .../ShippingInfoForm/ShippingInfoForm.tsx | 22 +- .../ViewAllItem/ViewAllItem.module.scss | 2 +- src/components/common/index.ts | 5 +- src/components/hooks/index.ts | 1 + src/components/hooks/useModalCommon.tsx | 4 +- src/components/icons/IconCirclePlus.tsx | 20 ++ src/components/icons/IconClose.tsx | 20 ++ src/components/icons/IconDelete.tsx | 11 + src/components/icons/IconLocation.tsx | 11 + src/components/icons/IconMinus.tsx | 8 +- src/components/icons/IconPeople.tsx | 11 + src/components/icons/IconPlus.tsx | 8 +- src/components/icons/IconTime.tsx | 11 + src/components/icons/index.ts | 8 +- .../CheckoutInfo/CheckoutInfo.module.scss | 7 + .../checkout/CheckoutInfo/CheckoutInfo.tsx | 87 +++++++ src/components/modules/checkout/index.ts | 1 + .../ProductInfoDetail.module.scss | 10 + .../ProductInfoDetail/ProductInfoDetail.tsx | 20 ++ .../ProductImgs/ProductImgs.module.scss | 9 + .../components/ProductImgs/ProductImgs.tsx | 40 ++++ .../ProductInfo/ProductInfo.module.scss | 81 +++++++ .../components/ProductInfo/ProductInfo.tsx | 46 ++++ .../RecommendedRecipes.module.scss | 27 +++ .../RecommendedRecipes/RecommendedRecipes.tsx | 51 +++++ .../ReleventProducts/ReleventProducts.tsx | 15 ++ .../ViewedProducts/ViewedProducts.tsx | 15 ++ .../modules/product-detail/index.ts | 4 + src/styles/_base.scss | 7 +- src/styles/_utilities.scss | 24 ++ src/utils/constanst.utils.ts | 3 + src/utils/demo-data.ts | 215 +++++++++++++++++ src/utils/language.utils.ts | 2 + src/utils/types.utils.ts | 26 ++- tailwind.config.js | 17 +- 259 files changed, 1939 insertions(+), 5672 deletions(-) delete mode 100644 components/auth/ForgotPassword.tsx delete mode 100644 components/auth/LoginView.tsx delete mode 100644 components/auth/SignUpView.tsx delete mode 100644 components/auth/index.ts delete mode 100644 components/cart/CartItem/CartItem.module.css delete mode 100644 components/cart/CartItem/CartItem.tsx delete mode 100644 components/cart/CartItem/index.ts delete mode 100644 components/cart/CartSidebarView/CartSidebarView.module.css delete mode 100644 components/cart/CartSidebarView/CartSidebarView.tsx delete mode 100644 components/cart/CartSidebarView/index.ts delete mode 100644 components/cart/index.ts delete mode 100644 components/checkout/CheckoutSidebarView/CheckoutSidebarView.module.css delete mode 100644 components/checkout/CheckoutSidebarView/CheckoutSidebarView.tsx delete mode 100644 components/checkout/CheckoutSidebarView/index.ts delete mode 100644 components/checkout/PaymentMethodView/PaymentMethodView.module.css delete mode 100644 components/checkout/PaymentMethodView/PaymentMethodView.tsx delete mode 100644 components/checkout/PaymentMethodView/index.ts delete mode 100644 components/checkout/PaymentWidget/PaymentWidget.module.css delete mode 100644 components/checkout/PaymentWidget/PaymentWidget.tsx delete mode 100644 components/checkout/PaymentWidget/index.ts delete mode 100644 components/checkout/ShippingView/ShippingView.module.css delete mode 100644 components/checkout/ShippingView/ShippingView.tsx delete mode 100644 components/checkout/ShippingView/index.ts delete mode 100644 components/checkout/ShippingWidget/ShippingWidget.module.css delete mode 100644 components/checkout/ShippingWidget/ShippingWidget.tsx delete mode 100644 components/checkout/ShippingWidget/index.ts delete mode 100644 components/common/Avatar/Avatar.tsx delete mode 100644 components/common/Avatar/index.ts delete mode 100644 components/common/FeatureBar/FeatureBar.module.css delete mode 100644 components/common/FeatureBar/FeatureBar.tsx delete mode 100644 components/common/FeatureBar/index.ts delete mode 100644 components/common/Footer/Footer.module.css delete mode 100644 components/common/Footer/Footer.tsx delete mode 100644 components/common/Footer/index.ts delete mode 100644 components/common/Head/Head.tsx delete mode 100644 components/common/Head/index.ts delete mode 100644 components/common/HomeAllProductsGrid/HomeAllProductsGrid.module.css delete mode 100644 components/common/HomeAllProductsGrid/HomeAllProductsGrid.tsx delete mode 100644 components/common/HomeAllProductsGrid/index.ts delete mode 100644 components/common/I18nWidget/I18nWidget.module.css delete mode 100644 components/common/I18nWidget/I18nWidget.tsx delete mode 100644 components/common/I18nWidget/index.ts delete mode 100644 components/common/Layout/Layout.module.css delete mode 100644 components/common/Layout/Layout.tsx delete mode 100644 components/common/Layout/index.ts delete mode 100644 components/common/Navbar/Navbar.module.css delete mode 100644 components/common/Navbar/Navbar.tsx delete mode 100644 components/common/Navbar/NavbarRoot.tsx delete mode 100644 components/common/Navbar/index.ts delete mode 100644 components/common/Searchbar/Searchbar.module.css delete mode 100644 components/common/Searchbar/Searchbar.tsx delete mode 100644 components/common/Searchbar/index.ts delete mode 100644 components/common/SidebarLayout/SidebarLayout.module.css delete mode 100644 components/common/SidebarLayout/SidebarLayout.tsx delete mode 100644 components/common/SidebarLayout/index.ts delete mode 100644 components/common/UserNav/DropdownMenu.module.css delete mode 100644 components/common/UserNav/DropdownMenu.tsx delete mode 100644 components/common/UserNav/UserNav.module.css delete mode 100644 components/common/UserNav/UserNav.tsx delete mode 100644 components/common/UserNav/index.ts delete mode 100644 components/common/index.ts delete mode 100644 components/icons/ArrowLeft.tsx delete mode 100644 components/icons/ArrowRight.tsx delete mode 100644 components/icons/Bag.tsx delete mode 100644 components/icons/Check.tsx delete mode 100644 components/icons/ChevronDown.tsx delete mode 100644 components/icons/ChevronLeft.tsx delete mode 100644 components/icons/ChevronRight.tsx delete mode 100644 components/icons/ChevronUp.tsx delete mode 100644 components/icons/CreditCard.tsx delete mode 100644 components/icons/Cross.tsx delete mode 100644 components/icons/DoubleChevron.tsx delete mode 100644 components/icons/Github.tsx delete mode 100644 components/icons/Heart.tsx delete mode 100644 components/icons/Info.tsx delete mode 100644 components/icons/MapPin.tsx delete mode 100644 components/icons/Minus.tsx delete mode 100644 components/icons/Moon.tsx delete mode 100644 components/icons/Plus.tsx delete mode 100644 components/icons/Star.tsx delete mode 100644 components/icons/Sun.tsx delete mode 100644 components/icons/Trash.tsx delete mode 100644 components/icons/Vercel.tsx delete mode 100644 components/icons/index.ts delete mode 100644 components/product/ProductCard/ProductCard.module.css delete mode 100644 components/product/ProductCard/ProductCard.tsx delete mode 100644 components/product/ProductCard/index.ts delete mode 100644 components/product/ProductOptions/ProductOptions.tsx delete mode 100644 components/product/ProductOptions/index.ts delete mode 100644 components/product/ProductSidebar/ProductSidebar.module.css delete mode 100644 components/product/ProductSidebar/ProductSidebar.tsx delete mode 100644 components/product/ProductSidebar/index.ts delete mode 100644 components/product/ProductSlider/ProductSlider.module.css delete mode 100644 components/product/ProductSlider/ProductSlider.tsx delete mode 100644 components/product/ProductSlider/index.ts delete mode 100644 components/product/ProductSliderControl/ProductSliderControl.module.css delete mode 100644 components/product/ProductSliderControl/ProductSliderControl.tsx delete mode 100644 components/product/ProductSliderControl/index.ts delete mode 100644 components/product/ProductTag/ProductTag.module.css delete mode 100644 components/product/ProductTag/ProductTag.tsx delete mode 100644 components/product/ProductTag/index.ts delete mode 100644 components/product/ProductView/ProductView.module.css delete mode 100644 components/product/ProductView/ProductView.tsx delete mode 100644 components/product/ProductView/index.ts delete mode 100644 components/product/Swatch/Swatch.module.css delete mode 100644 components/product/Swatch/Swatch.tsx delete mode 100644 components/product/Swatch/index.ts delete mode 100644 components/product/helpers.ts delete mode 100644 components/product/index.ts delete mode 100644 components/ui/Button/Button.module.css delete mode 100644 components/ui/Button/Button.tsx delete mode 100644 components/ui/Button/index.ts delete mode 100644 components/ui/Collapse/Collapse.module.css delete mode 100644 components/ui/Collapse/Collapse.tsx delete mode 100644 components/ui/Collapse/index.ts delete mode 100644 components/ui/Container/Container.tsx delete mode 100644 components/ui/Container/index.ts delete mode 100644 components/ui/Grid/Grid.module.css delete mode 100644 components/ui/Grid/Grid.tsx delete mode 100644 components/ui/Grid/index.ts delete mode 100644 components/ui/Hero/Hero.module.css delete mode 100644 components/ui/Hero/Hero.tsx delete mode 100644 components/ui/Hero/index.ts delete mode 100644 components/ui/Input/Input.module.css delete mode 100644 components/ui/Input/Input.tsx delete mode 100644 components/ui/Input/index.ts delete mode 100644 components/ui/Link/Link.tsx delete mode 100644 components/ui/Link/index.ts delete mode 100644 components/ui/LoadingDots/LoadingDots.module.css delete mode 100644 components/ui/LoadingDots/LoadingDots.tsx delete mode 100644 components/ui/LoadingDots/index.ts delete mode 100644 components/ui/Logo/Logo.tsx delete mode 100644 components/ui/Logo/index.ts delete mode 100644 components/ui/Marquee/Marquee.module.css delete mode 100644 components/ui/Marquee/Marquee.tsx delete mode 100644 components/ui/Marquee/index.ts delete mode 100644 components/ui/Modal/Modal.module.css delete mode 100644 components/ui/Modal/Modal.tsx delete mode 100644 components/ui/Modal/index.ts delete mode 100644 components/ui/Quantity/Quantity.module.css delete mode 100644 components/ui/Quantity/Quantity.tsx delete mode 100644 components/ui/Quantity/index.ts delete mode 100644 components/ui/README.md delete mode 100644 components/ui/Rating/Rating.tsx delete mode 100644 components/ui/Rating/index.ts delete mode 100644 components/ui/Sidebar/Sidebar.module.css delete mode 100644 components/ui/Sidebar/Sidebar.tsx delete mode 100644 components/ui/Sidebar/index.ts delete mode 100644 components/ui/Skeleton/Skeleton.module.css delete mode 100644 components/ui/Skeleton/Skeleton.tsx delete mode 100644 components/ui/Skeleton/index.ts delete mode 100644 components/ui/Text/Text.module.css delete mode 100644 components/ui/Text/Text.tsx delete mode 100644 components/ui/Text/index.ts delete mode 100644 components/ui/context.tsx delete mode 100644 components/ui/index.ts delete mode 100644 components/wishlist/WishlistButton/WishlistButton.module.css delete mode 100644 components/wishlist/WishlistButton/WishlistButton.tsx delete mode 100644 components/wishlist/WishlistButton/index.ts delete mode 100644 components/wishlist/index.ts delete mode 160000 grocery-vercel-commerce delete mode 100644 pages/[...pages].tsx delete mode 100644 pages/cart.tsx create mode 100644 pages/demo.tsx create mode 100644 src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.module.scss create mode 100644 src/components/common/CartDrawer/CartDrawer.module.scss create mode 100644 src/components/common/CartDrawer/CartDrawer.tsx create mode 100644 src/components/common/CartDrawer/components/CartCheckoutButton/CartCheckoutButton.module.scss create mode 100644 src/components/common/CartDrawer/components/CartCheckoutButton/CartCheckoutButton.tsx create mode 100644 src/components/common/CartDrawer/components/CartMessage/CartMessage.module.scss create mode 100644 src/components/common/CartDrawer/components/CartMessage/CartMessage.tsx create mode 100644 src/components/common/CartDrawer/components/CartRecommendation/CartRecommendation.module.scss create mode 100644 src/components/common/CartDrawer/components/CartRecommendation/CartRecommendation.tsx create mode 100644 src/components/common/CartDrawer/components/ProductCartItem/ProductCartItem.module.scss create mode 100644 src/components/common/CartDrawer/components/ProductCartItem/ProductCartItem.tsx create mode 100644 src/components/common/CartDrawer/components/ProductsInCart/ProductsInCart.module.scss create mode 100644 src/components/common/CartDrawer/components/ProductsInCart/ProductsInCart.tsx create mode 100644 src/components/common/DrawerCommon/DrawerCommon.module.scss create mode 100644 src/components/common/DrawerCommon/DrawerCommon.tsx create mode 100644 src/components/common/ImgWithLink/ImgWithLink.module.scss create mode 100644 src/components/common/ImgWithLink/ImgWithLink.tsx create mode 100644 src/components/common/ListProductWithInfo/InfoProducts/InfoProducts.module.scss create mode 100644 src/components/common/ListProductWithInfo/InfoProducts/InfoProducts.tsx create mode 100644 src/components/common/ListProductWithInfo/ListProductWithInfo.module.scss create mode 100644 src/components/common/ListProductWithInfo/ListProductWithInfo.tsx create mode 100644 src/components/common/ProductCard/ProductNotSell/ProductNotSell.module.scss create mode 100644 src/components/common/ProductCard/ProductNotSell/ProductNotSell.tsx rename components/ui/Rating/Rating.module.css => src/components/common/RecipeDetail/RecipeDetail.module.scss (100%) create mode 100644 src/components/common/RecipeDetail/RecipeDetail.tsx create mode 100644 src/components/common/RecipeDetail/components/RecipeBriefInfo/RecipeBriefInfo.module.scss create mode 100644 src/components/common/RecipeDetail/components/RecipeBriefInfo/RecipeBriefInfo.tsx create mode 100644 src/components/common/RecipeDetail/components/RecipeDetailInfo/RecipeDetailInfo.module.scss create mode 100644 src/components/common/RecipeDetail/components/RecipeDetailInfo/RecipeDetailInfo.tsx create mode 100644 src/components/common/RecipeDetail/components/RecipeIngredient/RecipeIngredient.module.scss create mode 100644 src/components/common/RecipeDetail/components/RecipeIngredient/RecipeIngredient.tsx delete mode 100644 src/components/common/ScrollToTop/ScrollTarget.tsx create mode 100644 src/components/hooks/index.ts create mode 100644 src/components/icons/IconCirclePlus.tsx create mode 100644 src/components/icons/IconClose.tsx create mode 100644 src/components/icons/IconDelete.tsx create mode 100644 src/components/icons/IconLocation.tsx create mode 100644 src/components/icons/IconPeople.tsx create mode 100644 src/components/icons/IconTime.tsx create mode 100644 src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss create mode 100644 src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx create mode 100644 src/components/modules/product-detail/ProductInfoDetail/ProductInfoDetail.module.scss create mode 100644 src/components/modules/product-detail/ProductInfoDetail/ProductInfoDetail.tsx create mode 100644 src/components/modules/product-detail/ProductInfoDetail/components/ProductImgs/ProductImgs.module.scss create mode 100644 src/components/modules/product-detail/ProductInfoDetail/components/ProductImgs/ProductImgs.tsx create mode 100644 src/components/modules/product-detail/ProductInfoDetail/components/ProductInfo/ProductInfo.module.scss create mode 100644 src/components/modules/product-detail/ProductInfoDetail/components/ProductInfo/ProductInfo.tsx create mode 100644 src/components/modules/product-detail/RecommendedRecipes/RecommendedRecipes.module.scss create mode 100644 src/components/modules/product-detail/RecommendedRecipes/RecommendedRecipes.tsx create mode 100644 src/components/modules/product-detail/ReleventProducts/ReleventProducts.tsx create mode 100644 src/components/modules/product-detail/ViewedProducts/ViewedProducts.tsx create mode 100644 src/components/modules/product-detail/index.ts create mode 100644 src/utils/demo-data.ts diff --git a/components/auth/ForgotPassword.tsx b/components/auth/ForgotPassword.tsx deleted file mode 100644 index dbac371c7..000000000 --- a/components/auth/ForgotPassword.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import { FC, useEffect, useState, useCallback } from 'react' -import { validate } from 'email-validator' -import { useUI } from '@components/ui/context' -import { Logo, Button, Input } from '@components/ui' - -interface Props {} - -const ForgotPassword: FC = () => { - // Form State - const [email, setEmail] = useState('') - const [loading, setLoading] = useState(false) - const [message, setMessage] = useState('') - const [dirty, setDirty] = useState(false) - const [disabled, setDisabled] = useState(false) - - const { setModalView, closeModal } = useUI() - - const handleResetPassword = async (e: React.SyntheticEvent) => { - e.preventDefault() - - if (!dirty && !disabled) { - setDirty(true) - handleValidation() - } - } - - const handleValidation = useCallback(() => { - // Unable to send form unless fields are valid. - if (dirty) { - setDisabled(!validate(email)) - } - }, [email, dirty]) - - useEffect(() => { - handleValidation() - }, [handleValidation]) - - return ( -
-
- -
-
- {message && ( -
{message}
- )} - - -
- -
- - - Do you have an account? - {` `} - setModalView('LOGIN_VIEW')} - > - Log In - - -
-
- ) -} - -export default ForgotPassword diff --git a/components/auth/LoginView.tsx b/components/auth/LoginView.tsx deleted file mode 100644 index 35ff98f66..000000000 --- a/components/auth/LoginView.tsx +++ /dev/null @@ -1,104 +0,0 @@ -import { FC, useEffect, useState, useCallback } from 'react' -import { Logo, Button, Input } from '@components/ui' -import useLogin from '@framework/auth/use-login' -import { useUI } from '@components/ui/context' -import { validate } from 'email-validator' - -interface Props {} - -const LoginView: FC = () => { - // Form State - const [email, setEmail] = useState('') - const [password, setPassword] = useState('') - const [loading, setLoading] = useState(false) - const [message, setMessage] = useState('') - const [dirty, setDirty] = useState(false) - const [disabled, setDisabled] = useState(false) - const { setModalView, closeModal } = useUI() - - const login = useLogin() - - const handleLogin = async (e: React.SyntheticEvent) => { - e.preventDefault() - - if (!dirty && !disabled) { - setDirty(true) - handleValidation() - } - - try { - setLoading(true) - setMessage('') - await login({ - email, - password, - }) - setLoading(false) - closeModal() - } catch ({ errors }) { - setMessage(errors[0].message) - setLoading(false) - } - } - - const handleValidation = useCallback(() => { - // Test for Alphanumeric password - const validPassword = /^(?=.*[a-zA-Z])(?=.*[0-9])/.test(password) - - // Unable to send form unless fields are valid. - if (dirty) { - setDisabled(!validate(email) || password.length < 7 || !validPassword) - } - }, [email, password, dirty]) - - useEffect(() => { - handleValidation() - }, [handleValidation]) - - return ( -
-
- -
-
- {message && ( - - )} - - - - -
- Don't have an account? - {` `} - setModalView('SIGNUP_VIEW')} - > - Sign Up - -
-
-
- ) -} - -export default LoginView diff --git a/components/auth/SignUpView.tsx b/components/auth/SignUpView.tsx deleted file mode 100644 index a85a3bc27..000000000 --- a/components/auth/SignUpView.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import { FC, useEffect, useState, useCallback } from 'react' -import { validate } from 'email-validator' -import { Info } from '@components/icons' -import { useUI } from '@components/ui/context' -import { Logo, Button, Input } from '@components/ui' -import useSignup from '@framework/auth/use-signup' - -interface Props {} - -const SignUpView: FC = () => { - // Form State - const [email, setEmail] = useState('') - const [password, setPassword] = useState('') - const [firstName, setFirstName] = useState('') - const [lastName, setLastName] = useState('') - const [loading, setLoading] = useState(false) - const [message, setMessage] = useState('') - const [dirty, setDirty] = useState(false) - const [disabled, setDisabled] = useState(false) - - const signup = useSignup() - const { setModalView, closeModal } = useUI() - - const handleSignup = async (e: React.SyntheticEvent) => { - e.preventDefault() - - if (!dirty && !disabled) { - setDirty(true) - handleValidation() - } - - try { - setLoading(true) - setMessage('') - await signup({ - email, - firstName, - lastName, - password, - }) - setLoading(false) - closeModal() - } catch ({ errors }) { - setMessage(errors[0].message) - setLoading(false) - } - } - - const handleValidation = useCallback(() => { - // Test for Alphanumeric password - const validPassword = /^(?=.*[a-zA-Z])(?=.*[0-9])/.test(password) - - // Unable to send form unless fields are valid. - if (dirty) { - setDisabled(!validate(email) || password.length < 7 || !validPassword) - } - }, [email, password, dirty]) - - useEffect(() => { - handleValidation() - }, [handleValidation]) - - return ( -
-
- -
-
- {message && ( -
{message}
- )} - - - - - - - - {' '} - - Info: Passwords must be longer than 7 chars and - include numbers.{' '} - - -
- -
- - - Do you have an account? - {` `} - setModalView('LOGIN_VIEW')} - > - Log In - - -
-
- ) -} - -export default SignUpView diff --git a/components/auth/index.ts b/components/auth/index.ts deleted file mode 100644 index 11571fac7..000000000 --- a/components/auth/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { default as LoginView } from './LoginView' -export { default as SignUpView } from './SignUpView' -export { default as ForgotPassword } from './ForgotPassword' diff --git a/components/cart/CartItem/CartItem.module.css b/components/cart/CartItem/CartItem.module.css deleted file mode 100644 index dd43314fb..000000000 --- a/components/cart/CartItem/CartItem.module.css +++ /dev/null @@ -1,32 +0,0 @@ -.root { - @apply flex flex-col py-4; -} - -.root:first-child { - padding-top: 0; -} - -.quantity { - appearance: textfield; - @apply w-8 border-accent-2 border mx-3 rounded text-center text-sm text-black; -} - -.quantity::-webkit-outer-spin-button, -.quantity::-webkit-inner-spin-button { - @apply appearance-none m-0; -} - -.productImage { - position: absolute; - transform: scale(1.9); - width: 100%; - height: 100%; - left: 30% !important; - top: 30% !important; - z-index: 1; -} - -.productName { - @apply font-medium cursor-pointer pb-1; - margin-top: -4px; -} diff --git a/components/cart/CartItem/CartItem.tsx b/components/cart/CartItem/CartItem.tsx deleted file mode 100644 index a59024e06..000000000 --- a/components/cart/CartItem/CartItem.tsx +++ /dev/null @@ -1,151 +0,0 @@ -import { ChangeEvent, FocusEventHandler, useEffect, useState } from 'react' -import cn from 'classnames' -import Image from 'next/image' -import Link from 'next/link' -import s from './CartItem.module.css' -import { Trash, Plus, Minus, Cross } from '@components/icons' -import { useUI } from '@components/ui/context' -import type { LineItem } from '@commerce/types/cart' -import usePrice from '@framework/product/use-price' -import useUpdateItem from '@framework/cart/use-update-item' -import useRemoveItem from '@framework/cart/use-remove-item' -import Quantity from '@components/ui/Quantity' - -type ItemOption = { - name: string - nameId: number - value: string - valueId: number -} - -const CartItem = ({ - item, - variant = 'default', - currencyCode, - ...rest -}: { - variant?: 'default' | 'display' - item: LineItem - currencyCode: string -}) => { - const { closeSidebarIfPresent } = useUI() - const [removing, setRemoving] = useState(false) - const [quantity, setQuantity] = useState(item.quantity) - const removeItem = useRemoveItem() - const updateItem = useUpdateItem({ item }) - - const { price } = usePrice({ - amount: item.variant.price * item.quantity, - baseAmount: item.variant.listPrice * item.quantity, - currencyCode, - }) - - const handleChange = async ({ - target: { value }, - }: ChangeEvent) => { - setQuantity(Number(value)) - await updateItem({ quantity: Number(value) }) - } - - const increaseQuantity = async (n = 1) => { - const val = Number(quantity) + n - setQuantity(val) - await updateItem({ quantity: val }) - } - - const handleRemove = async () => { - setRemoving(true) - try { - await removeItem(item) - } catch (error) { - setRemoving(false) - } - } - - // TODO: Add a type for this - const options = (item as any).options - - useEffect(() => { - // Reset the quantity state if the item quantity changes - if (item.quantity !== Number(quantity)) { - setQuantity(item.quantity) - } - }, [item.quantity]) - - return ( -
  • -
    -
    - - closeSidebarIfPresent()} - className={s.productImage} - width={150} - height={150} - src={item.variant.image!.url} - alt={item.variant.image!.altText} - unoptimized - /> - -
    -
    - - closeSidebarIfPresent()} - > - {item.name} - - - {options && options.length > 0 && ( -
    - {options.map((option: ItemOption, i: number) => ( -
    - {option.name} - {option.name === 'Color' ? ( - - ) : ( - - {option.value} - - )} - {i === options.length - 1 ? '' : } -
    - ))} -
    - )} - {variant === 'display' && ( -
    {quantity}x
    - )} -
    -
    - {price} -
    -
    - {variant === 'default' && ( - increaseQuantity(1)} - decrease={() => increaseQuantity(-1)} - /> - )} -
  • - ) -} - -export default CartItem diff --git a/components/cart/CartItem/index.ts b/components/cart/CartItem/index.ts deleted file mode 100644 index b5f6dc52f..000000000 --- a/components/cart/CartItem/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './CartItem' diff --git a/components/cart/CartSidebarView/CartSidebarView.module.css b/components/cart/CartSidebarView/CartSidebarView.module.css deleted file mode 100644 index c9ffbed50..000000000 --- a/components/cart/CartSidebarView/CartSidebarView.module.css +++ /dev/null @@ -1,11 +0,0 @@ -.root { - min-height: 100vh; -} - -.root.empty { - @apply bg-secondary text-secondary; -} - -.lineItemsList { - @apply py-4 space-y-6 sm:py-0 sm:space-y-0 sm:divide-y sm:divide-accent-2 border-accent-2; -} diff --git a/components/cart/CartSidebarView/CartSidebarView.tsx b/components/cart/CartSidebarView/CartSidebarView.tsx deleted file mode 100644 index 128b928a8..000000000 --- a/components/cart/CartSidebarView/CartSidebarView.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import cn from 'classnames' -import Link from 'next/link' -import { FC } from 'react' -import s from './CartSidebarView.module.css' -import CartItem from '../CartItem' -import { Button, Text } from '@components/ui' -import { useUI } from '@components/ui/context' -import { Bag, Cross, Check } from '@components/icons' -import useCart from '@framework/cart/use-cart' -import usePrice from '@framework/product/use-price' -import SidebarLayout from '@components/common/SidebarLayout' - -const CartSidebarView: FC = () => { - const { closeSidebar, setSidebarView } = useUI() - const { data, isLoading, isEmpty } = useCart() - - const { price: subTotal } = usePrice( - data && { - amount: Number(data.subtotalPrice), - currencyCode: data.currency.code, - } - ) - const { price: total } = usePrice( - data && { - amount: Number(data.totalPrice), - currencyCode: data.currency.code, - } - ) - const handleClose = () => closeSidebar() - const goToCheckout = () => setSidebarView('CHECKOUT_VIEW') - - const error = null - const success = null - - return ( - - {isLoading || isEmpty ? ( -
    - - - -

    - Your cart is empty -

    -

    - Biscuit oat cake wafer icing ice cream tiramisu pudding cupcake. -

    -
    - ) : error ? ( -
    - - - -

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

    -
    - ) : success ? ( -
    - - - -

    - Thank you for your order. -

    -
    - ) : ( - <> -
    - - - My Cart - - -
      - {data!.lineItems.map((item: any) => ( - - ))} -
    -
    - -
    -
      -
    • - Subtotal - {subTotal} -
    • -
    • - Taxes - Calculated at checkout -
    • -
    • - Shipping - FREE -
    • -
    -
    - Total - {total} -
    -
    - {process.env.COMMERCE_CUSTOMCHECKOUT_ENABLED ? ( - - ) : ( - - )} -
    -
    - - )} -
    - ) -} - -export default CartSidebarView diff --git a/components/cart/CartSidebarView/index.ts b/components/cart/CartSidebarView/index.ts deleted file mode 100644 index 0262e448e..000000000 --- a/components/cart/CartSidebarView/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './CartSidebarView' diff --git a/components/cart/index.ts b/components/cart/index.ts deleted file mode 100644 index 3e53fa34a..000000000 --- a/components/cart/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as CartSidebarView } from './CartSidebarView' -export { default as CartItem } from './CartItem' diff --git a/components/checkout/CheckoutSidebarView/CheckoutSidebarView.module.css b/components/checkout/CheckoutSidebarView/CheckoutSidebarView.module.css deleted file mode 100644 index 34c1b487c..000000000 --- a/components/checkout/CheckoutSidebarView/CheckoutSidebarView.module.css +++ /dev/null @@ -1,7 +0,0 @@ -.root { - min-height: calc(100vh - 322px); -} - -.lineItemsList { - @apply py-4 space-y-6 sm:py-0 sm:space-y-0 sm:divide-y sm:divide-accent-2 border-accent-2; -} diff --git a/components/checkout/CheckoutSidebarView/CheckoutSidebarView.tsx b/components/checkout/CheckoutSidebarView/CheckoutSidebarView.tsx deleted file mode 100644 index fb562e7af..000000000 --- a/components/checkout/CheckoutSidebarView/CheckoutSidebarView.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import cn from 'classnames' -import Link from 'next/link' -import { FC } from 'react' -import CartItem from '@components/cart/CartItem' -import { Button, Text } from '@components/ui' -import { useUI } from '@components/ui/context' -import useCart from '@framework/cart/use-cart' -import usePrice from '@framework/product/use-price' -import ShippingWidget from '../ShippingWidget' -import PaymentWidget from '../PaymentWidget' -import SidebarLayout from '@components/common/SidebarLayout' -import s from './CheckoutSidebarView.module.css' - -const CheckoutSidebarView: FC = () => { - const { setSidebarView } = useUI() - const { data } = useCart() - - const { price: subTotal } = usePrice( - data && { - amount: Number(data.subtotalPrice), - currencyCode: data.currency.code, - } - ) - const { price: total } = usePrice( - data && { - amount: Number(data.totalPrice), - currencyCode: data.currency.code, - } - ) - - return ( - setSidebarView('CART_VIEW')} - > -
    - - Checkout - - - setSidebarView('PAYMENT_VIEW')} /> - setSidebarView('SHIPPING_VIEW')} /> - -
      - {data!.lineItems.map((item: any) => ( - - ))} -
    -
    - -
    -
      -
    • - Subtotal - {subTotal} -
    • -
    • - Taxes - Calculated at checkout -
    • -
    • - Shipping - FREE -
    • -
    -
    - Total - {total} -
    -
    - {/* Once data is correcly filled */} - {/* */} - -
    -
    -
    - ) -} - -export default CheckoutSidebarView diff --git a/components/checkout/CheckoutSidebarView/index.ts b/components/checkout/CheckoutSidebarView/index.ts deleted file mode 100644 index 168bc58f4..000000000 --- a/components/checkout/CheckoutSidebarView/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './CheckoutSidebarView' diff --git a/components/checkout/PaymentMethodView/PaymentMethodView.module.css b/components/checkout/PaymentMethodView/PaymentMethodView.module.css deleted file mode 100644 index f3880c72c..000000000 --- a/components/checkout/PaymentMethodView/PaymentMethodView.module.css +++ /dev/null @@ -1,17 +0,0 @@ -.fieldset { - @apply flex flex-col my-3; -} - -.fieldset .label { - @apply text-accent-7 uppercase text-xs font-medium mb-2; -} - -.fieldset .input, -.fieldset .select { - @apply p-2 border border-accent-2 w-full text-sm font-normal; -} - -.fieldset .input:focus, -.fieldset .select:focus { - @apply outline-none shadow-outline-normal; -} diff --git a/components/checkout/PaymentMethodView/PaymentMethodView.tsx b/components/checkout/PaymentMethodView/PaymentMethodView.tsx deleted file mode 100644 index a5f6f4b51..000000000 --- a/components/checkout/PaymentMethodView/PaymentMethodView.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import { FC } from 'react' -import cn from 'classnames' -import { Button, Text } from '@components/ui' -import { useUI } from '@components/ui/context' -import s from './PaymentMethodView.module.css' -import SidebarLayout from '@components/common/SidebarLayout' - -const PaymentMethodView: FC = () => { - const { setSidebarView } = useUI() - - return ( - setSidebarView('CHECKOUT_VIEW')}> -
    - Payment Method -
    -
    - - -
    -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    -
    -
    -
    - - -
    -
    - - -
    -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    -
    - - -
    -
    - - -
    -
    -
    - - -
    -
    -
    -
    - -
    -
    - ) -} - -export default PaymentMethodView diff --git a/components/checkout/PaymentMethodView/index.ts b/components/checkout/PaymentMethodView/index.ts deleted file mode 100644 index 951b3c318..000000000 --- a/components/checkout/PaymentMethodView/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './PaymentMethodView' diff --git a/components/checkout/PaymentWidget/PaymentWidget.module.css b/components/checkout/PaymentWidget/PaymentWidget.module.css deleted file mode 100644 index 38dcab0c0..000000000 --- a/components/checkout/PaymentWidget/PaymentWidget.module.css +++ /dev/null @@ -1,4 +0,0 @@ -.root { - @apply border border-accent-2 px-6 py-5 mb-4 text-center - flex items-center cursor-pointer hover:border-accent-4; -} diff --git a/components/checkout/PaymentWidget/PaymentWidget.tsx b/components/checkout/PaymentWidget/PaymentWidget.tsx deleted file mode 100644 index e1892934e..000000000 --- a/components/checkout/PaymentWidget/PaymentWidget.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { FC } from 'react' -import s from './PaymentWidget.module.css' -import { ChevronRight, CreditCard } from '@components/icons' - -interface ComponentProps { - onClick?: () => any -} - -const PaymentWidget: FC = ({ onClick }) => { - /* Shipping Address - Only available with checkout set to true - - This means that the provider does offer checkout functionality. */ - return ( -
    -
    - - - Add Payment Method - - {/* VISA #### #### #### 2345 */} -
    -
    - -
    -
    - ) -} - -export default PaymentWidget diff --git a/components/checkout/PaymentWidget/index.ts b/components/checkout/PaymentWidget/index.ts deleted file mode 100644 index 18cadea57..000000000 --- a/components/checkout/PaymentWidget/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './PaymentWidget' diff --git a/components/checkout/ShippingView/ShippingView.module.css b/components/checkout/ShippingView/ShippingView.module.css deleted file mode 100644 index 157d3174e..000000000 --- a/components/checkout/ShippingView/ShippingView.module.css +++ /dev/null @@ -1,21 +0,0 @@ -.fieldset { - @apply flex flex-col my-3; -} - -.fieldset .label { - @apply text-accent-7 uppercase text-xs font-medium mb-2; -} - -.fieldset .input, -.fieldset .select { - @apply p-2 border border-accent-2 w-full text-sm font-normal; -} - -.fieldset .input:focus, -.fieldset .select:focus { - @apply outline-none shadow-outline-normal; -} - -.radio { - @apply bg-black; -} diff --git a/components/checkout/ShippingView/ShippingView.tsx b/components/checkout/ShippingView/ShippingView.tsx deleted file mode 100644 index 1d03a2aac..000000000 --- a/components/checkout/ShippingView/ShippingView.tsx +++ /dev/null @@ -1,78 +0,0 @@ -import { FC } from 'react' -import cn from 'classnames' -import s from './ShippingView.module.css' -import Button from '@components/ui/Button' -import { useUI } from '@components/ui/context' -import SidebarLayout from '@components/common/SidebarLayout' - -const PaymentMethodView: FC = () => { - const { setSidebarView } = useUI() - - return ( - setSidebarView('CHECKOUT_VIEW')}> -
    -

    - Shipping -

    -
    -
    - - Same as billing address -
    -
    - - - Use a different shipping address - -
    -
    -
    -
    - - -
    -
    - - -
    -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    -
    - - -
    -
    - - -
    -
    -
    - - -
    -
    -
    -
    - -
    -
    - ) -} - -export default PaymentMethodView diff --git a/components/checkout/ShippingView/index.ts b/components/checkout/ShippingView/index.ts deleted file mode 100644 index 428e7e4fe..000000000 --- a/components/checkout/ShippingView/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ShippingView' diff --git a/components/checkout/ShippingWidget/ShippingWidget.module.css b/components/checkout/ShippingWidget/ShippingWidget.module.css deleted file mode 100644 index 38dcab0c0..000000000 --- a/components/checkout/ShippingWidget/ShippingWidget.module.css +++ /dev/null @@ -1,4 +0,0 @@ -.root { - @apply border border-accent-2 px-6 py-5 mb-4 text-center - flex items-center cursor-pointer hover:border-accent-4; -} diff --git a/components/checkout/ShippingWidget/ShippingWidget.tsx b/components/checkout/ShippingWidget/ShippingWidget.tsx deleted file mode 100644 index b072178b0..000000000 --- a/components/checkout/ShippingWidget/ShippingWidget.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { FC } from 'react' -import s from './ShippingWidget.module.css' -import { ChevronRight, MapPin } from '@components/icons' -import cn from 'classnames' - -interface ComponentProps { - onClick?: () => any -} - -const ShippingWidget: FC = ({ onClick }) => { - /* Shipping Address - Only available with checkout set to true - - This means that the provider does offer checkout functionality. */ - return ( -
    -
    - - - Add Shipping Address - - {/* - 1046 Kearny Street.
    - San Franssisco, California -
    */} -
    -
    - -
    -
    - ) -} - -export default ShippingWidget diff --git a/components/checkout/ShippingWidget/index.ts b/components/checkout/ShippingWidget/index.ts deleted file mode 100644 index 88e6dca4b..000000000 --- a/components/checkout/ShippingWidget/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ShippingWidget' diff --git a/components/common/Avatar/Avatar.tsx b/components/common/Avatar/Avatar.tsx deleted file mode 100644 index 663538450..000000000 --- a/components/common/Avatar/Avatar.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { FC, useRef, useEffect } from 'react' -import { useUserAvatar } from '@lib/hooks/useUserAvatar' - -interface Props { - className?: string - children?: any -} - -const Avatar: FC = ({}) => { - let ref = useRef() as React.MutableRefObject - let { userAvatar } = useUserAvatar() - - return ( -
    - {/* Add an image - We're generating a gradient as placeholder */} -
    - ) -} - -export default Avatar diff --git a/components/common/Avatar/index.ts b/components/common/Avatar/index.ts deleted file mode 100644 index a4600ec77..000000000 --- a/components/common/Avatar/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Avatar' diff --git a/components/common/FeatureBar/FeatureBar.module.css b/components/common/FeatureBar/FeatureBar.module.css deleted file mode 100644 index a3cb61cd2..000000000 --- a/components/common/FeatureBar/FeatureBar.module.css +++ /dev/null @@ -1,7 +0,0 @@ -.root { - @apply text-center p-6 bg-primary text-sm flex-row justify-center items-center font-medium fixed bottom-0 w-full z-30 transition-all duration-300 ease-out; - - @screen md { - @apply flex text-left; - } -} diff --git a/components/common/FeatureBar/FeatureBar.tsx b/components/common/FeatureBar/FeatureBar.tsx deleted file mode 100644 index 8923a721e..000000000 --- a/components/common/FeatureBar/FeatureBar.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import cn from 'classnames' -import s from './FeatureBar.module.css' - -interface FeatureBarProps { - className?: string - title: string - description?: string - hide?: boolean - action?: React.ReactNode -} - -const FeatureBar: React.FC = ({ - title, - description, - className, - action, - hide, -}) => { - const rootClassName = cn( - s.root, - { - transform: true, - 'translate-y-0 opacity-100': !hide, - 'translate-y-full opacity-0': hide, - }, - className - ) - return ( -
    - {title} - - {description} - - {action && action} -
    - ) -} - -export default FeatureBar diff --git a/components/common/FeatureBar/index.ts b/components/common/FeatureBar/index.ts deleted file mode 100644 index d78bc9d20..000000000 --- a/components/common/FeatureBar/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './FeatureBar' diff --git a/components/common/Footer/Footer.module.css b/components/common/Footer/Footer.module.css deleted file mode 100644 index 2ba492086..000000000 --- a/components/common/Footer/Footer.module.css +++ /dev/null @@ -1,13 +0,0 @@ -.root { - @apply border-t border-accent-2; -} - -.link { - & > svg { - @apply transform duration-75 ease-linear; - } - - &:hover > svg { - @apply scale-110; - } -} diff --git a/components/common/Footer/Footer.tsx b/components/common/Footer/Footer.tsx deleted file mode 100644 index 04b80404e..000000000 --- a/components/common/Footer/Footer.tsx +++ /dev/null @@ -1,117 +0,0 @@ -import { FC } from 'react' -import cn from 'classnames' -import Link from 'next/link' -import { useRouter } from 'next/router' -import type { Page } from '@commerce/types/page' -import getSlug from '@lib/get-slug' -import { Github, Vercel } from '@components/icons' -import { Logo, Container } from '@components/ui' -import { I18nWidget } from '@components/common' -import s from './Footer.module.css' - -interface Props { - className?: string - children?: any - pages?: Page[] -} - -const links = [ - { - name: 'Home', - url: '/', - }, -] - -const Footer: FC = ({ className, pages }) => { - const { sitePages } = usePages(pages) - const rootClassName = cn(s.root, className) - - return ( - - ) -} - -function usePages(pages?: Page[]) { - const { locale } = useRouter() - const sitePages: Page[] = [] - - if (pages) { - pages.forEach((page) => { - const slug = page.url && getSlug(page.url) - if (!slug) return - if (locale && !slug.startsWith(`${locale}/`)) return - sitePages.push(page) - }) - } - - return { - sitePages: sitePages.sort(bySortOrder), - } -} - -// Sort pages by the sort order assigned in the BC dashboard -function bySortOrder(a: Page, b: Page) { - return (a.sort_order ?? 0) - (b.sort_order ?? 0) -} - -export default Footer diff --git a/components/common/Footer/index.ts b/components/common/Footer/index.ts deleted file mode 100644 index 5d06e9b71..000000000 --- a/components/common/Footer/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Footer' diff --git a/components/common/Head/Head.tsx b/components/common/Head/Head.tsx deleted file mode 100644 index b2c0c997b..000000000 --- a/components/common/Head/Head.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { FC } from 'react' -import NextHead from 'next/head' -import { DefaultSeo } from 'next-seo' -import config from '@config/seo.json' - -const Head: FC = () => { - return ( - <> - - - - - - - ) -} - -export default Head diff --git a/components/common/Head/index.ts b/components/common/Head/index.ts deleted file mode 100644 index b317a124b..000000000 --- a/components/common/Head/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Head' diff --git a/components/common/HomeAllProductsGrid/HomeAllProductsGrid.module.css b/components/common/HomeAllProductsGrid/HomeAllProductsGrid.module.css deleted file mode 100644 index 91d1fdc60..000000000 --- a/components/common/HomeAllProductsGrid/HomeAllProductsGrid.module.css +++ /dev/null @@ -1,7 +0,0 @@ -.root { - @apply flex flex-col w-full; - - @screen md { - @apply flex-row; - } -} diff --git a/components/common/HomeAllProductsGrid/HomeAllProductsGrid.tsx b/components/common/HomeAllProductsGrid/HomeAllProductsGrid.tsx deleted file mode 100644 index d0fac461f..000000000 --- a/components/common/HomeAllProductsGrid/HomeAllProductsGrid.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { FC } from 'react' -import Link from 'next/link' -import type { Product } from '@commerce/types/product' -import { Grid } from '@components/ui' -import { ProductCard } from '@components/product' -import s from './HomeAllProductsGrid.module.css' -import { getCategoryPath, getDesignerPath } from '@lib/search' -import { Category } from '@commerce/types/site' - -interface Props { - categories?: Category[] - brands?: any - products?: Product[] -} - -const HomeAllProductsGrid: FC = ({ - categories = [], - brands, - products = [], -}) => { - return ( -
    -
    - {categories.map((category) => ( -
    -
    {category.name}
    -
    - {products.slice(0, 4).map((product) => ( - - ))} -
    -
    - ))} -
    -
    - ) -} - -export default HomeAllProductsGrid diff --git a/components/common/HomeAllProductsGrid/index.ts b/components/common/HomeAllProductsGrid/index.ts deleted file mode 100644 index 31d313d16..000000000 --- a/components/common/HomeAllProductsGrid/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './HomeAllProductsGrid' diff --git a/components/common/I18nWidget/I18nWidget.module.css b/components/common/I18nWidget/I18nWidget.module.css deleted file mode 100644 index 269aa5f61..000000000 --- a/components/common/I18nWidget/I18nWidget.module.css +++ /dev/null @@ -1,46 +0,0 @@ -.root { - @apply relative; -} - -.button { - @apply h-10 px-2 rounded-md border border-accent-2 flex items-center justify-center transition-colors ease-linear; -} - -.button:hover { - @apply border-accent-3 shadow-sm; -} - -.button:focus { - @apply outline-none; -} - -.dropdownMenu { - @apply fixed right-0 top-12 mt-2 origin-top-right outline-none bg-primary z-40 w-full h-full; - - @screen lg { - @apply absolute border border-accent-1 shadow-lg w-56 h-auto; - } -} - -.closeButton { - @screen md { - @apply hidden; - } -} - -.item { - @apply flex cursor-pointer px-6 py-3 transition ease-in-out duration-150 text-primary leading-6 font-medium items-center; - text-transform: capitalize; -} - -.item:hover { - @apply bg-accent-1; -} - -.icon { - transition: transform 0.2s ease; -} - -.icon.active { - transform: rotate(180deg); -} diff --git a/components/common/I18nWidget/I18nWidget.tsx b/components/common/I18nWidget/I18nWidget.tsx deleted file mode 100644 index 58135f12a..000000000 --- a/components/common/I18nWidget/I18nWidget.tsx +++ /dev/null @@ -1,101 +0,0 @@ -import cn from 'classnames' -import Link from 'next/link' -import { FC, useState } from 'react' -import { useRouter } from 'next/router' -import s from './I18nWidget.module.css' -import { Cross, ChevronUp } from '@components/icons' -import ClickOutside from '@lib/click-outside' -interface LOCALE_DATA { - name: string - img: { - filename: string - alt: string - } -} - -const LOCALES_MAP: Record = { - es: { - name: 'Español', - img: { - filename: 'flag-es-co.svg', - alt: 'Bandera Colombiana', - }, - }, - 'en-US': { - name: 'English', - img: { - filename: 'flag-en-us.svg', - alt: 'US Flag', - }, - }, -} - -const I18nWidget: FC = () => { - const [display, setDisplay] = useState(false) - const { - locale, - locales, - defaultLocale = 'en-US', - asPath: currentPath, - } = useRouter() - - const options = locales?.filter((val) => val !== locale) - const currentLocale = locale || defaultLocale - - return ( - setDisplay(false)}> - - - ) -} - -export default I18nWidget diff --git a/components/common/I18nWidget/index.ts b/components/common/I18nWidget/index.ts deleted file mode 100644 index 46525c3d4..000000000 --- a/components/common/I18nWidget/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './I18nWidget' diff --git a/components/common/Layout/Layout.module.css b/components/common/Layout/Layout.module.css deleted file mode 100644 index bb90675a6..000000000 --- a/components/common/Layout/Layout.module.css +++ /dev/null @@ -1,4 +0,0 @@ -.root { - @apply h-full bg-primary mx-auto transition-colors duration-150; - max-width: 2460px; -} diff --git a/components/common/Layout/Layout.tsx b/components/common/Layout/Layout.tsx deleted file mode 100644 index ff6d72aaf..000000000 --- a/components/common/Layout/Layout.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import cn from 'classnames' -import React, { FC } from 'react' -import dynamic from 'next/dynamic' -import { useRouter } from 'next/router' -import { CommerceProvider } from '@framework' -import { useUI } from '@components/ui/context' -import type { Page } from '@commerce/types/page' -import { Navbar, Footer } from '@components/common' -import type { Category } from '@commerce/types/site' -import ShippingView from '@components/checkout/ShippingView' -import CartSidebarView from '@components/cart/CartSidebarView' -import { useAcceptCookies } from '@lib/hooks/useAcceptCookies' -import { Sidebar, Button, Modal, LoadingDots } from '@components/ui' -import PaymentMethodView from '@components/checkout/PaymentMethodView' -import CheckoutSidebarView from '@components/checkout/CheckoutSidebarView' - -import LoginView from '@components/auth/LoginView' -import s from './Layout.module.css' - -const Loading = () => ( -
    - -
    -) - -const dynamicProps = { - loading: () => , -} - -const SignUpView = dynamic( - () => import('@components/auth/SignUpView'), - dynamicProps -) - -const ForgotPassword = dynamic( - () => import('@components/auth/ForgotPassword'), - dynamicProps -) - -const FeatureBar = dynamic( - () => import('@components/common/FeatureBar'), - dynamicProps -) - -interface Props { - pageProps: { - pages?: Page[] - categories: Category[] - } -} - -const ModalView: FC<{ modalView: string; closeModal(): any }> = ({ - modalView, - closeModal, -}) => { - return ( - - {modalView === 'LOGIN_VIEW' && } - {modalView === 'SIGNUP_VIEW' && } - {modalView === 'FORGOT_VIEW' && } - - ) -} - -const ModalUI: FC = () => { - const { displayModal, closeModal, modalView } = useUI() - return displayModal ? ( - - ) : null -} - -const SidebarView: FC<{ sidebarView: string; closeSidebar(): any }> = ({ - sidebarView, - closeSidebar, -}) => { - return ( - - {sidebarView === 'CART_VIEW' && } - {sidebarView === 'CHECKOUT_VIEW' && } - {sidebarView === 'PAYMENT_VIEW' && } - {sidebarView === 'SHIPPING_VIEW' && } - - ) -} - -const SidebarUI: FC = () => { - const { displaySidebar, closeSidebar, sidebarView } = useUI() - return displaySidebar ? ( - - ) : null -} - -const Layout: FC = ({ - children, - pageProps: { categories = [], ...pageProps }, -}) => { - const { acceptedCookies, onAcceptCookies } = useAcceptCookies() - const { locale = 'en-US' } = useRouter() - const navBarlinks = categories.slice(0, 2).map((c) => ({ - label: c.name, - href: `/search/${c.slug}`, - })) - - return ( - -
    - -
    {children}
    -
    - - - onAcceptCookies()}> - Accept cookies - - } - /> -
    -
    - ) -} - -export default Layout diff --git a/components/common/Layout/index.ts b/components/common/Layout/index.ts deleted file mode 100644 index 0e2737eee..000000000 --- a/components/common/Layout/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Layout' diff --git a/components/common/Navbar/Navbar.module.css b/components/common/Navbar/Navbar.module.css deleted file mode 100644 index faa86d156..000000000 --- a/components/common/Navbar/Navbar.module.css +++ /dev/null @@ -1,35 +0,0 @@ -.root { - @apply sticky top-0 bg-primary z-40 transition-all duration-150; - min-height: 74px; -} - -.nav { - @apply relative flex flex-row justify-between py-4 md:py-4; -} - -.navMenu { - @apply hidden ml-6 space-x-4 lg:block; -} - -.link { - @apply inline-flex items-center leading-6 - transition ease-in-out duration-75 cursor-pointer - text-accent-5; -} - -.link:hover { - @apply text-accent-9; -} - -.link:focus { - @apply outline-none text-accent-8; -} - -.logo { - @apply cursor-pointer rounded-full border transform duration-100 ease-in-out; - - &:hover { - @apply shadow-md; - transform: scale(1.05); - } -} diff --git a/components/common/Navbar/Navbar.tsx b/components/common/Navbar/Navbar.tsx deleted file mode 100644 index 2ce5f33b8..000000000 --- a/components/common/Navbar/Navbar.tsx +++ /dev/null @@ -1,53 +0,0 @@ -import { FC } from 'react' -import Link from 'next/link' -import s from './Navbar.module.css' -import NavbarRoot from './NavbarRoot' -import { Logo, Container } from '@components/ui' -import { Searchbar, UserNav } from '@components/common' - -interface Link { - href: string - label: string -} -interface NavbarProps { - links?: Link[] -} - -const Navbar: FC = ({ links }) => ( - - -
    -
    - - - - - - -
    - {process.env.COMMERCE_SEARCH_ENABLED && ( -
    - -
    - )} -
    - -
    -
    -
    - -
    -
    -
    -) - -export default Navbar diff --git a/components/common/Navbar/NavbarRoot.tsx b/components/common/Navbar/NavbarRoot.tsx deleted file mode 100644 index 2eb8c5429..000000000 --- a/components/common/Navbar/NavbarRoot.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { FC, useState, useEffect } from 'react' -import throttle from 'lodash.throttle' -import cn from 'classnames' -import s from './Navbar.module.css' - -const NavbarRoot: FC = ({ children }) => { - const [hasScrolled, setHasScrolled] = useState(false) - - useEffect(() => { - const handleScroll = throttle(() => { - const offset = 0 - const { scrollTop } = document.documentElement - const scrolled = scrollTop > offset - - if (hasScrolled !== scrolled) { - setHasScrolled(scrolled) - } - }, 200) - - document.addEventListener('scroll', handleScroll) - return () => { - document.removeEventListener('scroll', handleScroll) - } - }, [hasScrolled]) - - return ( -
    - {children} -
    - ) -} - -export default NavbarRoot diff --git a/components/common/Navbar/index.ts b/components/common/Navbar/index.ts deleted file mode 100644 index e6400ae40..000000000 --- a/components/common/Navbar/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Navbar' diff --git a/components/common/Searchbar/Searchbar.module.css b/components/common/Searchbar/Searchbar.module.css deleted file mode 100644 index 7f20ed973..000000000 --- a/components/common/Searchbar/Searchbar.module.css +++ /dev/null @@ -1,29 +0,0 @@ -.root { - @apply relative text-sm bg-accent-0 text-base w-full transition-colors duration-150 border border-accent-2; -} - -.input { - @apply bg-transparent px-3 py-2 appearance-none w-full transition duration-150 ease-in-out pr-10; -} - -.input::placeholder { - @apply text-accent-3; -} - -.input:focus { - @apply outline-none shadow-outline-normal; -} - -.iconContainer { - @apply absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none; -} - -.icon { - @apply h-5 w-5; -} - -@screen sm { - .input { - min-width: 300px; - } -} diff --git a/components/common/Searchbar/Searchbar.tsx b/components/common/Searchbar/Searchbar.tsx deleted file mode 100644 index 0fc276d02..000000000 --- a/components/common/Searchbar/Searchbar.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { FC, InputHTMLAttributes, useEffect, useMemo } from 'react' -import cn from 'classnames' -import s from './Searchbar.module.css' -import { useRouter } from 'next/router' - -interface Props { - className?: string - id?: string -} - -const Searchbar: FC = ({ className, id = 'search' }) => { - const router = useRouter() - - useEffect(() => { - router.prefetch('/search') - }, []) - - const handleKeyUp = (e: React.KeyboardEvent) => { - e.preventDefault() - - if (e.key === 'Enter') { - const q = e.currentTarget.value - - router.push( - { - pathname: `/search`, - query: q ? { q } : {}, - }, - undefined, - { shallow: true } - ) - } - } - - return useMemo( - () => ( -
    - - -
    - - - -
    -
    - ), - [] - ) -} - -export default Searchbar diff --git a/components/common/Searchbar/index.ts b/components/common/Searchbar/index.ts deleted file mode 100644 index e6c0e36c8..000000000 --- a/components/common/Searchbar/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Searchbar' diff --git a/components/common/SidebarLayout/SidebarLayout.module.css b/components/common/SidebarLayout/SidebarLayout.module.css deleted file mode 100644 index a8940dc52..000000000 --- a/components/common/SidebarLayout/SidebarLayout.module.css +++ /dev/null @@ -1,20 +0,0 @@ -.root { - @apply relative h-full flex flex-col; -} - -.header { - @apply sticky top-0 pl-4 py-4 pr-6 - flex items-center justify-between - bg-accent-0 box-border w-full z-10; - min-height: 66px; -} - -.container { - @apply flex flex-col flex-1 box-border; -} - -@screen lg { - .header { - min-height: 74px; - } -} diff --git a/components/common/SidebarLayout/SidebarLayout.tsx b/components/common/SidebarLayout/SidebarLayout.tsx deleted file mode 100644 index a4e60a758..000000000 --- a/components/common/SidebarLayout/SidebarLayout.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import React, { FC } from 'react' -import { Cross, ChevronLeft } from '@components/icons' -import { UserNav } from '@components/common' -import cn from 'classnames' -import s from './SidebarLayout.module.css' - -type ComponentProps = { className?: string } & ( - | { handleClose: () => any; handleBack?: never } - | { handleBack: () => any; handleClose?: never } -) - -const SidebarLayout: FC = ({ - children, - className, - handleClose, - handleBack, -}) => { - return ( -
    -
    - {handleClose && ( - - )} - {handleBack && ( - - )} - - - -
    -
    {children}
    -
    - ) -} - -export default SidebarLayout diff --git a/components/common/SidebarLayout/index.ts b/components/common/SidebarLayout/index.ts deleted file mode 100644 index 45ded0cf0..000000000 --- a/components/common/SidebarLayout/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './SidebarLayout' diff --git a/components/common/UserNav/DropdownMenu.module.css b/components/common/UserNav/DropdownMenu.module.css deleted file mode 100644 index d6b13ecb5..000000000 --- a/components/common/UserNav/DropdownMenu.module.css +++ /dev/null @@ -1,24 +0,0 @@ -.dropdownMenu { - @apply fixed right-0 mt-2 origin-top-right outline-none bg-primary z-40 w-full h-full; - - @screen lg { - @apply absolute top-10 border border-accent-1 shadow-lg w-56 h-auto; - } -} - -.link { - @apply text-primary flex cursor-pointer px-6 py-3 flex transition ease-in-out duration-150 leading-6 font-medium items-center; - text-transform: capitalize; -} - -.link:hover { - @apply bg-accent-1; -} - -.link.active { - @apply font-bold bg-accent-2; -} - -.off { - @apply hidden; -} diff --git a/components/common/UserNav/DropdownMenu.tsx b/components/common/UserNav/DropdownMenu.tsx deleted file mode 100644 index f79fd5821..000000000 --- a/components/common/UserNav/DropdownMenu.tsx +++ /dev/null @@ -1,125 +0,0 @@ -import cn from 'classnames' -import Link from 'next/link' -import { FC, useRef, useState, useEffect } from 'react' -import { useTheme } from 'next-themes' -import { useRouter } from 'next/router' -import s from './DropdownMenu.module.css' -import { Avatar } from '@components/common' -import { Moon, Sun } from '@components/icons' -import { useUI } from '@components/ui/context' -import ClickOutside from '@lib/click-outside' -import useLogout from '@framework/auth/use-logout' - -import { - disableBodyScroll, - enableBodyScroll, - clearAllBodyScrollLocks, -} from 'body-scroll-lock' - -interface DropdownMenuProps { - open?: boolean -} - -const LINKS = [ - { - name: 'My Orders', - href: '/orders', - }, - { - name: 'My Profile', - href: '/profile', - }, - { - name: 'My Cart', - href: '/cart', - }, -] - -const DropdownMenu: FC = ({ open = false }) => { - const logout = useLogout() - const { pathname } = useRouter() - const { theme, setTheme } = useTheme() - const [display, setDisplay] = useState(false) - const { closeSidebarIfPresent } = useUI() - const ref = useRef() as React.MutableRefObject - - useEffect(() => { - if (ref.current) { - if (display) { - disableBodyScroll(ref.current) - } else { - enableBodyScroll(ref.current) - } - } - return () => { - clearAllBodyScrollLocks() - } - }, [display]) - - return ( - setDisplay(false)}> - - - ) -} - -export default DropdownMenu diff --git a/components/common/UserNav/UserNav.module.css b/components/common/UserNav/UserNav.module.css deleted file mode 100644 index 92f62c10d..000000000 --- a/components/common/UserNav/UserNav.module.css +++ /dev/null @@ -1,40 +0,0 @@ -.root { - @apply relative; -} - -.list { - @apply flex flex-row items-center justify-items-end h-full; -} - -.item { - @apply mr-6 cursor-pointer relative transition ease-in-out duration-100 flex items-center outline-none text-primary; - - &:hover { - @apply text-accent-6 transition scale-110 duration-100; - } - - &:last-child { - @apply mr-0; - } - - &:focus, - &:active { - @apply outline-none; - } -} - -.bagCount { - @apply border border-accent-1 bg-secondary text-secondary absolute rounded-full right-3 top-3 flex items-center justify-center font-bold text-xs; - padding-left: 2.5px; - padding-right: 2.5px; - min-width: 1.25rem; - min-height: 1.25rem; -} - -.avatarButton { - @apply inline-flex justify-center rounded-full; -} - -.avatarButton:focus { - @apply outline-none; -} diff --git a/components/common/UserNav/UserNav.tsx b/components/common/UserNav/UserNav.tsx deleted file mode 100644 index 5d7d28df3..000000000 --- a/components/common/UserNav/UserNav.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import { FC } from 'react' -import Link from 'next/link' -import cn from 'classnames' -import type { LineItem } from '@commerce/types/cart' -import useCart from '@framework/cart/use-cart' -import useCustomer from '@framework/customer/use-customer' -import { Avatar } from '@components/common' -import { Heart, Bag } from '@components/icons' -import { useUI } from '@components/ui/context' -import DropdownMenu from './DropdownMenu' -import s from './UserNav.module.css' - -interface Props { - className?: string -} - -const countItem = (count: number, item: LineItem) => count + item.quantity - -const UserNav: FC = ({ className }) => { - const { data } = useCart() - const { data: customer } = useCustomer() - const { toggleSidebar, closeSidebarIfPresent, openModal } = useUI() - const itemsCount = data?.lineItems.reduce(countItem, 0) ?? 0 - - return ( - - ) -} - -export default UserNav diff --git a/components/common/UserNav/index.ts b/components/common/UserNav/index.ts deleted file mode 100644 index 9e35ac018..000000000 --- a/components/common/UserNav/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './UserNav' diff --git a/components/common/index.ts b/components/common/index.ts deleted file mode 100644 index 98dd3394b..000000000 --- a/components/common/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -export { default as Avatar } from './Avatar' -export { default as FeatureBar } from './FeatureBar' -export { default as Footer } from './Footer' -export { default as Layout } from './Layout' -export { default as Navbar } from './Navbar' -export { default as Searchbar } from './Searchbar' -export { default as UserNav } from './UserNav' -export { default as Head } from './Head' -export { default as I18nWidget } from './I18nWidget' diff --git a/components/icons/ArrowLeft.tsx b/components/icons/ArrowLeft.tsx deleted file mode 100644 index 8cc1e1294..000000000 --- a/components/icons/ArrowLeft.tsx +++ /dev/null @@ -1,27 +0,0 @@ -const ArrowLeft = ({ ...props }) => { - return ( - - - - - ) -} - -export default ArrowLeft diff --git a/components/icons/ArrowRight.tsx b/components/icons/ArrowRight.tsx deleted file mode 100644 index e644951d9..000000000 --- a/components/icons/ArrowRight.tsx +++ /dev/null @@ -1,28 +0,0 @@ -const ArrowRight = ({ ...props }) => { - return ( - - - - - ) -} - -export default ArrowRight diff --git a/components/icons/Bag.tsx b/components/icons/Bag.tsx deleted file mode 100644 index de2cde0d1..000000000 --- a/components/icons/Bag.tsx +++ /dev/null @@ -1,33 +0,0 @@ -const Bag = ({ ...props }) => { - return ( - - - - - - ) -} - -export default Bag diff --git a/components/icons/Check.tsx b/components/icons/Check.tsx deleted file mode 100644 index 89c91a1e3..000000000 --- a/components/icons/Check.tsx +++ /dev/null @@ -1,21 +0,0 @@ -const Check = ({ ...props }) => { - return ( - - - - ) -} - -export default Check diff --git a/components/icons/ChevronDown.tsx b/components/icons/ChevronDown.tsx deleted file mode 100644 index 542e8056d..000000000 --- a/components/icons/ChevronDown.tsx +++ /dev/null @@ -1,20 +0,0 @@ -const ChevronDown = ({ ...props }) => { - return ( - - - - ) -} - -export default ChevronDown diff --git a/components/icons/ChevronLeft.tsx b/components/icons/ChevronLeft.tsx deleted file mode 100644 index 4efb6a522..000000000 --- a/components/icons/ChevronLeft.tsx +++ /dev/null @@ -1,20 +0,0 @@ -const ChevronLeft = ({ ...props }) => { - return ( - - - - ) -} - -export default ChevronLeft diff --git a/components/icons/ChevronRight.tsx b/components/icons/ChevronRight.tsx deleted file mode 100644 index d72b77a32..000000000 --- a/components/icons/ChevronRight.tsx +++ /dev/null @@ -1,20 +0,0 @@ -const ChevronUp = ({ ...props }) => { - return ( - - - - ) -} - -export default ChevronUp diff --git a/components/icons/ChevronUp.tsx b/components/icons/ChevronUp.tsx deleted file mode 100644 index 69b9959b8..000000000 --- a/components/icons/ChevronUp.tsx +++ /dev/null @@ -1,20 +0,0 @@ -const ChevronUp = ({ ...props }) => { - return ( - - - - ) -} - -export default ChevronUp diff --git a/components/icons/CreditCard.tsx b/components/icons/CreditCard.tsx deleted file mode 100644 index 958c31193..000000000 --- a/components/icons/CreditCard.tsx +++ /dev/null @@ -1,21 +0,0 @@ -const CreditCard = ({ ...props }) => { - return ( - - - - - ) -} - -export default CreditCard diff --git a/components/icons/Cross.tsx b/components/icons/Cross.tsx deleted file mode 100644 index 12e115ac9..000000000 --- a/components/icons/Cross.tsx +++ /dev/null @@ -1,21 +0,0 @@ -const Cross = ({ ...props }) => { - return ( - - - - - ) -} - -export default Cross diff --git a/components/icons/DoubleChevron.tsx b/components/icons/DoubleChevron.tsx deleted file mode 100644 index 198c30464..000000000 --- a/components/icons/DoubleChevron.tsx +++ /dev/null @@ -1,22 +0,0 @@ -const DoubleChevron = ({ ...props }) => { - return ( - - - - ) -} - -export default DoubleChevron diff --git a/components/icons/Github.tsx b/components/icons/Github.tsx deleted file mode 100644 index 1195a3c3a..000000000 --- a/components/icons/Github.tsx +++ /dev/null @@ -1,20 +0,0 @@ -const Github = ({ ...props }) => { - return ( - - - - ) -} - -export default Github diff --git a/components/icons/Heart.tsx b/components/icons/Heart.tsx deleted file mode 100644 index afa2f6aaa..000000000 --- a/components/icons/Heart.tsx +++ /dev/null @@ -1,22 +0,0 @@ -const Heart = ({ ...props }) => { - return ( - - - - ) -} - -export default Heart diff --git a/components/icons/Info.tsx b/components/icons/Info.tsx deleted file mode 100644 index 67c79cf27..000000000 --- a/components/icons/Info.tsx +++ /dev/null @@ -1,22 +0,0 @@ -const Info = ({ ...props }) => { - return ( - - - - - - ) -} - -export default Info diff --git a/components/icons/MapPin.tsx b/components/icons/MapPin.tsx deleted file mode 100644 index 6323b9c1c..000000000 --- a/components/icons/MapPin.tsx +++ /dev/null @@ -1,20 +0,0 @@ -const MapPin = ({ ...props }) => { - return ( - - - - - ) -} - -export default MapPin diff --git a/components/icons/Minus.tsx b/components/icons/Minus.tsx deleted file mode 100644 index 1e9411dda..000000000 --- a/components/icons/Minus.tsx +++ /dev/null @@ -1,15 +0,0 @@ -const Minus = ({ ...props }) => { - return ( - - - - ) -} - -export default Minus diff --git a/components/icons/Moon.tsx b/components/icons/Moon.tsx deleted file mode 100644 index e02f2a30d..000000000 --- a/components/icons/Moon.tsx +++ /dev/null @@ -1,20 +0,0 @@ -const Moon = ({ ...props }) => { - return ( - - - - ) -} - -export default Moon diff --git a/components/icons/Plus.tsx b/components/icons/Plus.tsx deleted file mode 100644 index ad030b92e..000000000 --- a/components/icons/Plus.tsx +++ /dev/null @@ -1,22 +0,0 @@ -const Plus = ({ ...props }) => { - return ( - - - - - ) -} - -export default Plus diff --git a/components/icons/Star.tsx b/components/icons/Star.tsx deleted file mode 100644 index d98f55e1d..000000000 --- a/components/icons/Star.tsx +++ /dev/null @@ -1,16 +0,0 @@ -const Star = ({ ...props }) => { - return ( - - - - ) -} - -export default Star diff --git a/components/icons/Sun.tsx b/components/icons/Sun.tsx deleted file mode 100644 index d3684bcb9..000000000 --- a/components/icons/Sun.tsx +++ /dev/null @@ -1,28 +0,0 @@ -const Sun = ({ ...props }) => { - return ( - - - - - - - - - - - - ) -} - -export default Sun diff --git a/components/icons/Trash.tsx b/components/icons/Trash.tsx deleted file mode 100644 index b005ea892..000000000 --- a/components/icons/Trash.tsx +++ /dev/null @@ -1,43 +0,0 @@ -const Trash = ({ ...props }) => { - return ( - - - - - - - ) -} - -export default Trash diff --git a/components/icons/Vercel.tsx b/components/icons/Vercel.tsx deleted file mode 100644 index 96e619fdf..000000000 --- a/components/icons/Vercel.tsx +++ /dev/null @@ -1,40 +0,0 @@ -const Vercel = ({ ...props }) => { - return ( - - - - - - - - - - ) -} - -export default Vercel diff --git a/components/icons/index.ts b/components/icons/index.ts deleted file mode 100644 index 97eef6d58..000000000 --- a/components/icons/index.ts +++ /dev/null @@ -1,22 +0,0 @@ -export { default as Bag } from './Bag' -export { default as Heart } from './Heart' -export { default as Trash } from './Trash' -export { default as Cross } from './Cross' -export { default as Plus } from './Plus' -export { default as Minus } from './Minus' -export { default as Check } from './Check' -export { default as Sun } from './Sun' -export { default as Moon } from './Moon' -export { default as Github } from './Github' -export { default as Info } from './Info' -export { default as Vercel } from './Vercel' -export { default as MapPin } from './MapPin' -export { default as Star } from './Star' -export { default as ArrowLeft } from './ArrowLeft' -export { default as ArrowRight } from './ArrowRight' -export { default as CreditCard } from './CreditCard' -export { default as ChevronUp } from './ChevronUp' -export { default as ChevronLeft } from './ChevronLeft' -export { default as ChevronDown } from './ChevronDown' -export { default as ChevronRight } from './ChevronRight' -export { default as DoubleChevron } from './DoubleChevron' diff --git a/components/product/ProductCard/ProductCard.module.css b/components/product/ProductCard/ProductCard.module.css deleted file mode 100644 index d5d441fea..000000000 --- a/components/product/ProductCard/ProductCard.module.css +++ /dev/null @@ -1,114 +0,0 @@ -.root { - @apply relative max-h-full w-full box-border overflow-hidden - bg-no-repeat bg-center bg-cover transition-transform - ease-linear cursor-pointer inline-block bg-accent-1; - height: 100% !important; -} - -.root:hover { - & .productImage { - transform: scale(1.2625); - } - - & .header .name span, - & .header .price, - & .wishlistButton { - @apply bg-secondary text-secondary; - } - - &:nth-child(6n + 1) .header .name span, - &:nth-child(6n + 1) .header .price, - &:nth-child(6n + 1) .wishlistButton { - @apply bg-violet text-white; - } - - &:nth-child(6n + 5) .header .name span, - &:nth-child(6n + 5) .header .price, - &:nth-child(6n + 5) .wishlistButton { - @apply bg-blue text-white; - } - - &:nth-child(6n + 3) .header .name span, - &:nth-child(6n + 3) .header .price, - &:nth-child(6n + 3) .wishlistButton { - @apply bg-pink text-white; - } - - &:nth-child(6n + 6) .header .name span, - &:nth-child(6n + 6) .header .price, - &:nth-child(6n + 6) .wishlistButton { - @apply bg-cyan text-white; - } -} - -.header { - @apply transition-colors ease-in-out duration-500 - absolute top-0 left-0 z-20 pr-16; -} - -.header .name { - @apply pt-0 max-w-full w-full leading-extra-loose - transition-colors ease-in-out duration-500; - font-size: 2rem; - letter-spacing: 0.4px; -} - -.header .name span { - @apply py-4 px-6 bg-primary text-primary font-bold - transition-colors ease-in-out duration-500; - font-size: inherit; - letter-spacing: inherit; - box-decoration-break: clone; - -webkit-box-decoration-break: clone; -} - -.header .price { - @apply pt-2 px-6 pb-4 text-sm bg-primary text-accent-9 - font-semibold inline-block tracking-wide - transition-colors ease-in-out duration-500; -} - -.imageContainer { - @apply flex items-center justify-center overflow-hidden; -} - -.imageContainer > div { - min-width: 100%; -} - -.imageContainer .productImage { - @apply transform transition-transform duration-500 - object-cover scale-120; -} - -.root .wishlistButton { - @apply top-0 right-0 z-30 absolute; -} - -/* Variant Simple */ -.simple .header .name { - @apply pt-2 text-lg leading-10 -mt-1; -} - -.simple .header .price { - @apply text-sm; -} - -/* Variant Slim */ -.slim { - @apply bg-transparent relative overflow-hidden - box-border; -} - -.slim .header { - @apply absolute inset-0 flex items-center justify-end mr-8 z-20; -} - -.slim span { - @apply bg-accent-9 text-accent-0 inline-block p-3 - font-bold text-xl break-words; -} - -.root:global(.secondary) .header span { - @apply bg-accent-0 text-accent-9; -} diff --git a/components/product/ProductCard/ProductCard.tsx b/components/product/ProductCard/ProductCard.tsx deleted file mode 100644 index 39c19db00..000000000 --- a/components/product/ProductCard/ProductCard.tsx +++ /dev/null @@ -1,132 +0,0 @@ -import { FC } from 'react' -import cn from 'classnames' -import Link from 'next/link' -import type { Product } from '@commerce/types/product' -import s from './ProductCard.module.css' -import Image, { ImageProps } from 'next/image' -import WishlistButton from '@components/wishlist/WishlistButton' -import usePrice from '@framework/product/use-price' -import ProductTag from '../ProductTag' -interface Props { - className?: string - product: Product - noNameTag?: boolean - imgProps?: Omit - variant?: 'default' | 'slim' | 'simple' -} - -const placeholderImg = '/product-img-placeholder.svg' - -const ProductCard: FC = ({ - product, - imgProps, - className, - noNameTag = false, - variant = 'default', - ...props -}) => { - const { price } = usePrice({ - amount: product.price.value, - baseAmount: product.price.retailPrice, - currencyCode: product.price.currencyCode!, - }) - - const rootClassName = cn( - s.root, - { [s.slim]: variant === 'slim', [s.simple]: variant === 'simple' }, - className - ) - - return ( - - - {variant === 'slim' && ( - <> -
    - {product.name} -
    - {product?.images && ( - {product.name - )} - - )} - - {variant === 'simple' && ( - <> - {process.env.COMMERCE_WISHLIST_ENABLED && ( - - )} - {!noNameTag && ( -
    -

    - {product.name} -

    -
    - {`${price} ${product.price?.currencyCode}`} -
    -
    - )} -
    - {product?.images && ( - {product.name - )} -
    - - )} - - {variant === 'default' && ( - <> - {process.env.COMMERCE_WISHLIST_ENABLED && ( - - )} - -
    - {product?.images && ( - {product.name - )} -
    - - )} -
    - - ) -} - -export default ProductCard diff --git a/components/product/ProductCard/index.ts b/components/product/ProductCard/index.ts deleted file mode 100644 index 4559faa14..000000000 --- a/components/product/ProductCard/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ProductCard' diff --git a/components/product/ProductOptions/ProductOptions.tsx b/components/product/ProductOptions/ProductOptions.tsx deleted file mode 100644 index 9261406bc..000000000 --- a/components/product/ProductOptions/ProductOptions.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { Swatch } from '@components/product' -import type { ProductOption } from '@commerce/types/product' -import { SelectedOptions } from '../helpers' -import React from 'react' -interface ProductOptionsProps { - options: ProductOption[] - selectedOptions: SelectedOptions - setSelectedOptions: React.Dispatch> -} - -const ProductOptions: React.FC = React.memo( - ({ options, selectedOptions, setSelectedOptions }) => { - return ( -
    - {options.map((opt) => ( -
    -

    - {opt.displayName} -

    -
    - {opt.values.map((v, i: number) => { - const active = selectedOptions[opt.displayName.toLowerCase()] - return ( - { - setSelectedOptions((selectedOptions) => { - return { - ...selectedOptions, - [opt.displayName.toLowerCase()]: - v.label.toLowerCase(), - } - }) - }} - /> - ) - })} -
    -
    - ))} -
    - ) - } -) - -export default ProductOptions diff --git a/components/product/ProductOptions/index.ts b/components/product/ProductOptions/index.ts deleted file mode 100644 index 252415ab7..000000000 --- a/components/product/ProductOptions/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ProductOptions' diff --git a/components/product/ProductSidebar/ProductSidebar.module.css b/components/product/ProductSidebar/ProductSidebar.module.css deleted file mode 100644 index b6ecc2b77..000000000 --- a/components/product/ProductSidebar/ProductSidebar.module.css +++ /dev/null @@ -1,84 +0,0 @@ -.root { - @apply relative grid items-start gap-1 grid-cols-1 overflow-x-hidden; - min-height: auto; -} - -.main { - @apply relative px-0 pb-0 box-border flex flex-col col-span-1; - min-height: 500px; -} - -.header { - @apply transition-colors ease-in-out duration-500 - absolute top-0 left-0 z-20 pr-16; -} - -.header .name { - @apply pt-0 max-w-full w-full leading-extra-loose; - font-size: 2rem; - letter-spacing: 0.4px; -} - -.header .name span { - @apply py-4 px-6 bg-primary text-primary font-bold; - font-size: inherit; - letter-spacing: inherit; - box-decoration-break: clone; - -webkit-box-decoration-break: clone; -} - -.header .price { - @apply pt-2 px-6 pb-4 text-sm bg-primary text-accent-9 - font-semibold inline-block tracking-wide; -} - -.sidebar { - @apply flex flex-col col-span-1 mx-auto max-w-8xl px-6 py-6 w-full h-full; -} - -.sliderContainer { - @apply flex items-center justify-center overflow-x-hidden bg-violet; -} - -.imageContainer { - @apply text-center; -} - -.imageContainer > div, -.imageContainer > div > div { - @apply h-full; -} - -.sliderContainer .img { - @apply w-full h-auto max-h-full object-cover; -} - -.button { - width: 100%; -} - -.wishlistButton { - @apply absolute z-30 top-0 right-0; -} - -.relatedProductsGrid { - @apply grid grid-cols-2 py-2 gap-2 md:grid-cols-4 md:gap-7; -} - -@screen lg { - .root { - @apply grid-cols-12; - } - - .main { - @apply mx-0 col-span-8; - } - - .sidebar { - @apply col-span-4 py-6; - } - - .imageContainer { - max-height: 600px; - } -} diff --git a/components/product/ProductSidebar/ProductSidebar.tsx b/components/product/ProductSidebar/ProductSidebar.tsx deleted file mode 100644 index fe8a71aa5..000000000 --- a/components/product/ProductSidebar/ProductSidebar.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import s from './ProductSidebar.module.css' -import { useAddItem } from '@framework/cart' -import { FC, useEffect, useState } from 'react' -import { ProductOptions } from '@components/product' -import type { Product } from '@commerce/types/product' -import { Button, Text, Rating, Collapse, useUI } from '@components/ui' -import { - getProductVariant, - selectDefaultOptionFromProduct, - SelectedOptions, -} from '../helpers' - -interface ProductSidebarProps { - product: Product - className?: string -} - -const ProductSidebar: FC = ({ product, className }) => { - const addItem = useAddItem() - const { openSidebar } = useUI() - const [loading, setLoading] = useState(false) - const [selectedOptions, setSelectedOptions] = useState({}) - - useEffect(() => { - selectDefaultOptionFromProduct(product, setSelectedOptions) - }, []) - - const variant = getProductVariant(product, selectedOptions) - const addToCart = async () => { - setLoading(true) - try { - await addItem({ - productId: String(product.id), - variantId: String(variant ? variant.id : product.variants[0].id), - }) - openSidebar() - setLoading(false) - } catch (err) { - setLoading(false) - } - } - - return ( -
    - - -
    - -
    36 reviews
    -
    -
    - {process.env.COMMERCE_CART_ENABLED && ( - - )} -
    -
    - - This is a limited edition production run. Printing starts when the - drop ends. - - - This is a limited edition production run. Printing starts when the - drop ends. Reminder: Bad Boys For Life. Shipping may take 10+ days due - to COVID-19. - -
    -
    - ) -} - -export default ProductSidebar diff --git a/components/product/ProductSidebar/index.ts b/components/product/ProductSidebar/index.ts deleted file mode 100644 index 7e00359c4..000000000 --- a/components/product/ProductSidebar/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ProductSidebar' diff --git a/components/product/ProductSlider/ProductSlider.module.css b/components/product/ProductSlider/ProductSlider.module.css deleted file mode 100644 index 8d7265eb8..000000000 --- a/components/product/ProductSlider/ProductSlider.module.css +++ /dev/null @@ -1,64 +0,0 @@ -.root { - @apply relative w-full h-full select-none; - overflow: hidden; -} - -.slider { - @apply relative h-full transition-opacity duration-150; - opacity: 0; -} - -.slider.show { - opacity: 1; -} - -.thumb { - @apply transition-transform transition-colors - ease-linear duration-75 overflow-hidden inline-block - cursor-pointer h-full; - width: 125px; - width: calc(100% / 3); -} - -.thumb.selected { - @apply bg-white; -} - -.thumb img { - height: 85% !important; -} - -.album { - width: 100%; - height: 100%; - @apply bg-violet-dark; - box-sizing: content-box; - overflow-y: hidden; - overflow-x: auto; - white-space: nowrap; - height: 125px; - scrollbar-width: none; -} - -/* Hide scrollbar for Chrome, Safari and Opera */ -.album::-webkit-scrollbar { - display: none; -} - -@screen md { - .thumb:hover { - transform: scale(1.02); - background-color: rgba(255, 255, 255, 0.08); - } - - .thumb.selected { - @apply bg-white; - } - - .album { - height: 182px; - } - .thumb { - width: 235px; - } -} diff --git a/components/product/ProductSlider/ProductSlider.tsx b/components/product/ProductSlider/ProductSlider.tsx deleted file mode 100644 index 8c3441906..000000000 --- a/components/product/ProductSlider/ProductSlider.tsx +++ /dev/null @@ -1,136 +0,0 @@ -import { useKeenSlider } from 'keen-slider/react' -import React, { - Children, - FC, - isValidElement, - useState, - useRef, - useEffect, -} from 'react' -import cn from 'classnames' -import { a } from '@react-spring/web' -import s from './ProductSlider.module.css' -import ProductSliderControl from '../ProductSliderControl' - -interface ProductSliderProps { - children: React.ReactNode[] - className?: string -} - -const ProductSlider: React.FC = ({ - children, - className = '', -}) => { - const [currentSlide, setCurrentSlide] = useState(0) - const [isMounted, setIsMounted] = useState(false) - const sliderContainerRef = useRef(null) - const thumbsContainerRef = useRef(null) - - const [ref, slider] = useKeenSlider({ - loop: true, - slidesPerView: 1, - mounted: () => setIsMounted(true), - slideChanged(s) { - const slideNumber = s.details().relativeSlide - setCurrentSlide(slideNumber) - - if (thumbsContainerRef.current) { - const $el = document.getElementById( - `thumb-${s.details().relativeSlide}` - ) - if (slideNumber >= 3) { - thumbsContainerRef.current.scrollLeft = $el!.offsetLeft - } else { - thumbsContainerRef.current.scrollLeft = 0 - } - } - }, - }) - - // Stop the history navigation gesture on touch devices - useEffect(() => { - const preventNavigation = (event: TouchEvent) => { - // Center point of the touch area - const touchXPosition = event.touches[0].pageX - // Size of the touch area - const touchXRadius = event.touches[0].radiusX || 0 - - // We set a threshold (10px) on both sizes of the screen, - // if the touch area overlaps with the screen edges - // it's likely to trigger the navigation. We prevent the - // touchstart event in that case. - if ( - touchXPosition - touchXRadius < 10 || - touchXPosition + touchXRadius > window.innerWidth - 10 - ) - event.preventDefault() - } - - sliderContainerRef.current!.addEventListener( - 'touchstart', - preventNavigation - ) - - return () => { - if (sliderContainerRef.current) { - sliderContainerRef.current!.removeEventListener( - 'touchstart', - preventNavigation - ) - } - } - }, []) - - const onPrev = React.useCallback(() => slider.prev(), [slider]) - const onNext = React.useCallback(() => slider.next(), [slider]) - - return ( -
    -
    - {slider && } - {Children.map(children, (child) => { - // Add the keen-slider__slide className to children - if (isValidElement(child)) { - return { - ...child, - props: { - ...child.props, - className: `${ - child.props.className ? `${child.props.className} ` : '' - }keen-slider__slide`, - }, - } - } - return child - })} -
    - - - {slider && - Children.map(children, (child, idx) => { - if (isValidElement(child)) { - return { - ...child, - props: { - ...child.props, - className: cn(child.props.className, s.thumb, { - [s.selected]: currentSlide === idx, - }), - id: `thumb-${idx}`, - onClick: () => { - slider.moveToSlideRelative(idx) - }, - }, - } - } - return child - })} - -
    - ) -} - -export default ProductSlider diff --git a/components/product/ProductSlider/index.ts b/components/product/ProductSlider/index.ts deleted file mode 100644 index 504440410..000000000 --- a/components/product/ProductSlider/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ProductSlider' diff --git a/components/product/ProductSliderControl/ProductSliderControl.module.css b/components/product/ProductSliderControl/ProductSliderControl.module.css deleted file mode 100644 index c744e7598..000000000 --- a/components/product/ProductSliderControl/ProductSliderControl.module.css +++ /dev/null @@ -1,29 +0,0 @@ -.control { - @apply bg-violet absolute bottom-10 right-10 flex flex-row - border-accent-0 border text-accent-0 z-30 shadow-xl select-none; - height: 48px; -} - -.leftControl, -.rightControl { - @apply px-9 cursor-pointer; - transition: background-color 0.2s ease; -} - -.leftControl:hover, -.rightControl:hover { - background-color: var(--violet-dark); -} - -.leftControl:focus, -.rightControl:focus { - @apply outline-none; -} - -.rightControl { - @apply border-l border-accent-0; -} - -.leftControl { - margin-right: -1px; -} diff --git a/components/product/ProductSliderControl/ProductSliderControl.tsx b/components/product/ProductSliderControl/ProductSliderControl.tsx deleted file mode 100644 index 4e767b5db..000000000 --- a/components/product/ProductSliderControl/ProductSliderControl.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import cn from 'classnames' -import React from 'react' -import s from './ProductSliderControl.module.css' -import { ArrowLeft, ArrowRight } from '@components/icons' - -interface ProductSliderControl { - onPrev: React.MouseEventHandler - onNext: React.MouseEventHandler -} - -const ProductSliderControl: React.FC = React.memo( - ({ onPrev, onNext }) => ( -
    - - -
    - ) -) -export default ProductSliderControl diff --git a/components/product/ProductSliderControl/index.ts b/components/product/ProductSliderControl/index.ts deleted file mode 100644 index 5b63c466f..000000000 --- a/components/product/ProductSliderControl/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ProductSliderControl' diff --git a/components/product/ProductTag/ProductTag.module.css b/components/product/ProductTag/ProductTag.module.css deleted file mode 100644 index faf2fd97f..000000000 --- a/components/product/ProductTag/ProductTag.module.css +++ /dev/null @@ -1,30 +0,0 @@ -.root { - @apply transition-colors ease-in-out duration-500 - absolute top-0 left-0 z-20 pr-16; -} - -.root .name { - @apply pt-0 max-w-full w-full leading-extra-loose; - font-size: 2rem; - letter-spacing: 0.4px; - line-height: 2.2em; -} - -.root .name span { - @apply py-4 px-6 bg-primary text-primary font-bold; - min-height: 70px; - font-size: inherit; - letter-spacing: inherit; - box-decoration-break: clone; - -webkit-box-decoration-break: clone; -} - -.root .name span.fontsizing { - display: flex; - padding-top: 1.5rem; -} - -.root .price { - @apply pt-2 px-6 pb-4 text-sm bg-primary text-accent-9 - font-semibold inline-block tracking-wide; -} diff --git a/components/product/ProductTag/ProductTag.tsx b/components/product/ProductTag/ProductTag.tsx deleted file mode 100644 index 2bc80b878..000000000 --- a/components/product/ProductTag/ProductTag.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import cn from 'classnames' -import { inherits } from 'util' -import s from './ProductTag.module.css' - -interface ProductTagProps { - className?: string - name: string - price: string - fontSize?: number -} - -const ProductTag: React.FC = ({ - name, - price, - className = '', - fontSize = 32, -}) => { - return ( -
    -

    - - {name} - -

    -
    {price}
    -
    - ) -} - -export default ProductTag diff --git a/components/product/ProductTag/index.ts b/components/product/ProductTag/index.ts deleted file mode 100644 index cb345e8bd..000000000 --- a/components/product/ProductTag/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ProductTag' diff --git a/components/product/ProductView/ProductView.module.css b/components/product/ProductView/ProductView.module.css deleted file mode 100644 index 0b3ebf564..000000000 --- a/components/product/ProductView/ProductView.module.css +++ /dev/null @@ -1,60 +0,0 @@ -.root { - @apply relative grid items-start gap-1 grid-cols-1 overflow-x-hidden; - min-height: auto; -} - -.main { - @apply relative px-0 pb-0 box-border flex flex-col col-span-1; - min-height: 500px; -} - -.sidebar { - @apply flex flex-col col-span-1 mx-auto max-w-8xl px-6 py-6 w-full h-full; -} - -.sliderContainer { - @apply flex items-center justify-center overflow-x-hidden bg-violet; -} - -.imageContainer { - @apply text-center; -} - -.imageContainer > div, -.imageContainer > div > div { - @apply h-full; -} - -.sliderContainer .img { - @apply w-full h-auto max-h-full object-cover; -} - -.button { - width: 100%; -} - -.wishlistButton { - @apply absolute z-30 top-0 right-0; -} - -.relatedProductsGrid { - @apply grid grid-cols-2 py-2 gap-2 md:grid-cols-4 md:gap-7; -} - -@screen lg { - .root { - @apply grid-cols-12; - } - - .main { - @apply mx-0 col-span-8; - } - - .sidebar { - @apply col-span-4 py-6; - } - - .imageContainer { - max-height: 600px; - } -} diff --git a/components/product/ProductView/ProductView.tsx b/components/product/ProductView/ProductView.tsx deleted file mode 100644 index cfe26983a..000000000 --- a/components/product/ProductView/ProductView.tsx +++ /dev/null @@ -1,109 +0,0 @@ -import cn from 'classnames' -import Image from 'next/image' -import { NextSeo } from 'next-seo' -import s from './ProductView.module.css' -import { FC } from 'react' -import type { Product } from '@commerce/types/product' -import usePrice from '@framework/product/use-price' -import { ProductSlider, ProductCard } from '@components/product' -import { Container, Text } from '@components/ui' -import ProductSidebar from '../ProductSidebar' -import ProductTag from '../ProductTag' -import { WishlistButton } from '@components/wishlist' -interface ProductViewProps { - product: Product - relatedProducts: Product[] -} - -const ProductView: FC = ({ product, relatedProducts }) => { - const { price } = usePrice({ - amount: product.price.value, - baseAmount: product.price.retailPrice, - currencyCode: product.price.currencyCode!, - }) - - return ( - <> - -
    -
    - -
    - - {product.images.map((image, i) => ( -
    - {image.alt -
    - ))} -
    -
    - {process.env.COMMERCE_WISHLIST_ENABLED && ( - - )} -
    - - -
    -
    -
    - Related Products -
    - {relatedProducts.map((p) => ( -
    - -
    - ))} -
    -
    -
    - - - ) -} - -export default ProductView diff --git a/components/product/ProductView/index.ts b/components/product/ProductView/index.ts deleted file mode 100644 index 9ac144801..000000000 --- a/components/product/ProductView/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './ProductView' diff --git a/components/product/Swatch/Swatch.module.css b/components/product/Swatch/Swatch.module.css deleted file mode 100644 index 79a69e548..000000000 --- a/components/product/Swatch/Swatch.module.css +++ /dev/null @@ -1,54 +0,0 @@ -.swatch { - box-sizing: border-box; - composes: root from '@components/ui/Button/Button.module.css'; - @apply h-10 w-10 bg-primary text-primary rounded-full mr-3 inline-flex - items-center justify-center cursor-pointer transition duration-150 ease-in-out - p-0 shadow-none border-accent-3 border box-border select-none; - margin-right: calc(0.75rem - 1px); - overflow: hidden; - width: 48px; - height: 48px; -} - -.swatch::before, -.swatch::after { - box-sizing: border-box; -} - -.swatch:hover { - @apply transform scale-110 bg-hover; -} - -.swatch > span { - @apply absolute; -} - -.color { - @apply text-black transition duration-150 ease-in-out; -} - -.color :hover { - @apply text-black; -} - -.color.dark, -.color.dark:hover { - color: white !important; -} - -.active { - @apply border-accent-9 border-2; - padding-right: 1px; - padding-left: 1px; -} - -.textLabel { - @apply w-auto px-4; - min-width: 3rem; -} - -.active.textLabel { - @apply border-accent-9 border-2; - padding-right: calc(1rem - 1px); - padding-left: calc(1rem - 1px); -} diff --git a/components/product/Swatch/Swatch.tsx b/components/product/Swatch/Swatch.tsx deleted file mode 100644 index d04e77a78..000000000 --- a/components/product/Swatch/Swatch.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import cn from 'classnames' -import React from 'react' -import s from './Swatch.module.css' -import { Check } from '@components/icons' -import Button, { ButtonProps } from '@components/ui/Button' -import { isDark } from '@lib/colors' -interface SwatchProps { - active?: boolean - children?: any - className?: string - variant?: 'size' | 'color' | string - color?: string - label?: string | null -} - -const Swatch: React.FC & SwatchProps> = React.memo( - ({ - active, - className, - color = '', - label = null, - variant = 'size', - ...props - }) => { - variant = variant?.toLowerCase() - - if (label) { - label = label?.toLowerCase() - } - - const swatchClassName = cn( - s.swatch, - { - [s.color]: color, - [s.active]: active, - [s.size]: variant === 'size', - [s.dark]: color ? isDark(color) : false, - [s.textLabel]: !color && label && label.length > 3, - }, - className - ) - - return ( - - ) - } -) - -export default Swatch diff --git a/components/product/Swatch/index.ts b/components/product/Swatch/index.ts deleted file mode 100644 index c8a795498..000000000 --- a/components/product/Swatch/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Swatch' diff --git a/components/product/helpers.ts b/components/product/helpers.ts deleted file mode 100644 index d3fbd5ef5..000000000 --- a/components/product/helpers.ts +++ /dev/null @@ -1,32 +0,0 @@ -import type { Product } from '@commerce/types/product' -export type SelectedOptions = Record -import { Dispatch, SetStateAction } from 'react' - -export function getProductVariant(product: Product, opts: SelectedOptions) { - const variant = product.variants.find((variant) => { - return Object.entries(opts).every(([key, value]) => - variant.options.find((option) => { - if ( - option.__typename === 'MultipleChoiceOption' && - option.displayName.toLowerCase() === key.toLowerCase() - ) { - return option.values.find((v) => v.label.toLowerCase() === value) - } - }) - ) - }) - return variant -} - -export function selectDefaultOptionFromProduct( - product: Product, - updater: Dispatch> -) { - // Selects the default option - product.variants[0].options?.forEach((v) => { - updater((choices) => ({ - ...choices, - [v.displayName.toLowerCase()]: v.values[0].label.toLowerCase(), - })) - }) -} diff --git a/components/product/index.ts b/components/product/index.ts deleted file mode 100644 index 8b70f8e2e..000000000 --- a/components/product/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export { default as Swatch } from './Swatch' -export { default as ProductView } from './ProductView' -export { default as ProductCard } from './ProductCard' -export { default as ProductSlider } from './ProductSlider' -export { default as ProductOptions } from './ProductOptions' diff --git a/components/ui/Button/Button.module.css b/components/ui/Button/Button.module.css deleted file mode 100644 index 2ac7544f7..000000000 --- a/components/ui/Button/Button.module.css +++ /dev/null @@ -1,48 +0,0 @@ -.root { - @apply bg-accent-9 text-accent-0 cursor-pointer inline-flex - px-10 py-5 leading-6 transition ease-in-out duration-150 - shadow-sm text-center justify-center uppercase - border border-transparent items-center text-sm font-semibold - tracking-wide; - max-height: 64px; -} - -.root:hover { - @apply border-accent-9 bg-accent-6; -} - -.root:focus { - @apply shadow-outline-normal outline-none; -} - -.root[data-active] { - @apply bg-accent-6; -} - -.loading { - @apply bg-accent-1 text-accent-3 border-accent-2 cursor-not-allowed; -} - -.slim { - @apply py-2 transform-none normal-case; -} - -.ghost { - @apply border border-accent-2 bg-accent-0 text-accent-9 text-sm; -} - -.ghost:hover { - @apply border-accent-9 bg-accent-9 text-accent-0; -} - -.disabled, -.disabled:hover { - @apply text-accent-4 border-accent-2 bg-accent-1 cursor-not-allowed; - filter: grayscale(1); - -webkit-transform: translateZ(0); - -webkit-perspective: 1000; - -webkit-backface-visibility: hidden; -} - -.progress { -} diff --git a/components/ui/Button/Button.tsx b/components/ui/Button/Button.tsx deleted file mode 100644 index b29fb432a..000000000 --- a/components/ui/Button/Button.tsx +++ /dev/null @@ -1,73 +0,0 @@ -import cn from 'classnames' -import React, { - forwardRef, - ButtonHTMLAttributes, - JSXElementConstructor, - useRef, -} from 'react' -import mergeRefs from 'react-merge-refs' -import s from './Button.module.css' -import { LoadingDots } from '@components/ui' - -export interface ButtonProps extends ButtonHTMLAttributes { - href?: string - className?: string - variant?: 'flat' | 'slim' | 'ghost' - active?: boolean - type?: 'submit' | 'reset' | 'button' - Component?: string | JSXElementConstructor - width?: string | number - loading?: boolean - disabled?: boolean -} - -const Button: React.FC = forwardRef((props, buttonRef) => { - const { - className, - variant = 'flat', - children, - active, - width, - loading = false, - disabled = false, - style = {}, - Component = 'button', - ...rest - } = props - const ref = useRef(null) - - const rootClassName = cn( - s.root, - { - [s.ghost]: variant === 'ghost', - [s.slim]: variant === 'slim', - [s.loading]: loading, - [s.disabled]: disabled, - }, - className - ) - - return ( - - {children} - {loading && ( - - - - )} - - ) -}) - -export default Button diff --git a/components/ui/Button/index.ts b/components/ui/Button/index.ts deleted file mode 100644 index aa076c58e..000000000 --- a/components/ui/Button/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default } from './Button' -export * from './Button' diff --git a/components/ui/Collapse/Collapse.module.css b/components/ui/Collapse/Collapse.module.css deleted file mode 100644 index fb4a82a90..000000000 --- a/components/ui/Collapse/Collapse.module.css +++ /dev/null @@ -1,25 +0,0 @@ -.root { - @apply border-b border-accent-2 py-4 flex flex-col outline-none; -} - -.header { - @apply flex flex-row items-center; -} - -.header .label { - @apply text-base font-medium; -} - -.content { - @apply pt-3 overflow-hidden pl-8; -} - -.icon { - @apply mr-3 text-accent-6; - margin-left: -6px; - transition: transform 0.2s ease; -} - -.icon.open { - transform: rotate(90deg); -} diff --git a/components/ui/Collapse/Collapse.tsx b/components/ui/Collapse/Collapse.tsx deleted file mode 100644 index b2f9525ac..000000000 --- a/components/ui/Collapse/Collapse.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import cn from 'classnames' -import React, { FC, ReactNode, useState } from 'react' -import s from './Collapse.module.css' -import { ChevronRight } from '@components/icons' -import { useSpring, a } from '@react-spring/web' -import useMeasure from 'react-use-measure' - -export interface CollapseProps { - title: string - children: ReactNode -} - -const Collapse: FC = React.memo(({ title, children }) => { - const [isActive, setActive] = useState(false) - const [ref, { height: viewHeight }] = useMeasure() - - const animProps = useSpring({ - height: isActive ? viewHeight : 0, - config: { tension: 250, friction: 32, clamp: true, duration: 150 }, - opacity: isActive ? 1 : 0, - }) - - const toggle = () => setActive((x) => !x) - - return ( -
    -
    - - {title} -
    - -
    - {children} -
    -
    -
    - ) -}) - -export default Collapse diff --git a/components/ui/Collapse/index.ts b/components/ui/Collapse/index.ts deleted file mode 100644 index 1e584a53b..000000000 --- a/components/ui/Collapse/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default } from './Collapse' -export * from './Collapse' diff --git a/components/ui/Container/Container.tsx b/components/ui/Container/Container.tsx deleted file mode 100644 index 538b1cac7..000000000 --- a/components/ui/Container/Container.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import cn from 'classnames' -import React, { FC } from 'react' - -interface ContainerProps { - className?: string - children?: any - el?: HTMLElement - clean?: boolean -} - -const Container: FC = ({ - children, - className, - el = 'div', - clean, -}) => { - const rootClassName = cn(className, { - 'mx-auto max-w-8xl px-6': !clean, - }) - - let Component: React.ComponentType> = - el as any - - return {children} -} - -export default Container diff --git a/components/ui/Container/index.ts b/components/ui/Container/index.ts deleted file mode 100644 index 9dbd596a8..000000000 --- a/components/ui/Container/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Container' diff --git a/components/ui/Grid/Grid.module.css b/components/ui/Grid/Grid.module.css deleted file mode 100644 index 27e4c5b19..000000000 --- a/components/ui/Grid/Grid.module.css +++ /dev/null @@ -1,154 +0,0 @@ -.root { - @apply grid grid-cols-1 gap-0; - - @screen lg { - @apply grid-cols-3 grid-rows-2; - } - - & > * { - @apply row-span-1 bg-transparent box-border overflow-hidden; - height: 500px; - max-height: 800px; - - @screen lg { - @apply col-span-1; - height: inherit; - } - } -} - -.default { - & > * { - @apply bg-transparent; - } -} - -.layoutNormal { - @apply gap-3; -} - -@screen md { - .layoutNormal > * { - max-height: min-content !important; - } -} - -@screen lg { - .layoutNormal > * { - max-height: 400px; - } -} - -.layoutA { - & > *:nth-child(6n + 1), - & > *:nth-child(6n + 5) { - @apply row-span-2; - height: var(--row-height); - - @screen lg { - @apply col-span-2; - } - } - - &.filled { - & > *:nth-child(6n + 1) { - @apply bg-violet; - } - - & > *:nth-child(6n + 2) { - @apply bg-accent-8; - } - - & > *:nth-child(6n + 3) { - @apply bg-pink; - } - - & > *:nth-child(6n + 6) { - @apply bg-cyan; - } - } -} - -.layoutB { - & > *:nth-child(6n + 2), - & > *:nth-child(6n + 4) { - @apply row-span-2; - height: var(--row-height); - - @screen lg { - @apply col-span-2; - } - } - - &.filled { - & > *:nth-child(6n + 1) { - @apply bg-violet; - } - - & > *:nth-child(6n + 2) { - @apply bg-accent-8; - } - - & > *:nth-child(6n + 3) { - @apply bg-pink; - } - - & > *:nth-child(6n + 6) { - @apply bg-cyan; - } - } -} - -.layoutC { - & > *:nth-child(12n + 1), - & > *:nth-child(12n + 8) { - @apply row-span-2; - height: var(--row-height); - - @screen lg { - @apply col-span-2; - } - } - - &.filled { - & > *:nth-child(12n + 1) { - @apply bg-violet; - height: var(--row-height); - } - - & > *:nth-child(12n + 8) { - @apply bg-cyan; - height: var(--row-height); - } - - & > *:nth-child(6n + 3) { - @apply bg-pink; - } - } -} - -.layoutD { - & > *:nth-child(12n + 2), - & > *:nth-child(12n + 7) { - @apply row-span-2; - height: var(--row-height); - - @screen lg { - @apply col-span-2; - } - } - - &.filled { - & > *:nth-child(12n + 2) { - @apply bg-violet; - } - - & > *:nth-child(12n + 7) { - @apply bg-cyan; - } - - & > *:nth-child(6n + 3) { - @apply bg-pink; - } - } -} diff --git a/components/ui/Grid/Grid.tsx b/components/ui/Grid/Grid.tsx deleted file mode 100644 index 55ca78277..000000000 --- a/components/ui/Grid/Grid.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import cn from 'classnames' -import { FC, ReactNode, Component } from 'react' -import s from './Grid.module.css' - -interface GridProps { - className?: string - children?: ReactNode[] | Component[] | any[] - layout?: 'A' | 'B' | 'C' | 'D' | 'normal' - variant?: 'default' | 'filled' -} - -const Grid: FC = ({ - className, - layout = 'A', - children, - variant = 'default', -}) => { - const rootClassName = cn( - s.root, - { - [s.layoutA]: layout === 'A', - [s.layoutB]: layout === 'B', - [s.layoutC]: layout === 'C', - [s.layoutD]: layout === 'D', - [s.layoutNormal]: layout === 'normal', - [s.default]: variant === 'default', - [s.filled]: variant === 'filled', - }, - className - ) - return
    {children}
    -} - -export default Grid diff --git a/components/ui/Grid/index.ts b/components/ui/Grid/index.ts deleted file mode 100644 index ddb51299b..000000000 --- a/components/ui/Grid/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Grid' diff --git a/components/ui/Hero/Hero.module.css b/components/ui/Hero/Hero.module.css deleted file mode 100644 index a0f1798f5..000000000 --- a/components/ui/Hero/Hero.module.css +++ /dev/null @@ -1,30 +0,0 @@ -.root { - @apply flex flex-col py-16 mx-auto; -} - -.title { - @apply text-accent-0 font-extrabold text-4xl leading-none tracking-tight; -} - -.description { - @apply mt-4 text-xl leading-8 text-accent-2 mb-1 lg:max-w-4xl; -} - -@screen lg { - .root { - @apply flex-row items-start justify-center py-32; - } - .title { - @apply text-5xl max-w-xl text-right leading-10 -mt-3; - line-height: 3.5rem; - } - .description { - @apply mt-0 ml-6; - } -} - -@screen xl { - .title { - @apply text-6xl; - } -} diff --git a/components/ui/Hero/Hero.tsx b/components/ui/Hero/Hero.tsx deleted file mode 100644 index 58d13e5de..000000000 --- a/components/ui/Hero/Hero.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import React, { FC } from 'react' -import { Container } from '@components/ui' -import { ArrowRight } from '@components/icons' -import s from './Hero.module.css' -import Link from 'next/link' -interface HeroProps { - className?: string - headline: string - description: string -} - -const Hero: FC = ({ headline, description }) => { - return ( -
    - -
    -

    {headline}

    -
    -

    {description}

    - - - Read it here - - - -
    -
    -
    -
    - ) -} - -export default Hero diff --git a/components/ui/Hero/index.ts b/components/ui/Hero/index.ts deleted file mode 100644 index b08fa5ac8..000000000 --- a/components/ui/Hero/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Hero' diff --git a/components/ui/Input/Input.module.css b/components/ui/Input/Input.module.css deleted file mode 100644 index 34507f445..000000000 --- a/components/ui/Input/Input.module.css +++ /dev/null @@ -1,7 +0,0 @@ -.root { - @apply bg-primary py-2 px-6 w-full appearance-none transition duration-150 ease-in-out pr-10 border border-accent-3 text-accent-6; -} - -.root:focus { - @apply outline-none shadow-outline-normal; -} diff --git a/components/ui/Input/Input.tsx b/components/ui/Input/Input.tsx deleted file mode 100644 index e630728b2..000000000 --- a/components/ui/Input/Input.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import cn from 'classnames' -import s from './Input.module.css' -import React, { InputHTMLAttributes } from 'react' - -export interface InputProps extends InputHTMLAttributes { - className?: string - onChange?: (...args: any[]) => any -} - -const Input: React.FC = (props) => { - const { className, children, onChange, ...rest } = props - - const rootClassName = cn(s.root, {}, className) - - const handleOnChange = (e: any) => { - if (onChange) { - onChange(e.target.value) - } - return null - } - - return ( - - ) -} - -export default Input diff --git a/components/ui/Input/index.ts b/components/ui/Input/index.ts deleted file mode 100644 index aa97178e5..000000000 --- a/components/ui/Input/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Input' diff --git a/components/ui/Link/Link.tsx b/components/ui/Link/Link.tsx deleted file mode 100644 index 27f30e863..000000000 --- a/components/ui/Link/Link.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import NextLink, { LinkProps as NextLinkProps } from 'next/link' - -const Link: React.FC = ({ href, children, ...props }) => { - return ( - - {children} - - ) -} - -export default Link diff --git a/components/ui/Link/index.ts b/components/ui/Link/index.ts deleted file mode 100644 index 518d37298..000000000 --- a/components/ui/Link/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Link' diff --git a/components/ui/LoadingDots/LoadingDots.module.css b/components/ui/LoadingDots/LoadingDots.module.css deleted file mode 100644 index 6054de3c7..000000000 --- a/components/ui/LoadingDots/LoadingDots.module.css +++ /dev/null @@ -1,33 +0,0 @@ -.root { - @apply inline-flex text-center items-center leading-7; -} - -.root .dot { - @apply rounded-full h-2 w-2; - background-color: currentColor; - animation-name: blink; - animation-duration: 1.4s; - animation-iteration-count: infinite; - animation-fill-mode: both; - margin: 0 2px; -} - -.root .dot:nth-of-type(2) { - animation-delay: 0.2s; -} - -.root .dot::nth-of-type(3) { - animation-delay: 0.4s; -} - -@keyframes blink { - 0% { - opacity: 0.2; - } - 20% { - opacity: 1; - } - 100% { - opacity: 0.2; - } -} diff --git a/components/ui/LoadingDots/LoadingDots.tsx b/components/ui/LoadingDots/LoadingDots.tsx deleted file mode 100644 index 27ce9f25f..000000000 --- a/components/ui/LoadingDots/LoadingDots.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import s from './LoadingDots.module.css' - -const LoadingDots: React.FC = () => { - return ( - - - - - - ) -} - -export default LoadingDots diff --git a/components/ui/LoadingDots/index.ts b/components/ui/LoadingDots/index.ts deleted file mode 100644 index 63df282bf..000000000 --- a/components/ui/LoadingDots/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './LoadingDots' diff --git a/components/ui/Logo/Logo.tsx b/components/ui/Logo/Logo.tsx deleted file mode 100644 index f15bde40a..000000000 --- a/components/ui/Logo/Logo.tsx +++ /dev/null @@ -1,21 +0,0 @@ -const Logo = ({ className = '', ...props }) => ( - - - - -) - -export default Logo diff --git a/components/ui/Logo/index.ts b/components/ui/Logo/index.ts deleted file mode 100644 index 93dce23b4..000000000 --- a/components/ui/Logo/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Logo' diff --git a/components/ui/Marquee/Marquee.module.css b/components/ui/Marquee/Marquee.module.css deleted file mode 100644 index e5ecb16ef..000000000 --- a/components/ui/Marquee/Marquee.module.css +++ /dev/null @@ -1,22 +0,0 @@ -.root { - @apply w-full min-w-full relative flex flex-row items-center overflow-hidden py-0; - max-height: 320px; -} - -.root > div { - max-height: 320px; - padding: 0; - margin: 0; -} - -.root > div > * > *:nth-child(2) * { - max-height: 100%; -} - -.primary { - @apply bg-accent-0; -} - -.secondary { - @apply bg-accent-9; -} diff --git a/components/ui/Marquee/Marquee.tsx b/components/ui/Marquee/Marquee.tsx deleted file mode 100644 index ce5ec2338..000000000 --- a/components/ui/Marquee/Marquee.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import cn from 'classnames' -import s from './Marquee.module.css' -import { FC, ReactNode, Component, Children } from 'react' -import { default as FastMarquee } from 'react-fast-marquee' - -interface MarqueeProps { - className?: string - children?: ReactNode[] | Component[] | any[] - variant?: 'primary' | 'secondary' -} - -const Marquee: FC = ({ - className = '', - children, - variant = 'primary', -}) => { - const rootClassName = cn( - s.root, - { - [s.primary]: variant === 'primary', - [s.secondary]: variant === 'secondary', - }, - className - ) - - return ( - - {Children.map(children, (child) => ({ - ...child, - props: { - ...child.props, - className: cn(child.props.className, `${variant}`), - }, - }))} - - ) -} - -export default Marquee diff --git a/components/ui/Marquee/index.ts b/components/ui/Marquee/index.ts deleted file mode 100644 index b59b75568..000000000 --- a/components/ui/Marquee/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Marquee' diff --git a/components/ui/Modal/Modal.module.css b/components/ui/Modal/Modal.module.css deleted file mode 100644 index f30d7c90a..000000000 --- a/components/ui/Modal/Modal.module.css +++ /dev/null @@ -1,17 +0,0 @@ -.root { - @apply fixed bg-black bg-opacity-40 flex items-center inset-0 z-50 justify-center; - backdrop-filter: blur(0.8px); - -webkit-backdrop-filter: blur(0.8px); -} - -.modal { - @apply bg-primary p-12 border border-accent-2 relative; -} - -.modal:focus { - @apply outline-none; -} - -.close { - @apply hover:text-accent-5 transition ease-in-out duration-150 focus:outline-none absolute right-0 top-0 m-6; -} diff --git a/components/ui/Modal/Modal.tsx b/components/ui/Modal/Modal.tsx deleted file mode 100644 index bb42b3d1b..000000000 --- a/components/ui/Modal/Modal.tsx +++ /dev/null @@ -1,59 +0,0 @@ -import { FC, useRef, useEffect, useCallback } from 'react' -import s from './Modal.module.css' -import FocusTrap from '@lib/focus-trap' -import { Cross } from '@components/icons' -import { - disableBodyScroll, - clearAllBodyScrollLocks, - enableBodyScroll, -} from 'body-scroll-lock' -interface ModalProps { - className?: string - children?: any - onClose: () => void - onEnter?: () => void | null -} - -const Modal: FC = ({ children, onClose }) => { - const ref = useRef() as React.MutableRefObject - - const handleKey = useCallback( - (e: KeyboardEvent) => { - if (e.key === 'Escape') { - return onClose() - } - }, - [onClose] - ) - - useEffect(() => { - if (ref.current) { - disableBodyScroll(ref.current, { reserveScrollBarGap: true }) - window.addEventListener('keydown', handleKey) - } - return () => { - if (ref && ref.current) { - enableBodyScroll(ref.current) - } - clearAllBodyScrollLocks() - window.removeEventListener('keydown', handleKey) - } - }, [handleKey]) - - return ( -
    -
    - - {children} -
    -
    - ) -} - -export default Modal diff --git a/components/ui/Modal/index.ts b/components/ui/Modal/index.ts deleted file mode 100644 index e24753a1e..000000000 --- a/components/ui/Modal/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Modal' diff --git a/components/ui/Quantity/Quantity.module.css b/components/ui/Quantity/Quantity.module.css deleted file mode 100644 index fa60cc56e..000000000 --- a/components/ui/Quantity/Quantity.module.css +++ /dev/null @@ -1,27 +0,0 @@ -.actions { - @apply flex p-1 border-accent-2 border items-center justify-center - w-12 text-accent-7; - transition-property: border-color, background, color, transform, box-shadow; - - transition-duration: 0.15s; - transition-timing-function: ease; - user-select: none; -} - -.actions:hover { - @apply border bg-accent-1 border-accent-3 text-accent-9; - transition: border-color; - z-index: 10; -} - -.actions:focus { - @apply outline-none; -} - -.actions:disabled { - @apply cursor-not-allowed; -} - -.input { - @apply bg-transparent px-4 w-full h-full focus:outline-none select-none pointer-events-auto; -} diff --git a/components/ui/Quantity/Quantity.tsx b/components/ui/Quantity/Quantity.tsx deleted file mode 100644 index abde145aa..000000000 --- a/components/ui/Quantity/Quantity.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import React, { FC } from 'react' -import s from './Quantity.module.css' -import { Cross, Plus, Minus } from '@components/icons' -import cn from 'classnames' -export interface QuantityProps { - value: number - increase: () => any - decrease: () => any - handleRemove: React.MouseEventHandler - handleChange: React.ChangeEventHandler - max?: number -} - -const Quantity: FC = ({ - value, - increase, - decrease, - handleChange, - handleRemove, - max = 6, -}) => { - return ( -
    - - - - -
    - ) -} - -export default Quantity diff --git a/components/ui/Quantity/index.ts b/components/ui/Quantity/index.ts deleted file mode 100644 index 5ee880cc9..000000000 --- a/components/ui/Quantity/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default } from './Quantity' -export * from './Quantity' diff --git a/components/ui/README.md b/components/ui/README.md deleted file mode 100644 index 5bf4fe510..000000000 --- a/components/ui/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# UI - -Building blocks to build a rich graphical interfaces. Components should be atomic and pure. Serve one purpose. diff --git a/components/ui/Rating/Rating.tsx b/components/ui/Rating/Rating.tsx deleted file mode 100644 index 259e642ea..000000000 --- a/components/ui/Rating/Rating.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React, { FC } from 'react' -import rangeMap from '@lib/range-map' -import { Star } from '@components/icons' -import cn from 'classnames' - -export interface RatingProps { - value: number -} - -const Quantity: React.FC = React.memo(({ value = 5 }) => { - return ( -
    - {rangeMap(5, (i) => ( - = Math.floor(value), - })} - > - - - ))} -
    - ) -}) - -export default Quantity diff --git a/components/ui/Rating/index.ts b/components/ui/Rating/index.ts deleted file mode 100644 index 1354efb25..000000000 --- a/components/ui/Rating/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default } from './Rating' -export * from './Rating' diff --git a/components/ui/Sidebar/Sidebar.module.css b/components/ui/Sidebar/Sidebar.module.css deleted file mode 100644 index f6a49387f..000000000 --- a/components/ui/Sidebar/Sidebar.module.css +++ /dev/null @@ -1,14 +0,0 @@ -.root { - @apply fixed inset-0 h-full z-50 box-border; -} - -.sidebar { - @apply h-full flex flex-col text-base bg-accent-0 shadow-xl overflow-y-auto overflow-x-hidden; - -webkit-overflow-scrolling: touch !important; -} - -.backdrop { - @apply absolute inset-0 bg-black bg-opacity-40 duration-100 ease-linear; - backdrop-filter: blur(0.8px); - -webkit-backdrop-filter: blur(0.8px); -} diff --git a/components/ui/Sidebar/Sidebar.tsx b/components/ui/Sidebar/Sidebar.tsx deleted file mode 100644 index ce0eeefe2..000000000 --- a/components/ui/Sidebar/Sidebar.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { FC, useEffect, useRef } from 'react' -import s from './Sidebar.module.css' -import cn from 'classnames' -import { - disableBodyScroll, - enableBodyScroll, - clearAllBodyScrollLocks, -} from 'body-scroll-lock' - -interface SidebarProps { - children: any - onClose: () => void -} - -const Sidebar: FC = ({ children, onClose }) => { - const ref = useRef() as React.MutableRefObject - - useEffect(() => { - if (ref.current) { - disableBodyScroll(ref.current, { reserveScrollBarGap: true }) - } - return () => { - if (ref && ref.current) { - enableBodyScroll(ref.current) - } - clearAllBodyScrollLocks() - } - }, []) - - return ( -
    -
    -
    -
    -
    -
    - {children} -
    -
    -
    -
    -
    - ) -} - -export default Sidebar diff --git a/components/ui/Sidebar/index.ts b/components/ui/Sidebar/index.ts deleted file mode 100644 index 877187ca3..000000000 --- a/components/ui/Sidebar/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Sidebar' diff --git a/components/ui/Skeleton/Skeleton.module.css b/components/ui/Skeleton/Skeleton.module.css deleted file mode 100644 index 37c164de7..000000000 --- a/components/ui/Skeleton/Skeleton.module.css +++ /dev/null @@ -1,48 +0,0 @@ -.skeleton { - @apply block; - background-image: linear-gradient( - 270deg, - var(--accent-0), - var(--accent-2), - var(--accent-0), - var(--accent-1) - ); - background-size: 400% 100%; - animation: loading 8s ease-in-out infinite; -} - -.wrapper { - @apply block relative; - - &:not(.show)::before { - content: none; - } - - &::before { - content: ''; - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 100; - background-image: linear-gradient( - 270deg, - var(--accent-0), - var(--accent-2), - var(--accent-0), - var(--accent-1) - ); - background-size: 400% 100%; - animation: loading 8s ease-in-out infinite; - } -} - -@keyframes loading { - 0% { - background-position: 200% 0; - } - 100% { - background-position: -200% 0; - } -} diff --git a/components/ui/Skeleton/Skeleton.tsx b/components/ui/Skeleton/Skeleton.tsx deleted file mode 100644 index 9cef2c1ac..000000000 --- a/components/ui/Skeleton/Skeleton.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import React, { CSSProperties } from 'react' -import cn from 'classnames' -import px from '@lib/to-pixels' -import s from './Skeleton.module.css' - -interface SkeletonProps { - show?: boolean - block?: boolean - className?: string - style?: CSSProperties - width?: string | number - height?: string | number - boxHeight?: string | number -} - -const Skeleton: React.FC = ({ - style, - width, - height, - children, - className, - show = true, - boxHeight = height, -}) => { - // Automatically calculate the size if there are children - // and no fixed sizes are specified - const shouldAutoSize = !!children && !(width || height) - - // Defaults - width = width || 24 - height = height || 24 - boxHeight = boxHeight || height - - return ( - - {children} - - ) -} - -export default Skeleton diff --git a/components/ui/Skeleton/index.ts b/components/ui/Skeleton/index.ts deleted file mode 100644 index 3ec6c0031..000000000 --- a/components/ui/Skeleton/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Skeleton' diff --git a/components/ui/Text/Text.module.css b/components/ui/Text/Text.module.css deleted file mode 100644 index f572fdf18..000000000 --- a/components/ui/Text/Text.module.css +++ /dev/null @@ -1,15 +0,0 @@ -.body { - @apply text-base leading-7 max-w-6xl mx-auto; -} - -.heading { - @apply text-5xl pt-1 pb-2 font-semibold tracking-wide cursor-pointer mb-2; -} - -.pageHeading { - @apply pt-1 pb-4 text-2xl leading-7 font-bold tracking-wide; -} - -.sectionHeading { - @apply pt-1 pb-2 text-2xl font-bold tracking-wide cursor-pointer mb-2; -} diff --git a/components/ui/Text/Text.tsx b/components/ui/Text/Text.tsx deleted file mode 100644 index 6106c209a..000000000 --- a/components/ui/Text/Text.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import React, { - FunctionComponent, - JSXElementConstructor, - CSSProperties, -} from 'react' -import cn from 'classnames' -import s from './Text.module.css' - -interface TextProps { - variant?: Variant - className?: string - style?: CSSProperties - children?: React.ReactNode | any - html?: string - onClick?: () => any -} - -type Variant = 'heading' | 'body' | 'pageHeading' | 'sectionHeading' - -const Text: FunctionComponent = ({ - style, - className = '', - variant = 'body', - children, - html, - onClick, -}) => { - const componentsMap: { - [P in Variant]: React.ComponentType | string - } = { - body: 'div', - heading: 'h1', - pageHeading: 'h1', - sectionHeading: 'h2', - } - - const Component: - | JSXElementConstructor - | React.ReactElement - | React.ComponentType - | string = componentsMap![variant!] - - const htmlContentProps = html - ? { - dangerouslySetInnerHTML: { __html: html }, - } - : {} - - return ( - - {children} - - ) -} - -export default Text diff --git a/components/ui/Text/index.ts b/components/ui/Text/index.ts deleted file mode 100644 index e1e5fa74e..000000000 --- a/components/ui/Text/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './Text' diff --git a/components/ui/context.tsx b/components/ui/context.tsx deleted file mode 100644 index d2f5aebfd..000000000 --- a/components/ui/context.tsx +++ /dev/null @@ -1,216 +0,0 @@ -import React, { FC, useCallback, useMemo } from 'react' -import { ThemeProvider } from 'next-themes' - -export interface State { - displaySidebar: boolean - displayDropdown: boolean - displayModal: boolean - sidebarView: string - modalView: string - userAvatar: string -} - -const initialState = { - displaySidebar: false, - displayDropdown: false, - displayModal: false, - modalView: 'LOGIN_VIEW', - sidebarView: 'CHECKOUT_VIEW', - userAvatar: '', -} - -type Action = - | { - type: 'OPEN_SIDEBAR' - } - | { - type: 'CLOSE_SIDEBAR' - } - | { - type: 'OPEN_DROPDOWN' - } - | { - type: 'CLOSE_DROPDOWN' - } - | { - type: 'OPEN_MODAL' - } - | { - type: 'CLOSE_MODAL' - } - | { - type: 'SET_MODAL_VIEW' - view: MODAL_VIEWS - } - | { - type: 'SET_SIDEBAR_VIEW' - view: SIDEBAR_VIEWS - } - | { - type: 'SET_USER_AVATAR' - value: string - } - -type MODAL_VIEWS = - | 'SIGNUP_VIEW' - | 'LOGIN_VIEW' - | 'FORGOT_VIEW' - | 'NEW_SHIPPING_ADDRESS' - | 'NEW_PAYMENT_METHOD' - -type SIDEBAR_VIEWS = 'CART_VIEW' | 'CHECKOUT_VIEW' | 'PAYMENT_METHOD_VIEW' - -export const UIContext = React.createContext(initialState) - -UIContext.displayName = 'UIContext' - -function uiReducer(state: State, action: Action) { - switch (action.type) { - case 'OPEN_SIDEBAR': { - return { - ...state, - displaySidebar: true, - } - } - case 'CLOSE_SIDEBAR': { - return { - ...state, - displaySidebar: false, - } - } - case 'OPEN_DROPDOWN': { - return { - ...state, - displayDropdown: true, - } - } - case 'CLOSE_DROPDOWN': { - return { - ...state, - displayDropdown: false, - } - } - case 'OPEN_MODAL': { - return { - ...state, - displayModal: true, - displaySidebar: false, - } - } - case 'CLOSE_MODAL': { - return { - ...state, - displayModal: false, - } - } - case 'SET_MODAL_VIEW': { - return { - ...state, - modalView: action.view, - } - } - case 'SET_SIDEBAR_VIEW': { - return { - ...state, - sidebarView: action.view, - } - } - case 'SET_USER_AVATAR': { - return { - ...state, - userAvatar: action.value, - } - } - } -} - -export const UIProvider: FC = (props) => { - const [state, dispatch] = React.useReducer(uiReducer, initialState) - - const openSidebar = useCallback( - () => dispatch({ type: 'OPEN_SIDEBAR' }), - [dispatch] - ) - const closeSidebar = useCallback( - () => dispatch({ type: 'CLOSE_SIDEBAR' }), - [dispatch] - ) - const toggleSidebar = useCallback( - () => - state.displaySidebar - ? dispatch({ type: 'CLOSE_SIDEBAR' }) - : dispatch({ type: 'OPEN_SIDEBAR' }), - [dispatch, state.displaySidebar] - ) - const closeSidebarIfPresent = useCallback( - () => state.displaySidebar && dispatch({ type: 'CLOSE_SIDEBAR' }), - [dispatch, state.displaySidebar] - ) - - const openDropdown = useCallback( - () => dispatch({ type: 'OPEN_DROPDOWN' }), - [dispatch] - ) - const closeDropdown = useCallback( - () => dispatch({ type: 'CLOSE_DROPDOWN' }), - [dispatch] - ) - - const openModal = useCallback( - () => dispatch({ type: 'OPEN_MODAL' }), - [dispatch] - ) - const closeModal = useCallback( - () => dispatch({ type: 'CLOSE_MODAL' }), - [dispatch] - ) - - const setUserAvatar = useCallback( - (value: string) => dispatch({ type: 'SET_USER_AVATAR', value }), - [dispatch] - ) - - const setModalView = useCallback( - (view: MODAL_VIEWS) => dispatch({ type: 'SET_MODAL_VIEW', view }), - [dispatch] - ) - - const setSidebarView = useCallback( - (view: SIDEBAR_VIEWS) => dispatch({ type: 'SET_SIDEBAR_VIEW', view }), - [dispatch] - ) - - const value = useMemo( - () => ({ - ...state, - openSidebar, - closeSidebar, - toggleSidebar, - closeSidebarIfPresent, - openDropdown, - closeDropdown, - openModal, - closeModal, - setModalView, - setSidebarView, - setUserAvatar, - }), - [state] - ) - - return -} - -export const useUI = () => { - const context = React.useContext(UIContext) - if (context === undefined) { - throw new Error(`useUI must be used within a UIProvider`) - } - return context -} - -export const ManagedUIContext: FC = ({ children }) => ( - - {children} - -) diff --git a/components/ui/index.ts b/components/ui/index.ts deleted file mode 100644 index 47bdbd9ff..000000000 --- a/components/ui/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -export { default as Hero } from './Hero' -export { default as Logo } from './Logo' -export { default as Grid } from './Grid' -export { default as Button } from './Button' -export { default as Sidebar } from './Sidebar' -export { default as Marquee } from './Marquee' -export { default as Container } from './Container' -export { default as LoadingDots } from './LoadingDots' -export { default as Skeleton } from './Skeleton' -export { default as Modal } from './Modal' -export { default as Text } from './Text' -export { default as Input } from './Input' -export { default as Collapse } from './Collapse' -export { default as Quantity } from './Quantity' -export { default as Rating } from './Rating' -export { useUI } from './context' diff --git a/components/wishlist/WishlistButton/WishlistButton.module.css b/components/wishlist/WishlistButton/WishlistButton.module.css deleted file mode 100644 index 3bdf1e710..000000000 --- a/components/wishlist/WishlistButton/WishlistButton.module.css +++ /dev/null @@ -1,33 +0,0 @@ -.root { - transition-duration: 0.2s; - transition-timing-function: ease; - transition-property: color, background-color, opacity; - @apply p-3 text-accent-9 flex items-center - justify-center font-semibold cursor-pointer - bg-accent-0 text-sm; -} - -.root:focus { - @apply outline-none; -} - -.icon { - transition-duration: 0.2s; - transition-timing-function: ease; - transition-property: transform, fill; - color: currentColor; -} - -.icon.loading { - fill: var(--pink-light); -} - -.icon.inWishlist { - fill: var(--pink); -} - -@screen lg { - .root { - @apply p-4; - } -} diff --git a/components/wishlist/WishlistButton/WishlistButton.tsx b/components/wishlist/WishlistButton/WishlistButton.tsx deleted file mode 100644 index a48eac170..000000000 --- a/components/wishlist/WishlistButton/WishlistButton.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import React, { FC, useState } from 'react' -import cn from 'classnames' -import { useUI } from '@components/ui' -import { Heart } from '@components/icons' -import useAddItem from '@framework/wishlist/use-add-item' -import useCustomer from '@framework/customer/use-customer' -import useWishlist from '@framework/wishlist/use-wishlist' -import useRemoveItem from '@framework/wishlist/use-remove-item' -import s from './WishlistButton.module.css' -import type { Product, ProductVariant } from '@commerce/types/product' - -type Props = { - productId: Product['id'] - variant: ProductVariant -} & React.ButtonHTMLAttributes - -const WishlistButton: FC = ({ - productId, - variant, - className, - ...props -}) => { - const { data } = useWishlist() - const addItem = useAddItem() - const removeItem = useRemoveItem() - const { data: customer } = useCustomer() - const { openModal, setModalView } = useUI() - const [loading, setLoading] = useState(false) - - // @ts-ignore Wishlist is not always enabled - const itemInWishlist = data?.items?.find( - // @ts-ignore Wishlist is not always enabled - (item) => - item.product_id === Number(productId) && - (item.variant_id as any) === Number(variant.id) - ) - - const handleWishlistChange = async (e: any) => { - e.preventDefault() - - if (loading) return - - // A login is required before adding an item to the wishlist - if (!customer) { - setModalView('LOGIN_VIEW') - return openModal() - } - - setLoading(true) - - try { - if (itemInWishlist) { - await removeItem({ id: itemInWishlist.id! }) - } else { - await addItem({ - productId, - variantId: variant?.id!, - }) - } - - setLoading(false) - } catch (err) { - setLoading(false) - } - } - - return ( - - ) -} - -export default WishlistButton diff --git a/components/wishlist/WishlistButton/index.ts b/components/wishlist/WishlistButton/index.ts deleted file mode 100644 index 66e88074b..000000000 --- a/components/wishlist/WishlistButton/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default } from './WishlistButton' diff --git a/components/wishlist/index.ts b/components/wishlist/index.ts deleted file mode 100644 index 9fe0a3541..000000000 --- a/components/wishlist/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as WishlistButton } from './WishlistButton' diff --git a/grocery-vercel-commerce b/grocery-vercel-commerce deleted file mode 160000 index 3c7aa8e86..000000000 --- a/grocery-vercel-commerce +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 3c7aa8e862bfd8d44719be44c6c0a31ab01524a3 diff --git a/next.config.js b/next.config.js index 515b2ae7c..d3ad64f4a 100644 --- a/next.config.js +++ b/next.config.js @@ -13,6 +13,10 @@ const isVendure = provider === 'vendure' module.exports = withCommerceConfig({ commerce, + images: { + // todo: replace domains for images + domains: ['user-images.githubusercontent.com'], + }, i18n: { locales: ['en-US', 'es'], defaultLocale: 'en-US', diff --git a/pages/404.tsx b/pages/404.tsx index 38a01bcc4..8a357fb51 100644 --- a/pages/404.tsx +++ b/pages/404.tsx @@ -1,24 +1,4 @@ -import type { GetStaticPropsContext } from 'next' -import commerce from '@lib/api/commerce' -import { Layout } from '@components/common' - -export async function getStaticProps({ - preview, - locale, - locales, -}: GetStaticPropsContext) { - const config = { locale, locales } - const { pages } = await commerce.getAllPages({ config, preview }) - const { categories, brands } = await commerce.getSiteInfo({ config, preview }) - return { - props: { - pages, - categories, - brands, - }, - revalidate: 200, - } -} +import { Layout } from "src/components/common" export default function NotFound() { return ( diff --git a/pages/[...pages].tsx b/pages/[...pages].tsx deleted file mode 100644 index a8a24b3aa..000000000 --- a/pages/[...pages].tsx +++ /dev/null @@ -1,86 +0,0 @@ -import type { - GetStaticPathsContext, - GetStaticPropsContext, - InferGetStaticPropsType, -} from 'next' -import commerce from '@lib/api/commerce' -import { Text } from '@components/ui' -import { Layout } from '@components/common' -import getSlug from '@lib/get-slug' -import { missingLocaleInPages } from '@lib/usage-warns' -import type { Page } from '@commerce/types/page' -import { useRouter } from 'next/router' - -export async function getStaticProps({ - preview, - params, - locale, - locales, -}: GetStaticPropsContext<{ pages: string[] }>) { - const config = { locale, locales } - const pagesPromise = commerce.getAllPages({ config, preview }) - const siteInfoPromise = commerce.getSiteInfo({ config, preview }) - const { pages } = await pagesPromise - const { categories } = await siteInfoPromise - const path = params?.pages.join('/') - const slug = locale ? `${locale}/${path}` : path - const pageItem = pages.find((p: Page) => - p.url ? getSlug(p.url) === slug : false - ) - const data = - pageItem && - (await commerce.getPage({ - variables: { id: pageItem.id! }, - config, - preview, - })) - - const page = data?.page - - if (!page) { - // We throw to make sure this fails at build time as this is never expected to happen - throw new Error(`Page with slug '${slug}' not found`) - } - - return { - props: { pages, page, categories }, - revalidate: 60 * 60, // Every hour - } -} - -export async function getStaticPaths({ locales }: GetStaticPathsContext) { - const config = { locales } - const { pages }: { pages: Page[] } = await commerce.getAllPages({ config }) - const [invalidPaths, log] = missingLocaleInPages() - const paths = pages - .map((page) => page.url) - .filter((url) => { - if (!url || !locales) return url - // If there are locales, only include the pages that include one of the available locales - if (locales.includes(getSlug(url).split('/')[0])) return url - - invalidPaths.push(url) - }) - log() - - return { - paths, - fallback: 'blocking', - } -} - -export default function Pages({ - page, -}: InferGetStaticPropsType) { - const router = useRouter() - - return router.isFallback ? ( -

    Loading...

    // TODO (BC) Add Skeleton Views - ) : ( -
    - {page?.body && } -
    - ) -} - -Pages.Layout = Layout diff --git a/pages/cart.tsx b/pages/cart.tsx deleted file mode 100644 index b9659d21b..000000000 --- a/pages/cart.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import type { GetStaticPropsContext } from 'next' -import commerce from '@lib/api/commerce' -import { Layout } from '@components/common' -// import useCart from '@framework/cart/use-cart' -// import usePrice from '@framework/product/use-price' -// import { Button, Text } from '@components/ui' -// import { Bag, Cross, Check, MapPin, CreditCard } from '@components/icons' -// import { CartItem } from '@components/cart' - -export async function getStaticProps({ - preview, - locale, - locales, -}: GetStaticPropsContext) { - const config = { locale, locales } - const pagesPromise = commerce.getAllPages({ config, preview }) - const siteInfoPromise = commerce.getSiteInfo({ config, preview }) - const { pages } = await pagesPromise - const { categories } = await siteInfoPromise - return { - props: { pages, categories }, - } -} - -export default function Cart() { - // const error = null - // const success = null - // const { data, isLoading, isEmpty } = useCart() - - // const { price: subTotal } = usePrice( - // data && { - // amount: Number(data.subtotalPrice), - // currencyCode: data.currency.code, - // } - // ) - // const { price: total } = usePrice( - // data && { - // amount: Number(data.totalPrice), - // currencyCode: data.currency.code, - // } - // ) - - return ( -
    - This is cart page -
    - ) -} - -Cart.Layout = Layout diff --git a/pages/demo.tsx b/pages/demo.tsx new file mode 100644 index 000000000..38f91037c --- /dev/null +++ b/pages/demo.tsx @@ -0,0 +1,13 @@ +import { Layout } from 'src/components/common'; + + + +export default function Demo() { + return <> + Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestias possimus tempore, nulla voluptate sed iste unde qui. Natus, amet minus, fugiat unde optio iste perferendis ea quae iusto asperiores voluptates enim sunt ducimus? Perferendis velit maxime sint pariatur beatae, veniam nulla sed, impedit, consectetur minus est libero enim? Quia reiciendis dolor, porro nisi harum fuga ullam pariatur facilis quas, praesentium quae, eveniet officiis officia animi aspernatur ut sunt commodi vero totam! Rerum, placeat perferendis laborum itaque blanditiis natus aperiam, eum delectus enim architecto eos, et voluptates! Illo at sed, pariatur ullam suscipit rerum recusandae doloremque natus nihil. Et temporibus quae necessitatibus quam alias, repellat laudantium a perspiciatis dolorum accusamus officiis pariatur ipsum facilis, nobis magni molestiae accusantium assumenda tempora consequuntur natus nostrum? Id, mollitia alias quidem hic aperiam error, blanditiis vero distinctio sit neque assumenda odio praesentium, perspiciatis aspernatur exercitationem. Eveniet nostrum tempore saepe cupiditate totam fuga doloremque placeat natus beatae quibusdam labore tempora delectus alias architecto vel, recusandae facilis nam rerum dolores magni? Eaque fugiat ut dicta. Aperiam, excepturi ad molestias non corrupti, officia dolore sequi, provident laborum officiis praesentium beatae quos? Totam et consequatur atque fugit voluptate. Aliquam neque, ab hic suscipit obcaecati ut aut quos. Expedita, ipsam. + Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestias possimus tempore, nulla voluptate sed iste unde qui. Natus, amet minus, fugiat unde optio iste perferendis ea quae iusto asperiores voluptates enim sunt ducimus? Perferendis velit maxime sint pariatur beatae, veniam nulla sed, impedit, consectetur minus est libero enim? Quia reiciendis dolor, porro nisi harum fuga ullam pariatur facilis quas, praesentium quae, eveniet officiis officia animi aspernatur ut sunt commodi vero totam! Rerum, placeat perferendis laborum itaque blanditiis natus aperiam, eum delectus enim architecto eos, et voluptates! Illo at sed, pariatur ullam suscipit rerum recusandae doloremque natus nihil. Et temporibus quae necessitatibus quam alias, repellat laudantium a perspiciatis dolorum accusamus officiis pariatur ipsum facilis, nobis magni molestiae accusantium assumenda tempora consequuntur natus nostrum? Id, mollitia alias quidem hic aperiam error, blanditiis vero distinctio sit neque assumenda odio praesentium, perspiciatis aspernatur exercitationem. Eveniet nostrum tempore saepe cupiditate totam fuga doloremque placeat natus beatae quibusdam labore tempora delectus alias architecto vel, recusandae facilis nam rerum dolores magni? Eaque fugiat ut dicta. Aperiam, excepturi ad molestias non corrupti, officia dolore sequi, provident laborum officiis praesentium beatae quos? Totam et consequatur atque fugit voluptate. Aliquam neque, ab hic suscipit obcaecati ut aut quos. Expedita, ipsam. + Lorem ipsum dolor sit amet consectetur adipisicing elit. Molestias possimus tempore, nulla voluptate sed iste unde qui. Natus, amet minus, fugiat unde optio iste perferendis ea quae iusto asperiores voluptates enim sunt ducimus? Perferendis velit maxime sint pariatur beatae, veniam nulla sed, impedit, consectetur minus est libero enim? Quia reiciendis dolor, porro nisi harum fuga ullam pariatur facilis quas, praesentium quae, eveniet officiis officia animi aspernatur ut sunt commodi vero totam! Rerum, placeat perferendis laborum itaque blanditiis natus aperiam, eum delectus enim architecto eos, et voluptates! Illo at sed, pariatur ullam suscipit rerum recusandae doloremque natus nihil. Et temporibus quae necessitatibus quam alias, repellat laudantium a perspiciatis dolorum accusamus officiis pariatur ipsum facilis, nobis magni molestiae accusantium assumenda tempora consequuntur natus nostrum? Id, mollitia alias quidem hic aperiam error, blanditiis vero distinctio sit neque assumenda odio praesentium, perspiciatis aspernatur exercitationem. Eveniet nostrum tempore saepe cupiditate totam fuga doloremque placeat natus beatae quibusdam labore tempora delectus alias architecto vel, recusandae facilis nam rerum dolores magni? Eaque fugiat ut dicta. Aperiam, excepturi ad molestias non corrupti, officia dolore sequi, provident laborum officiis praesentium beatae quos? Totam et consequatur atque fugit voluptate. Aliquam neque, ab hic suscipit obcaecati ut aut quos. Expedita, ipsam. + +} + +Demo.Layout = Layout diff --git a/pages/index.tsx b/pages/index.tsx index c193554a9..158b1dc60 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,37 +1,19 @@ - -import { CardBlog, CollapseCommon, Layout, RelevantBlogPosts } from 'src/components/common'; +import { Layout } from 'src/components/common'; import { HomeBanner, HomeCategories, HomeCollection, HomeCTA, HomeFeature, HomeRecipe, HomeSubscribe, HomeVideo } from 'src/components/modules/home'; -import {SelectCommon} from 'src/components/common' -import card from "../public/assets/images/card.png" -const CONTENT = [ - "When you’re trying to eat healthier but want something more substantial than a leafy green salad, broccoli salad is there for you. I love the crunch and heft of broccoli, especially when it’s cut up into bite size spoonable pieces.", - "Some people aren’t into raw broccoli, but I love it! I always go for the raw broccoli on those vegetable platters that seem to be at every potluck/party you go to.", - "This is a simple broccoli salad: you have the bulk of it, raw broccoli; crunchy red onions for a bit of acidity and raw crunch, craisins for sweetness, almonds for a nutty counter point; and a sweet and tangy soy-rice vinegar-sesame dressing.", -] export default function Home() { return ( <> - {/* - + - */} - {/* - */} - {/* */} - {/* Sort By - Sort By */} - - - - - - - - {/* todo: uncomment */} + + + + + {/* // todo: uncomment */} {/* */} ) diff --git a/pages/product/[slug].tsx b/pages/product/[slug].tsx index c5bcbdba1..c34394af5 100644 --- a/pages/product/[slug].tsx +++ b/pages/product/[slug].tsx @@ -1,76 +1,16 @@ -import { Layout } from '@components/common' -import commerce from '@lib/api/commerce' -import type { - GetStaticPathsContext, - GetStaticPropsContext, - InferGetStaticPropsType -} from 'next' -import { useRouter } from 'next/router' -export async function getStaticProps({ - params, - locale, - locales, - preview, -}: GetStaticPropsContext<{ slug: string }>) { - const config = { locale, locales } - const pagesPromise = commerce.getAllPages({ config, preview }) - const siteInfoPromise = commerce.getSiteInfo({ config, preview }) - const productPromise = commerce.getProduct({ - variables: { slug: params!.slug }, - config, - preview, - }) +import { Layout, RecipeDetail } from 'src/components/common' +import { ProductInfoDetail, RecommendedRecipes, ReleventProducts, ViewedProducts } from 'src/components/modules/product-detail' +import { INGREDIENT_DATA_TEST, RECIPE_DATA_TEST } from 'src/utils/demo-data' - const allProductsPromise = commerce.getAllProducts({ - variables: { first: 4 }, - config, - preview, - }) - const { pages } = await pagesPromise - const { categories } = await siteInfoPromise - const { product } = await productPromise - const { products: relatedProducts } = await allProductsPromise - - if (!product) { - throw new Error(`Product with slug '${params!.slug}' not found`) - } - - return { - props: { - pages, - product, - relatedProducts, - categories, - }, - revalidate: 200, - } -} - -export async function getStaticPaths({ locales }: GetStaticPathsContext) { - const { products } = await commerce.getAllProductPaths() - - return { - paths: locales - ? locales.reduce((arr, locale) => { - // Add a product path for every locale - products.forEach((product: any) => { - arr.push(`/${locale}/product${product.path}`) - }) - return arr - }, []) - : products.map((product: any) => `/product${product.path}`), - fallback: 'blocking', - } -} - -export default function Slug({ - product, - relatedProducts, -}: InferGetStaticPropsType) { - const router = useRouter() - - return
    This is product page
    +export default function Slug() { + return <> + + + + + + } Slug.Layout = Layout diff --git a/pages/test.tsx b/pages/test.tsx index c1e1f5d5f..7fb1f9294 100644 --- a/pages/test.tsx +++ b/pages/test.tsx @@ -9,6 +9,7 @@ import { import { CardItemCheckoutProps } from 'src/components/common/CardItemCheckout/CardItemCheckout' import CheckoutCollapse from 'src/components/common/CheckoutCollapse/CheckoutCollapse' import PaginationCommon from 'src/components/common/PaginationCommon/PaginationCommon' +import { CheckoutInfo } from 'src/components/modules/checkout' import image5 from '../public/assets/images/image5.png' import image6 from '../public/assets/images/image6.png' import image7 from '../public/assets/images/image7.png' @@ -16,6 +17,7 @@ import image8 from '../public/assets/images/image8.png' const dataTest:CardItemCheckoutProps[] = [ { name: 'Tomato', + slug: "tomato", weight: '250g', category: 'VEGGIE', price: 'Rp 27.500', @@ -24,6 +26,7 @@ const dataTest:CardItemCheckoutProps[] = [ }, { name: 'Carrot', + slug: "carrot", weight: '250g', category: 'VEGGIE', price: 'Rp 27.500', @@ -32,20 +35,13 @@ const dataTest:CardItemCheckoutProps[] = [ }, { name: 'Salad', + slug:"salad", weight: '250g', category: 'VEGGIE', price: 'Rp 27.500', imageSrc: image8.src, quantity:2 }, - { - name: 'Tomato', - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image5.src, - quantity:9 - }, ] export default function Test() { const [visible, setVisible] = useState(false) @@ -64,15 +60,8 @@ export default function Test() { } return ( <> -
    -
    - - - - - - -
    +
    +
    diff --git a/src/components/common/BreadcrumbCommon/BreadcrumbCommon.module.scss b/src/components/common/BreadcrumbCommon/BreadcrumbCommon.module.scss index 6741f386c..8f6c05bf7 100644 --- a/src/components/common/BreadcrumbCommon/BreadcrumbCommon.module.scss +++ b/src/components/common/BreadcrumbCommon/BreadcrumbCommon.module.scss @@ -1,6 +1,8 @@ @import '../../../styles/utilities'; .breadcrumbCommon { - @apply spacing-horizontal-left; color: var(--text-base); -} \ No newline at end of file + .currentItem { + cursor: default; + } +} diff --git a/src/components/common/BreadcrumbCommon/BreadcrumbCommon.tsx b/src/components/common/BreadcrumbCommon/BreadcrumbCommon.tsx index 2dca6b714..be84dcb67 100644 --- a/src/components/common/BreadcrumbCommon/BreadcrumbCommon.tsx +++ b/src/components/common/BreadcrumbCommon/BreadcrumbCommon.tsx @@ -1,42 +1,37 @@ import React from 'react' +import { ROUTE } from 'src/utils/constanst.utils' import s from './BreadcrumbCommon.module.scss' import BreadcrumbItem from './components/BreadcrumbItem/BreadcrumbItem' import BreadcrumbSeparator from './components/BreadcrumbSeparator/BreadcrumbSeparator' interface BreadcrumbCommonProps { - crumbs: { link:string, name:string }[]; + crumbs: { link: string, name: string }[]; showHomePage?: boolean; } -const BreadcrumbCommon = ({ crumbs, showHomePage=false } : BreadcrumbCommonProps) => { - if (showHomePage) { - crumbs.unshift({link: "/", name: "Home"}); - } +const BreadcrumbCommon = ({ crumbs, showHomePage = true }: BreadcrumbCommonProps) => { return (
    { - crumbs.map((crumb, i) => { - if (i === 0) { - return ( - - ) - } - if (i === crumbs.length-1) { - return ( - - - - ) - } - return ( - - - - ) - }) + + showHomePage && } -
    + { + crumbs.length > 0 && <> + + { + crumbs.slice(0, crumbs.length - 1).map((crumb) => ( + < BreadcrumbSeparator key={crumb.name}> + + + ))} + < BreadcrumbSeparator> + {crumbs[crumbs.length - 1].name} + + + } + ) } diff --git a/src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.module.scss b/src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.module.scss new file mode 100644 index 000000000..3a785f480 --- /dev/null +++ b/src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.module.scss @@ -0,0 +1,5 @@ +.breadcrumbItem { + &:hover { + color: var(--primary); + } +} diff --git a/src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.tsx b/src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.tsx index f807de555..13f980ea9 100644 --- a/src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.tsx +++ b/src/components/common/BreadcrumbCommon/components/BreadcrumbItem/BreadcrumbItem.tsx @@ -1,5 +1,6 @@ import React from 'react' import Link from 'next/link' +import s from './BreadcrumbItem.module.scss' interface BreadcrumbItemProps { text: string; @@ -9,7 +10,7 @@ interface BreadcrumbItemProps { const BreadcrumbItem = ({ text, href }: BreadcrumbItemProps) => { return ( - {text} + {text} ) } diff --git a/src/components/common/BreadcrumbCommon/components/BreadcrumbSeparator/BreadcrumbSeparator.tsx b/src/components/common/BreadcrumbCommon/components/BreadcrumbSeparator/BreadcrumbSeparator.tsx index f84bc3a51..370c342d8 100644 --- a/src/components/common/BreadcrumbCommon/components/BreadcrumbSeparator/BreadcrumbSeparator.tsx +++ b/src/components/common/BreadcrumbCommon/components/BreadcrumbSeparator/BreadcrumbSeparator.tsx @@ -1,7 +1,7 @@ import React from 'react' interface BreadcrumbSeparatorProps { - children?: React.ReactNode; + children?: React.ReactNode } const BreadcrumbSeparator = ({ children }: BreadcrumbSeparatorProps) => { diff --git a/src/components/common/ButtonCommon/ButtonCommon.module.scss b/src/components/common/ButtonCommon/ButtonCommon.module.scss index 4cfe737de..c7b9f1ffa 100644 --- a/src/components/common/ButtonCommon/ButtonCommon.module.scss +++ b/src/components/common/ButtonCommon/ButtonCommon.module.scss @@ -7,6 +7,9 @@ align-items: center; padding: 1rem 2rem; @screen md { + padding: 0.8rem 1.6rem; + } + @screen lg { padding: 0.8rem 3.2rem; } &:disabled { @@ -84,11 +87,14 @@ padding: 1rem; } @screen md { - padding: 1.6rem 4.8rem; + padding: 1.6rem 3.2rem; &.onlyIcon { padding: 1.6rem; } } + @screen lg { + padding: 1.6rem 4.8rem; + } &.loading { &::before { width: 2.4rem; diff --git a/src/components/common/CarouselCommon/CarouselCommon.module.scss b/src/components/common/CarouselCommon/CarouselCommon.module.scss index da306f38f..ef2671947 100644 --- a/src/components/common/CarouselCommon/CarouselCommon.module.scss +++ b/src/components/common/CarouselCommon/CarouselCommon.module.scss @@ -8,6 +8,7 @@ :global(.customArrow) { width: 64px; height: 64px; + border-radius: .8rem; &:focus { outline: none; } diff --git a/src/components/common/CartDrawer/CartDrawer.module.scss b/src/components/common/CartDrawer/CartDrawer.module.scss new file mode 100644 index 000000000..126028d3c --- /dev/null +++ b/src/components/common/CartDrawer/CartDrawer.module.scss @@ -0,0 +1,12 @@ +@import '../../../styles/utilities'; + + +.cartDrawer { + @apply flex flex-col h-full; + .body { + @apply overflow-y-auto overflow-x-hidden h-full custom-scroll; + } + .bottom { + padding-top: 1.6rem; + } +} \ No newline at end of file diff --git a/src/components/common/CartDrawer/CartDrawer.tsx b/src/components/common/CartDrawer/CartDrawer.tsx new file mode 100644 index 000000000..0a432bb65 --- /dev/null +++ b/src/components/common/CartDrawer/CartDrawer.tsx @@ -0,0 +1,35 @@ +import React from 'react'; +import { PRODUCT_CART_DATA_TEST } from 'src/utils/demo-data'; +import { DrawerCommon } from '..'; +import s from './CartDrawer.module.scss'; +import CartCheckoutButton from './components/CartCheckoutButton/CartCheckoutButton'; +import CartMessage from './components/CartMessage/CartMessage'; +import CartRecommendation from './components/CartRecommendation/CartRecommendation'; +import ProductsInCart from './components/ProductsInCart/ProductsInCart'; + +interface Props { + visible: boolean + onClose: () => void +} + +const CartDrawer = ({ visible, onClose }: Props) => { + return ( + +
    +
    + + +
    +
    + + +
    +
    +
    + ) +} + +export default CartDrawer; \ No newline at end of file diff --git a/src/components/common/CartDrawer/components/CartCheckoutButton/CartCheckoutButton.module.scss b/src/components/common/CartDrawer/components/CartCheckoutButton/CartCheckoutButton.module.scss new file mode 100644 index 000000000..3f90bffbd --- /dev/null +++ b/src/components/common/CartDrawer/components/CartCheckoutButton/CartCheckoutButton.module.scss @@ -0,0 +1,6 @@ +.cartCheckoutButton { + padding: 1.6rem; + button { + width: 100%; + } +} diff --git a/src/components/common/CartDrawer/components/CartCheckoutButton/CartCheckoutButton.tsx b/src/components/common/CartDrawer/components/CartCheckoutButton/CartCheckoutButton.tsx new file mode 100644 index 000000000..0cd7d00a2 --- /dev/null +++ b/src/components/common/CartDrawer/components/CartCheckoutButton/CartCheckoutButton.tsx @@ -0,0 +1,13 @@ +import React, { memo } from 'react'; +import { ButtonCommon } from 'src/components/common'; +import s from './CartCheckoutButton.module.scss'; + +const CartCheckoutButton = memo(() => { + return ( +
    + Check out - Rp 120.500 +
    + ) +}) + +export default CartCheckoutButton; \ No newline at end of file diff --git a/src/components/common/CartDrawer/components/CartMessage/CartMessage.module.scss b/src/components/common/CartDrawer/components/CartMessage/CartMessage.module.scss new file mode 100644 index 000000000..59d8e8ddc --- /dev/null +++ b/src/components/common/CartDrawer/components/CartMessage/CartMessage.module.scss @@ -0,0 +1,16 @@ +@import "../../../../../styles/utilities"; + +.cartMessage { + @apply flex bg-info; + padding: 1.2rem 1.6rem; + .text { + color: var(--white); + font-weight: bold; + margin-right: 0.8rem; + } + .icon { + svg path { + fill: var(--text-placeholder); + } + } +} diff --git a/src/components/common/CartDrawer/components/CartMessage/CartMessage.tsx b/src/components/common/CartDrawer/components/CartMessage/CartMessage.tsx new file mode 100644 index 000000000..2cc85fb49 --- /dev/null +++ b/src/components/common/CartDrawer/components/CartMessage/CartMessage.tsx @@ -0,0 +1,18 @@ +import React, { memo } from 'react'; +import { IconInfo } from 'src/components/icons'; +import s from './CartMessage.module.scss'; + +const CartMessage = memo(() => { + return ( +
    +
    + You save - Rp 150 +
    +
    + +
    +
    + ) +}) + +export default CartMessage; \ No newline at end of file diff --git a/src/components/common/CartDrawer/components/CartRecommendation/CartRecommendation.module.scss b/src/components/common/CartDrawer/components/CartRecommendation/CartRecommendation.module.scss new file mode 100644 index 000000000..88664460c --- /dev/null +++ b/src/components/common/CartDrawer/components/CartRecommendation/CartRecommendation.module.scss @@ -0,0 +1,26 @@ +@import '../../../../../styles/utilities'; + +.cartRecommendation { + @apply w-full bg-background-gray; + .top { + @apply flex justify-between items-center; + padding: 1.6rem; + .heading { + @apply font-bold text-active sm-headline; + } + } + .productCardWarpper { + padding-left: 1.6rem; + :global(.customArrow) { + @apply bg-line; + @screen lg { + &:global(.leftArrow) { + left: calc(-6.4rem - 2rem); + } + &:global(.rightArrow) { + right: calc(-6.4rem - 2rem); + } + } + } + } +} diff --git a/src/components/common/CartDrawer/components/CartRecommendation/CartRecommendation.tsx b/src/components/common/CartDrawer/components/CartRecommendation/CartRecommendation.tsx new file mode 100644 index 000000000..bbc40647e --- /dev/null +++ b/src/components/common/CartDrawer/components/CartRecommendation/CartRecommendation.tsx @@ -0,0 +1,43 @@ +import { TOptionsEvents } from 'keen-slider'; +import React from 'react'; +import { CarouselCommon, ViewAllItem } from 'src/components/common'; +import ProductCard, { ProductCardProps } from 'src/components/common/ProductCard/ProductCard'; +import { ROUTE } from 'src/utils/constanst.utils'; +import { PRODUCT_DATA_TEST } from 'src/utils/demo-data'; +import s from './CartRecommendation.module.scss'; + +const option: TOptionsEvents = { + slidesPerView: 2, + mode: 'free', + breakpoints: { + '(min-width: 640px)': { + slidesPerView: 1, + }, + '(min-width: 768px)': { + slidesPerView: 2.5, + } + }, +} + +const CartRecommendation = () => { + return ( +
    +
    +
    + Recommendation +
    + +
    +
    + + data={PRODUCT_DATA_TEST} + Component={ProductCard} + itemKey="cart-recommendation" + option={option} + /> +
    +
    + ) +} + +export default CartRecommendation; diff --git a/src/components/common/CartDrawer/components/ProductCartItem/ProductCartItem.module.scss b/src/components/common/CartDrawer/components/ProductCartItem/ProductCartItem.module.scss new file mode 100644 index 000000000..4988d4a66 --- /dev/null +++ b/src/components/common/CartDrawer/components/ProductCartItem/ProductCartItem.module.scss @@ -0,0 +1,54 @@ +@import "../../../../../styles/utilities"; + +.productCartItem { + @apply grid; + grid-template-columns: 2fr 1fr; + padding-bottom: 1.6rem; + padding-top: 1.6rem; + .info { + @apply flex; + .imgWrap { + width: 11rem; + height: 7.5rem; + margin-right: 1.6rem; + img { + object-fit: contain; + } + } + .detail { + min-height: 9rem; + .name { + &:hover { + color: var(--primary); + } + } + .price { + margin-top: 0.8rem; + .old { + margin-bottom: 0.8rem; + .number { + margin-right: 0.8rem; + color: var(--text-label); + text-decoration: line-through; + } + } + .current { + @apply text-active font-bold sm-headline; + } + } + } + } + + .actions { + @apply flex flex-col justify-between items-end; + margin-left: 1.6rem; + .iconDelete { + @apply cursor-pointer; + &:hover { + svg path { + fill: var(--negative); + } + } + } + } +} diff --git a/src/components/common/CartDrawer/components/ProductCartItem/ProductCartItem.tsx b/src/components/common/CartDrawer/components/ProductCartItem/ProductCartItem.tsx new file mode 100644 index 000000000..7ec3ecbdb --- /dev/null +++ b/src/components/common/CartDrawer/components/ProductCartItem/ProductCartItem.tsx @@ -0,0 +1,56 @@ +import React from 'react'; +import Link from 'next/link' +import { QuanittyInput } from 'src/components/common'; +import { IconDelete } from 'src/components/icons'; +import { ROUTE } from 'src/utils/constanst.utils'; +import { ProductProps } from 'src/utils/types.utils'; +import ImgWithLink from '../../../ImgWithLink/ImgWithLink'; +import LabelCommon from '../../../LabelCommon/LabelCommon'; +import s from './ProductCartItem.module.scss'; + +export interface ProductCartItempProps extends ProductProps { + quantity: number, +} + +const ProductCartItem = ({ name, slug, weight, price, oldPrice, discount, imageSrc, quantity }: ProductCartItempProps) => { + return ( +
    +
    + + +
    + +
    +
    + +
    + + +
    + {name} {weight ? `(${weight})` : ''} +
    +
    + +
    + { + oldPrice && +
    + {oldPrice} + {discount} +
    + } +
    {price}
    +
    +
    +
    +
    +
    + +
    + +
    +
    + ) +} + +export default ProductCartItem; \ No newline at end of file diff --git a/src/components/common/CartDrawer/components/ProductsInCart/ProductsInCart.module.scss b/src/components/common/CartDrawer/components/ProductsInCart/ProductsInCart.module.scss new file mode 100644 index 000000000..61ef7421e --- /dev/null +++ b/src/components/common/CartDrawer/components/ProductsInCart/ProductsInCart.module.scss @@ -0,0 +1,9 @@ +.productsInCart { + padding: 1.6rem 1.6rem 0 1.6rem; + list-style: none; + li { + &:not(:last-child) { + border-bottom: 1px solid var(--border-line); + } + } +} diff --git a/src/components/common/CartDrawer/components/ProductsInCart/ProductsInCart.tsx b/src/components/common/CartDrawer/components/ProductsInCart/ProductsInCart.tsx new file mode 100644 index 000000000..b455d4d73 --- /dev/null +++ b/src/components/common/CartDrawer/components/ProductsInCart/ProductsInCart.tsx @@ -0,0 +1,30 @@ +import React from 'react'; +import ProductCartItem, { ProductCartItempProps } from '../ProductCartItem/ProductCartItem'; +import s from './ProductsInCart.module.scss'; + +interface Props { + data: ProductCartItempProps[] +} + +const ProductsInCart = ({ data }: Props) => { + return ( +
      + { + data.map(item =>
    • + +
    • ) + } +
    + ) +} + +export default ProductsInCart; \ No newline at end of file diff --git a/src/components/common/CheckoutBill/CheckoutBill.module.scss b/src/components/common/CheckoutBill/CheckoutBill.module.scss index 9c002b2e5..d0b15d516 100644 --- a/src/components/common/CheckoutBill/CheckoutBill.module.scss +++ b/src/components/common/CheckoutBill/CheckoutBill.module.scss @@ -1,9 +1,30 @@ -.warpper{ - max-width: 56.3rem; - @apply flex justify-between flex-col; - .bot{ - .promo{ - padding: 3.2rem; - } +.warpper { + max-width: 56.3rem; + padding: 3.2rem; + @apply flex justify-between flex-col border-l-2 border-solid border-line; + .title { + font-weight: bold; + font-size: 2rem; + line-height: 2.8rem; + } + .list { + min-height: 52.8rem; + } + .bot { + .promo { + // padding: 3.2rem; + @apply bg-gray flex justify-between items-center; + min-height: 6.4rem; } -} \ No newline at end of file + .price { + .line { + @apply flex justify-between items-center text-label; + .total { + font-weight: bold; + font-size: 2rem; + line-height: 2.8rem; + } + } + } + } +} diff --git a/src/components/common/CheckoutBill/CheckoutBill.tsx b/src/components/common/CheckoutBill/CheckoutBill.tsx index 5493565cd..cdbbe5165 100644 --- a/src/components/common/CheckoutBill/CheckoutBill.tsx +++ b/src/components/common/CheckoutBill/CheckoutBill.tsx @@ -1,30 +1,46 @@ import React from 'react' -import s from "./CheckoutBill.module.scss" +import s from './CheckoutBill.module.scss' import { CardItemCheckout } from '..' import { CardItemCheckoutProps } from '../CardItemCheckout/CardItemCheckout' +import { IconCirclePlus } from 'src/components/icons' interface CheckoutBillProps { - data: CardItemCheckoutProps[] + data: CardItemCheckoutProps[] } -const CheckoutBill = ({data}: CheckoutBillProps) => { - return ( -
    -
    - {data.map((item,index)=>{ - return - })} -
    -
    -
    - -
    -
    - -
    -
    +const CheckoutBill = ({ data }: CheckoutBillProps) => { + return ( +
    +
    + Your cart ({data.length}) +
    +
    + {data.map((item) => { + return + })} +
    +
    +
    + Apply Promotion Code +
    - ) +
    +
    + Subtotal +
    RP 120.500
    +
    +
    + Shipping +
    Free
    +
    +
    + Estimated Total +
    RP 120.500
    +
    +
    +
    +
    + ) } export default CheckoutBill diff --git a/src/components/common/CheckoutCollapse/CheckoutCollapse.tsx b/src/components/common/CheckoutCollapse/CheckoutCollapse.tsx index b4825730a..14348a625 100644 --- a/src/components/common/CheckoutCollapse/CheckoutCollapse.tsx +++ b/src/components/common/CheckoutCollapse/CheckoutCollapse.tsx @@ -7,8 +7,9 @@ interface CheckoutCollapseProps { children: React.ReactNode title: string isEdit: boolean - onClose: () => void - onOpen: () => void + onClose?: (id:number) => void + onOpen?: (id:number) => void + onEditClick?:(id:number) => void } const CheckoutCollapse = ({ @@ -19,14 +20,18 @@ const CheckoutCollapse = ({ visible, onOpen, onClose, + onEditClick }: CheckoutCollapseProps) => { const handleTitleClick = () => { if(visible){ - onClose && onClose() + onClose && onClose(id) }else{ - onOpen && onOpen() + onOpen && onOpen(id) } } + const handleEdit = () => { + onEditClick && onEditClick(id) + } return (
    @@ -38,7 +43,7 @@ const CheckoutCollapse = ({ {title}
    - {isEdit &&
    {'Edit'}
    } + {isEdit &&
    {'Edit'}
    }
    {children}
    diff --git a/src/components/common/CustomerInfoForm/CustomerInfoForm.tsx b/src/components/common/CustomerInfoForm/CustomerInfoForm.tsx index a821c66eb..8496b119d 100644 --- a/src/components/common/CustomerInfoForm/CustomerInfoForm.tsx +++ b/src/components/common/CustomerInfoForm/CustomerInfoForm.tsx @@ -2,29 +2,30 @@ import Link from 'next/link' import React, { useRef } from 'react' import { ButtonCommon, Inputcommon } from 'src/components/common' import InputCommon from 'src/components/common/InputCommon/InputCommon' +import { CheckOutForm } from 'src/utils/types.utils' import s from './CustomerInfoForm.module.scss' interface CustomerInfoFormProps { - onConfirm?: ()=>void + onConfirm?: (id: number, formInfo: CheckOutForm) => void + id: number } -const CustomerInfoForm = ({}: CustomerInfoFormProps) => { - const nameRef = useRef>(null); - const emailRef = useRef>(null); +const CustomerInfoForm = ({ id, onConfirm }: CustomerInfoFormProps) => { + const nameRef = useRef>(null) + const emailRef = useRef>(null) - - - const handleConfirmClick = () => { - return { - name:nameRef?.current?.getValue(), - email:emailRef.current?.getValue() - } - } + const handleConfirmClick = () => { + onConfirm && + onConfirm(id, { + name: nameRef?.current?.getValue().toString(), + email: emailRef.current?.getValue().toString(), + }) + } return (
    - - + +
    @@ -42,7 +43,9 @@ const CustomerInfoForm = ({}: CustomerInfoFormProps) => { } .
    - Continue to Shipping + + Continue to Shipping +
    ) diff --git a/src/components/common/DrawerCommon/DrawerCommon.module.scss b/src/components/common/DrawerCommon/DrawerCommon.module.scss new file mode 100644 index 000000000..3253eac50 --- /dev/null +++ b/src/components/common/DrawerCommon/DrawerCommon.module.scss @@ -0,0 +1,52 @@ +@import "../../../styles/utilities"; + +.drawerCommon { + @apply fixed flex justify-end transition-all duration-200; + overflow: hidden; + top: 0; + right: 0; + height: 100vh; + width: 90%; + box-shadow: -3px 0 10px rgba(0, 0, 0, 0.15); + z-index: 20000; + + .inner { + @apply flex flex-col bg-white; + width: fit-content; + height: 100vh; + width: 100%; + margin-right: 0; + @screen md { + max-width: 55rem; + } + .top { + @apply flex justify-between items-center; + padding: 1.6rem; + .heading { + @apply sm-headline; + } + .iconClose { + @apply cursor-pointer transition-all duration-200; + &:hover { + svg path { + fill: var(--primary); + } + } + } + } + } + .content { + overflow-y: auto; + height: 100%; + } + &.hide { + transform: translateX(110%); + } + + @screen md { + width: unset; + .inner { + min-width: 48rem; + } + } +} diff --git a/src/components/common/DrawerCommon/DrawerCommon.tsx b/src/components/common/DrawerCommon/DrawerCommon.tsx new file mode 100644 index 000000000..deb1af3eb --- /dev/null +++ b/src/components/common/DrawerCommon/DrawerCommon.tsx @@ -0,0 +1,36 @@ +import React, { useRef } from 'react'; +import s from './DrawerCommon.module.scss'; +import classNames from 'classnames'; +import { IconClose } from 'src/components/icons'; + +interface Props { + visible: boolean + title?: string + children?: React.ReactNode + onClose: () => void +} + +const DrawerCommon = ({ title, visible, children, onClose }: Props) => { + return ( +
    +
    +
    +

    + {title} +

    +
    + +
    +
    +
    + {children} +
    +
    +
    + ) +} + +export default DrawerCommon; \ No newline at end of file diff --git a/src/components/common/Header/Header.tsx b/src/components/common/Header/Header.tsx index e9a06b9a8..a9926f765 100644 --- a/src/components/common/Header/Header.tsx +++ b/src/components/common/Header/Header.tsx @@ -1,6 +1,6 @@ import classNames from 'classnames' import React, { memo, useEffect, useState } from 'react' -import { useModalCommon } from 'src/components/hooks/useModalCommon' +import { useModalCommon } from 'src/components/hooks' import { isMobile } from 'src/utils/funtion.utils' import ModalAuthenticate from '../ModalAuthenticate/ModalAuthenticate' import ModalCreateUserInfo from '../ModalCreateUserInfo/ModalCreateUserInfo' diff --git a/src/components/common/Header/components/HeaderMenu/HeaderMenu.module.scss b/src/components/common/Header/components/HeaderMenu/HeaderMenu.module.scss index a61c059e6..2832211c1 100644 --- a/src/components/common/Header/components/HeaderMenu/HeaderMenu.module.scss +++ b/src/components/common/Header/components/HeaderMenu/HeaderMenu.module.scss @@ -52,7 +52,10 @@ } a { @appy no-underline; - &.iconFovourite { + &:hover { + opacity: .8; + } + &.iconFavourite { svg path { fill: var(--negative); } diff --git a/src/components/common/Header/components/HeaderMenu/HeaderMenu.tsx b/src/components/common/Header/components/HeaderMenu/HeaderMenu.tsx index 969964608..aa962605d 100644 --- a/src/components/common/Header/components/HeaderMenu/HeaderMenu.tsx +++ b/src/components/common/Header/components/HeaderMenu/HeaderMenu.tsx @@ -5,6 +5,7 @@ import InputSearch from 'src/components/common/InputSearch/InputSearch' import MenuDropdown from 'src/components/common/MenuDropdown/MenuDropdown' import { IconBuy, IconHeart, IconHistory, IconUser } from 'src/components/icons' import { ACCOUNT_TAB, QUERY_KEY, ROUTE } from 'src/utils/constanst.utils' +import Logo from '../../../Logo/Logo' import s from './HeaderMenu.module.scss' interface Props { @@ -39,7 +40,7 @@ const HeaderMenu = memo(({ isFull, openModalAuthen, openModalInfo }: Props) => {
    -
    Online Grocery
    + @@ -51,14 +52,14 @@ const HeaderMenu = memo(({ isFull, openModalAuthen, openModalInfo }: Props) => {
    • - +
    • - + diff --git a/src/components/common/ImgWithLink/ImgWithLink.module.scss b/src/components/common/ImgWithLink/ImgWithLink.module.scss new file mode 100644 index 000000000..413f96cdb --- /dev/null +++ b/src/components/common/ImgWithLink/ImgWithLink.module.scss @@ -0,0 +1,9 @@ +.imgWithLink { + position: relative; + min-width: 5rem; + width: 100%; + height: 100%; + img { + object-fit: cover; + } +} diff --git a/src/components/common/ImgWithLink/ImgWithLink.tsx b/src/components/common/ImgWithLink/ImgWithLink.tsx new file mode 100644 index 000000000..092322085 --- /dev/null +++ b/src/components/common/ImgWithLink/ImgWithLink.tsx @@ -0,0 +1,18 @@ +import React from 'react' +import s from './ImgWithLink.module.scss' +import Image from 'next/image' + +export interface ImgWithLinkProps { + src: string, + alt?: string, +} + +const ImgWithLink = ({ src, alt }: ImgWithLinkProps) => { + return ( +
      + {alt} +
      + ) +} + +export default ImgWithLink \ No newline at end of file diff --git a/src/components/common/Layout/Layout.tsx b/src/components/common/Layout/Layout.tsx index af7ab25c7..c510e4e14 100644 --- a/src/components/common/Layout/Layout.tsx +++ b/src/components/common/Layout/Layout.tsx @@ -1,6 +1,8 @@ import { CommerceProvider } from '@framework' import { useRouter } from 'next/router' import { FC } from 'react' +import { useModalCommon } from 'src/components/hooks' +import { CartDrawer } from '..' import Footer from '../Footer/Footer' import Header from '../Header/Header' import s from './Layout.module.scss' @@ -13,13 +15,25 @@ interface Props { // note: demo code const Layout: FC = ({ children }) => { const { locale = 'en-US' } = useRouter() + const { visible: visibleCartDrawer, openModal, closeModal: closeCartDrawer } = useModalCommon({ initialValue: false }) + const toggle = () => { + if (visibleCartDrawer) { + closeCartDrawer() + } else { + openModal() + } + } return (
      {/*
      */}
      {children}
      - {/*
      */} + + +
      diff --git a/src/components/common/ListProductWithInfo/InfoProducts/InfoProducts.module.scss b/src/components/common/ListProductWithInfo/InfoProducts/InfoProducts.module.scss new file mode 100644 index 000000000..c1cd9966e --- /dev/null +++ b/src/components/common/ListProductWithInfo/InfoProducts/InfoProducts.module.scss @@ -0,0 +1,23 @@ +@import "../../../../styles/utilities"; + +.infoProducts { + @apply flex justify-between items-center spacing-horizontal; + + .top { + .sub { + display: none; + } + } + @screen lg { + @apply block; + margin-right: 4rem; + padding: 0; + .top { + margin-bottom: 3.2rem; + .sub { + display: block; + margin-top: 0.4rem; + } + } + } +} diff --git a/src/components/common/ListProductWithInfo/InfoProducts/InfoProducts.tsx b/src/components/common/ListProductWithInfo/InfoProducts/InfoProducts.tsx new file mode 100644 index 000000000..25e18252c --- /dev/null +++ b/src/components/common/ListProductWithInfo/InfoProducts/InfoProducts.tsx @@ -0,0 +1,26 @@ +import React from 'react'; +import { ROUTE } from 'src/utils/constanst.utils'; +import HeadingCommon from '../../HeadingCommon/HeadingCommon'; +import ViewAllItem from '../../ViewAllItem/ViewAllItem'; +import s from './InfoProducts.module.scss' +interface Props { + title: string, + subtitle?: string, +} + +const InfoProducts = ({ title, subtitle }: Props) => { + return ( +
      +
      + {title} +
      + {subtitle} +
      +
      + + +
      + ); +}; + +export default InfoProducts; \ No newline at end of file diff --git a/src/components/common/ListProductWithInfo/ListProductWithInfo.module.scss b/src/components/common/ListProductWithInfo/ListProductWithInfo.module.scss new file mode 100644 index 000000000..ddd8ed901 --- /dev/null +++ b/src/components/common/ListProductWithInfo/ListProductWithInfo.module.scss @@ -0,0 +1,48 @@ +@import "../../../styles/utilities"; + +.listProductWithInfo { + background-color: var(--background); + border-top: 1rem solid var(--gray); + border-bottom: 1rem solid var(--gray); + padding-top: 6rem; + padding-bottom: 6rem; + @screen lg { + @apply flex spacing-horizontal-left; + padding-top: 5.6rem; + padding-bottom: 5.6rem; + border: none; + background-color: var(--background-gray); + } + .productsWrap { + @apply spacing-horizontal-left; + @screen lg { + max-width: 75%; + @apply custom-border-radius-lg bg-white; + padding: 4rem .8rem; + :global(.customArrow) { + @screen lg { + &:global(.leftArrow) { + left: calc(-6.4rem + 3rem); + } + &:global(.rightArrow) { + right: calc(-6.4rem + 3rem); + } + } + } + } + @screen xl { + padding: 4rem 2.4rem; + max-width: 80%; + :global(.customArrow) { + @screen lg { + &:global(.leftArrow) { + left: calc(-6.4rem + 1rem); + } + &:global(.rightArrow) { + right: calc(-6.4rem + 1rem); + } + } + } + } + } +} diff --git a/src/components/common/ListProductWithInfo/ListProductWithInfo.tsx b/src/components/common/ListProductWithInfo/ListProductWithInfo.tsx new file mode 100644 index 000000000..66b8253d1 --- /dev/null +++ b/src/components/common/ListProductWithInfo/ListProductWithInfo.tsx @@ -0,0 +1,51 @@ +import { TOptionsEvents } from 'keen-slider'; +import React from 'react'; +import CarouselCommon from '../CarouselCommon/CarouselCommon'; +import ProductCard, { ProductCardProps } from '../ProductCard/ProductCard'; +import InfoProducts from './InfoProducts/InfoProducts'; +import s from './ListProductWithInfo.module.scss'; + +interface Props { + data: ProductCardProps[], + title: string, + subtitle?: string, +} +const OPTION_DEFAULT: TOptionsEvents = { + slidesPerView: 2, + mode: 'free', + breakpoints: { + '(min-width: 640px)': { + slidesPerView: 3, + }, + '(min-width: 768px)': { + slidesPerView: 4, + }, + '(min-width: 1024px)': { + slidesPerView: 3, + }, + '(min-width: 1280px)': { + slidesPerView: 4.5, + }, + }, +} + +const ListProductWithInfo = ({ data, title, subtitle }: Props) => { + return ( +
      + +
      + + data={data} + Component={ProductCard} + itemKey={title} + option={OPTION_DEFAULT} + /> +
      +
      + ); +}; + +export default ListProductWithInfo; \ No newline at end of file diff --git a/src/components/common/Logo/Logo.module.scss b/src/components/common/Logo/Logo.module.scss index 2660c4880..da6bfc49f 100644 --- a/src/components/common/Logo/Logo.module.scss +++ b/src/components/common/Logo/Logo.module.scss @@ -1,7 +1,7 @@ -@import '../../../styles/utilities'; +@import "../../../styles/utilities"; .logo { - display: flex; + @apply flex justify-center items-center; .eclipse { width: 3.2rem; height: 3.2rem; @@ -10,9 +10,9 @@ margin-right: 1.2rem; } .content { - @apply font-logo; + @apply font-logo font-bold; font-size: 16px; line-height: 32px; letter-spacing: -0.02em; } -} \ No newline at end of file +} diff --git a/src/components/common/Logo/Logo.tsx b/src/components/common/Logo/Logo.tsx index 96d1820e0..58a0ea5de 100644 --- a/src/components/common/Logo/Logo.tsx +++ b/src/components/common/Logo/Logo.tsx @@ -1,14 +1,18 @@ import s from './Logo.module.scss' +import Link from 'next/link' +import { ROUTE } from 'src/utils/constanst.utils' const Logo = () => { - return( -
      -
      -
      -
      - ONLINE GROCERY -
      -
      + return ( + + +
      +
      +
      + ONLINE GROCERY +
      +
      + ) } diff --git a/src/components/common/MenuDropdown/MenuDropdown.module.scss b/src/components/common/MenuDropdown/MenuDropdown.module.scss index 8fc270b2a..ae5b76c3d 100644 --- a/src/components/common/MenuDropdown/MenuDropdown.module.scss +++ b/src/components/common/MenuDropdown/MenuDropdown.module.scss @@ -3,6 +3,9 @@ .menuDropdown { @apply relative cursor-pointer; width: fit-content; + .label { + all: unset; + } &:hover { .label { color: var(--primary); @@ -65,6 +68,16 @@ margin-top: 0.4rem; li { @apply block w-full transition-all duration-200 cursor-pointer text-active; + word-wrap: break-word; + -webkit-hyphens: auto; + -ms-hyphens: auto; + -moz-hyphens: auto; + hyphens: auto; + overflow-x: hidden; + position: relative; + max-width: 15rem; + white-space: nowrap; + text-overflow: ellipsis; button { all: unset; color: currentColor; diff --git a/src/components/common/MenuDropdown/MenuDropdown.tsx b/src/components/common/MenuDropdown/MenuDropdown.tsx index bd3f0c851..ca25f22f8 100644 --- a/src/components/common/MenuDropdown/MenuDropdown.tsx +++ b/src/components/common/MenuDropdown/MenuDropdown.tsx @@ -16,9 +16,9 @@ const MenuDropdown = ({ options, children, isHasArrow = true, align }: Props) => [s.menuDropdown]: true, [s.arrow]: isHasArrow, })}> - +
      { + if (isNotSell) { + return
      + +
      + + } + return (
      diff --git a/src/components/common/ProductCard/ProductNotSell/ProductNotSell.module.scss b/src/components/common/ProductCard/ProductNotSell/ProductNotSell.module.scss new file mode 100644 index 000000000..4945220a9 --- /dev/null +++ b/src/components/common/ProductCard/ProductNotSell/ProductNotSell.module.scss @@ -0,0 +1,27 @@ +@import "../../../../styles/utilities"; + +.imgWrap { + img { + opacity: 0.5; + } +} + +.name { + @apply text-label cursor-default font-bold; +} + +.info { + @apply flex justify-center items-center custom-border-radius bg-info-light text-center; + padding: .8rem 1.6rem; + margin-top: 1.6rem; + color: var(--info); + svg { + @apply u-icon; + path { + fill: currentColor; + } + } + .text { + margin-left: 0.8rem; + } +} diff --git a/src/components/common/ProductCard/ProductNotSell/ProductNotSell.tsx b/src/components/common/ProductCard/ProductNotSell/ProductNotSell.tsx new file mode 100644 index 000000000..f87d87c43 --- /dev/null +++ b/src/components/common/ProductCard/ProductNotSell/ProductNotSell.tsx @@ -0,0 +1,28 @@ +import React from 'react'; +import { IconInfo } from 'src/components/icons'; +import ImgWithLink from '../../ImgWithLink/ImgWithLink'; +import s from './ProductNotSell.module.scss'; + +export interface Props { + name: string, + imageSrc: string, +} + +const ProductNotSell = ({ name, imageSrc }: Props) => { + return ( + <> +
      + +
      +
      {name}
      +
      + +
      + Not Sell +
      +
      + + ); +}; + +export default ProductNotSell; \ No newline at end of file diff --git a/src/components/common/QuanittyInput/QuanittyInput.tsx b/src/components/common/QuanittyInput/QuanittyInput.tsx index a01f16fe7..20baba9ea 100644 --- a/src/components/common/QuanittyInput/QuanittyInput.tsx +++ b/src/components/common/QuanittyInput/QuanittyInput.tsx @@ -1,7 +1,7 @@ import React, { ChangeEvent, useEffect, useState } from 'react' import s from './QuanittyInput.module.scss' import classNames from 'classnames' -import { Minus, Plus } from '@components/icons' +import { IconMinus, IconPlus } from '../../icons' interface QuanittyInputProps extends Omit< React.InputHTMLAttributes, @@ -64,7 +64,7 @@ const QuanittyInput = ({ return (
      - +
      - +
      ) diff --git a/src/components/common/RecipeCard/RecipeCard.module.scss b/src/components/common/RecipeCard/RecipeCard.module.scss index 1fd6fd65e..19f3eb76a 100644 --- a/src/components/common/RecipeCard/RecipeCard.module.scss +++ b/src/components/common/RecipeCard/RecipeCard.module.scss @@ -6,6 +6,9 @@ width: 100%; max-height: 22rem; border-radius: 2.4rem; + img { + border-radius: 2.4rem; + } &:hover{ cursor: pointer; } diff --git a/components/ui/Rating/Rating.module.css b/src/components/common/RecipeDetail/RecipeDetail.module.scss similarity index 100% rename from components/ui/Rating/Rating.module.css rename to src/components/common/RecipeDetail/RecipeDetail.module.scss diff --git a/src/components/common/RecipeDetail/RecipeDetail.tsx b/src/components/common/RecipeDetail/RecipeDetail.tsx new file mode 100644 index 000000000..cdec99994 --- /dev/null +++ b/src/components/common/RecipeDetail/RecipeDetail.tsx @@ -0,0 +1,23 @@ +import React from 'react' +import { ProductCardProps } from '../ProductCard/ProductCard' +import RecipeDetailInfo from './components/RecipeDetailInfo/RecipeDetailInfo' +import RecipeIngredient from './components/RecipeIngredient/RecipeIngredient' +import s from './RecipeDetail.module.scss' + + +interface Props { + className?: string + children?: any, + ingredients: ProductCardProps[], +} + +const RecipeDetail = ({ ingredients }: Props) => { + return ( +
      + + +
      + ) +} + +export default RecipeDetail diff --git a/src/components/common/RecipeDetail/components/RecipeBriefInfo/RecipeBriefInfo.module.scss b/src/components/common/RecipeDetail/components/RecipeBriefInfo/RecipeBriefInfo.module.scss new file mode 100644 index 000000000..56f1e6500 --- /dev/null +++ b/src/components/common/RecipeDetail/components/RecipeBriefInfo/RecipeBriefInfo.module.scss @@ -0,0 +1,19 @@ +.recipeBriefInfo { + @apply flex; + .item { + @apply flex; + &:not(:last-child) { + margin-right: 2.4rem; + } + svg { + width: 2rem; + height: 2rem; + path { + fill: var(--text-label); + } + } + .content { + margin-left: 0.8rem; + } + } +} diff --git a/src/components/common/RecipeDetail/components/RecipeBriefInfo/RecipeBriefInfo.tsx b/src/components/common/RecipeDetail/components/RecipeBriefInfo/RecipeBriefInfo.tsx new file mode 100644 index 000000000..d06387914 --- /dev/null +++ b/src/components/common/RecipeDetail/components/RecipeBriefInfo/RecipeBriefInfo.tsx @@ -0,0 +1,29 @@ +import React from 'react' +import { IconLocation, IconPeople, IconTime } from 'src/components/icons' +import s from './RecipeBriefInfo.module.scss' + +interface Props { + className?: string + children?: any, +} + +const RecipeBriefInfo = ({ }: Props) => { + return ( +
      +
      + +
      15 minutes
      +
      +
      + +
      4 People
      +
      +
      + +
      15 minutes
      +
      +
      + ) +} + +export default RecipeBriefInfo diff --git a/src/components/common/RecipeDetail/components/RecipeDetailInfo/RecipeDetailInfo.module.scss b/src/components/common/RecipeDetail/components/RecipeDetailInfo/RecipeDetailInfo.module.scss new file mode 100644 index 000000000..86b525083 --- /dev/null +++ b/src/components/common/RecipeDetail/components/RecipeDetailInfo/RecipeDetailInfo.module.scss @@ -0,0 +1,61 @@ +@import "../../../../../styles/utilities"; + +.recipeDetailInfo { + @apply spacing-horizontal; + margin: 5.6rem auto; + @screen md { + @apply flex; + } + .img { + width: fit-content; + margin-top: 0; + + @screen sm-only { + margin-bottom: 2rem; + } + @screen lg { + max-width: 60rem; + } + img { + @apply w-full; + object-fit: contain; + max-height: 64rem; + border-radius: 2.4rem; + @screen md { + max-height: 90rem; + } + } + } + + .recipeInfo { + @screen md { + max-width: 39rem; + margin-left: 4.8rem; + } + @screen lg { + margin-left: 11.2rem; + } + .top { + margin-bottom: 4.8rem; + .name { + @apply heading-1 font-heading; + margin-bottom: 1.6rem; + } + } + .detail { + .item { + &:not(:last-child) { + margin-bottom: 2.4rem; + } + .heading { + @apply heading-3 font-heading; + margin-bottom: 0.8rem; + } + .content { + list-style: disc; + margin-left: 2rem; + } + } + } + } +} diff --git a/src/components/common/RecipeDetail/components/RecipeDetailInfo/RecipeDetailInfo.tsx b/src/components/common/RecipeDetail/components/RecipeDetailInfo/RecipeDetailInfo.tsx new file mode 100644 index 000000000..4d212e10a --- /dev/null +++ b/src/components/common/RecipeDetail/components/RecipeDetailInfo/RecipeDetailInfo.tsx @@ -0,0 +1,59 @@ +import React from 'react' +import RecipeBriefInfo from '../RecipeBriefInfo/RecipeBriefInfo' +import s from './RecipeDetailInfo.module.scss' + + +interface Props { + className?: string + children?: any +} + +const RecipeDetailInfo = ({ }: Props) => { + return ( +
      +
      + Recipe +
      +
      +
      +

      + Crispy Fried Calamari +

      + +
      +
      +
      +

      Ingredients

      +
        +
      • Canola oil for frying
      • +
      • 1 pound clean squid bodies cut in 1/4 inch rings and dried with a paper towel
      • +
      • 2 cups flour
      • +
      • 1/2 teaspoon kosher salt
      • +
      • 1/2 teaspoon garlic powder
      • +
      • 1/8 teaspoon coarse ground black pepper
      • +
      • 1 lemon cut into wedges
      • +
      +
      + +
      +

      Preparation

      +
        +
      • 1In a large pot or dutch oven add three inches of oil and bring to 350 degrees.
      • +
      • Add the flour, salt, garlic powder and pepper to a large bowl and stir to combine.
      • +
      • Toss the squid pieces in the flour then into the hot oil.
      • +
      • Fry the squid for 1-2 minutes. You want the color to stay pale like in the pictures.
      • +
      • Remove to a cookie sheet to drain (do not add paper towels as it will steam the calamari and make it soft.)
      • +
      • Serve with lemon wedges.
      • +
      +
      + +
      +
      +
      + ) +} + +export default RecipeDetailInfo diff --git a/src/components/common/RecipeDetail/components/RecipeIngredient/RecipeIngredient.module.scss b/src/components/common/RecipeDetail/components/RecipeIngredient/RecipeIngredient.module.scss new file mode 100644 index 000000000..b1419699d --- /dev/null +++ b/src/components/common/RecipeDetail/components/RecipeIngredient/RecipeIngredient.module.scss @@ -0,0 +1,21 @@ +@import "../../../../../styles/utilities"; + +.recipeIngredient { + padding: 6rem 0; + @screen md { + padding: 5.6rem 0; + } + .top { + @apply flex justify-between items-center spacing-horizontal; + } + .bottom { + @apply flex justify-center items-center spacing-horizontal; + margin-top: 4rem; + button { + width: 100%; + @screen md { + width: 39rem; + } + } + } +} diff --git a/src/components/common/RecipeDetail/components/RecipeIngredient/RecipeIngredient.tsx b/src/components/common/RecipeDetail/components/RecipeIngredient/RecipeIngredient.tsx new file mode 100644 index 000000000..a879f0b72 --- /dev/null +++ b/src/components/common/RecipeDetail/components/RecipeIngredient/RecipeIngredient.tsx @@ -0,0 +1,33 @@ +import React from 'react' +import ButtonCommon from 'src/components/common/ButtonCommon/ButtonCommon' +import HeadingCommon from 'src/components/common/HeadingCommon/HeadingCommon' +import { ProductCardProps } from 'src/components/common/ProductCard/ProductCard' +import ProductCarousel from 'src/components/common/ProductCarousel/ProductCarousel' +import ViewAllItem from 'src/components/common/ViewAllItem/ViewAllItem' +import { ROUTE } from 'src/utils/constanst.utils' +import s from './RecipeIngredient.module.scss' + +interface Props { + className?: string + children?: any, + data: ProductCardProps[], +} + +const RecipeIngredient = ({ data }: Props) => { + return ( +
      +
      + Ingredients +
      + +
      +
      + +
      + Buy all +
      +
      + ) +} + +export default RecipeIngredient diff --git a/src/components/common/ScrollToTop/ScrollTarget.tsx b/src/components/common/ScrollToTop/ScrollTarget.tsx deleted file mode 100644 index 50a839c83..000000000 --- a/src/components/common/ScrollToTop/ScrollTarget.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React, { MutableRefObject } from 'react' - -interface ScrollTargetProps { - refScrollUp: MutableRefObject; -} - -const ScrollTarget = ({ refScrollUp } : ScrollTargetProps) => { - - return ( -
      - ) - -} - -export default ScrollTarget diff --git a/src/components/common/ScrollToTop/ScrollToTop.tsx b/src/components/common/ScrollToTop/ScrollToTop.tsx index 98e16168d..d148c8937 100644 --- a/src/components/common/ScrollToTop/ScrollToTop.tsx +++ b/src/components/common/ScrollToTop/ScrollToTop.tsx @@ -5,11 +5,10 @@ import s from './ScrollToTop.module.scss' import ArrowUp from '../../icons/IconArrowUp' interface ScrollToTopProps { - target: MutableRefObject; visibilityHeight?: number; } -const ScrollToTop = ({ target, visibilityHeight=450 }: ScrollToTopProps) => { +const ScrollToTop = ({ visibilityHeight=450 }: ScrollToTopProps) => { const [scrollPosition, setSrollPosition] = useState(0); const [showScrollToTop, setShowScrollToTop] = useState("hide"); @@ -26,7 +25,7 @@ const ScrollToTop = ({ target, visibilityHeight=450 }: ScrollToTopProps) => { }; function handleScrollUp() { - target.current.scrollIntoView({ behavior: "smooth" }); + window.scrollTo(0, 0); } function addEventScroll() { @@ -34,7 +33,7 @@ const ScrollToTop = ({ target, visibilityHeight=450 }: ScrollToTopProps) => { } useEffect(() => { - addEventScroll() + addEventScroll(); }); return ( diff --git a/src/components/common/ShippingInfoForm/ShippingInfoForm.tsx b/src/components/common/ShippingInfoForm/ShippingInfoForm.tsx index d8c858399..ac4bc8af5 100644 --- a/src/components/common/ShippingInfoForm/ShippingInfoForm.tsx +++ b/src/components/common/ShippingInfoForm/ShippingInfoForm.tsx @@ -4,8 +4,12 @@ import s from './ShippingInfoForm.module.scss' import Link from 'next/link' import { CustomInputCommon } from 'src/utils/type.utils' import { Shipping } from 'src/components/icons' +import { CheckOutForm } from 'src/utils/types.utils' -interface ShippingInfoFormProps {} +interface ShippingInfoFormProps { + onConfirm?: (id:number,formInfo:CheckOutForm)=>void + id:number +} const option = [ { @@ -16,20 +20,20 @@ const option = [ }, ] -const ShippingInfoForm = ({}: ShippingInfoFormProps) => { +const ShippingInfoForm = ({onConfirm,id}: ShippingInfoFormProps) => { const addressRef = useRef(null) const cityRef = useRef(null) const stateRef = useRef(null) const codeRef = useRef(null) const phoneRef = useRef(null) const handleConfirmClick = () => { - return { - address: addressRef?.current?.getValue(), - city: cityRef.current?.getValue(), - state: stateRef?.current?.getValue(), - code: codeRef.current?.getValue(), - phone: phoneRef?.current?.getValue(), - } + onConfirm && onConfirm(id,{ + address: addressRef?.current?.getValue().toString(), + city: cityRef.current?.getValue().toString(), + state: stateRef?.current?.getValue().toString(), + code: Number(codeRef.current?.getValue()), + phone: Number(phoneRef?.current?.getValue()), + }) } return ( diff --git a/src/components/common/ViewAllItem/ViewAllItem.module.scss b/src/components/common/ViewAllItem/ViewAllItem.module.scss index 4b8b6fe6d..b4ec26872 100644 --- a/src/components/common/ViewAllItem/ViewAllItem.module.scss +++ b/src/components/common/ViewAllItem/ViewAllItem.module.scss @@ -4,7 +4,7 @@ display: flex; .content { color: var(--primary); - margin: 0.8rem 0.8rem 0.8rem 1.6rem; + margin: 0.8rem 0.8rem 0.8rem 0; font-weight: bold; } .vector { diff --git a/src/components/common/index.ts b/src/components/common/index.ts index fb4f8daf5..8d5a44b73 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -19,7 +19,6 @@ export { default as DateTime} from './DateTime/DateTime' export { default as HeadingCommon } from './HeadingCommon/HeadingCommon' export { default as CollectionHeading } from './CollectionHeading/CollectionHeading' export { default as ScrollToTop } from './ScrollToTop/ScrollToTop' -export { default as ScrollTarget } from './ScrollToTop/ScrollTarget' export { default as InputSearch} from './InputSearch/InputSearch' export { default as ButtonIconBuy} from './ButtonIconBuy/ButtonIconBuy' export { default as Banner} from './Banner/Banner' @@ -41,3 +40,7 @@ export { default as CheckoutBill} from './CheckoutBill/CheckoutBill' export { default as CustomerInfoForm} from './CustomerInfoForm/CustomerInfoForm' export { default as ShippingInfoForm} from './ShippingInfoForm/ShippingInfoForm' export { default as PaymentInfoForm} from './PaymentInfoForm/PaymentInfoForm' +export { default as ImgWithLink} from './ImgWithLink/ImgWithLink' +export { default as RecipeDetail} from './RecipeDetail/RecipeDetail' +export { default as DrawerCommon} from './DrawerCommon/DrawerCommon' +export { default as CartDrawer} from './CartDrawer/CartDrawer' diff --git a/src/components/hooks/index.ts b/src/components/hooks/index.ts new file mode 100644 index 000000000..cf83feb42 --- /dev/null +++ b/src/components/hooks/index.ts @@ -0,0 +1 @@ +export { default as useModalCommon } from './useModalCommon' diff --git a/src/components/hooks/useModalCommon.tsx b/src/components/hooks/useModalCommon.tsx index 02626ce94..41aed648f 100644 --- a/src/components/hooks/useModalCommon.tsx +++ b/src/components/hooks/useModalCommon.tsx @@ -4,7 +4,7 @@ interface Props { initialValue?: boolean, } -export const useModalCommon = ({ initialValue = false }: Props) => { +const useModalCommon = ({ initialValue = false }: Props) => { const [visible, setVisible] = useState(initialValue) const openModal = (e?: any) => { @@ -21,3 +21,5 @@ export const useModalCommon = ({ initialValue = false }: Props) => { visible, openModal, closeModal } }; + +export default useModalCommon \ No newline at end of file diff --git a/src/components/icons/IconCirclePlus.tsx b/src/components/icons/IconCirclePlus.tsx new file mode 100644 index 000000000..c59766d89 --- /dev/null +++ b/src/components/icons/IconCirclePlus.tsx @@ -0,0 +1,20 @@ +import React from 'react' + +const IconCirclePlus = () => { + return ( + + + + ) +} + +export default IconCirclePlus diff --git a/src/components/icons/IconClose.tsx b/src/components/icons/IconClose.tsx new file mode 100644 index 000000000..018ee8cd6 --- /dev/null +++ b/src/components/icons/IconClose.tsx @@ -0,0 +1,20 @@ +import React from 'react' + +const IconClose = () => { + return ( + + + + ) +} + +export default IconClose diff --git a/src/components/icons/IconDelete.tsx b/src/components/icons/IconDelete.tsx new file mode 100644 index 000000000..4daff3f80 --- /dev/null +++ b/src/components/icons/IconDelete.tsx @@ -0,0 +1,11 @@ +import React from 'react' + +const IconDelete = () => { + return ( + + + + ) +} + +export default IconDelete diff --git a/src/components/icons/IconLocation.tsx b/src/components/icons/IconLocation.tsx new file mode 100644 index 000000000..3dc0a81b9 --- /dev/null +++ b/src/components/icons/IconLocation.tsx @@ -0,0 +1,11 @@ +import React from 'react' + +const IconLocation = () => { + return ( + + + + ) +} + +export default IconLocation diff --git a/src/components/icons/IconMinus.tsx b/src/components/icons/IconMinus.tsx index ba4eb2fc0..abf3a2907 100644 --- a/src/components/icons/IconMinus.tsx +++ b/src/components/icons/IconMinus.tsx @@ -1,14 +1,14 @@ const IconMinus = ({ ...props }) => { return ( diff --git a/src/components/icons/IconPeople.tsx b/src/components/icons/IconPeople.tsx new file mode 100644 index 000000000..0075b0f75 --- /dev/null +++ b/src/components/icons/IconPeople.tsx @@ -0,0 +1,11 @@ +import React from 'react' + +const IconPeople = () => { + return ( + + + + ) +} + +export default IconPeople diff --git a/src/components/icons/IconPlus.tsx b/src/components/icons/IconPlus.tsx index a532c6244..63d6d2dd4 100644 --- a/src/components/icons/IconPlus.tsx +++ b/src/components/icons/IconPlus.tsx @@ -1,14 +1,14 @@ const IconPlus = ({ ...props }) => { return ( diff --git a/src/components/icons/IconTime.tsx b/src/components/icons/IconTime.tsx new file mode 100644 index 000000000..81064df9d --- /dev/null +++ b/src/components/icons/IconTime.tsx @@ -0,0 +1,11 @@ +import React from 'react' + +const IconTime = () => { + return ( + + + + ) +} + +export default IconTime diff --git a/src/components/icons/index.ts b/src/components/icons/index.ts index 8bdbb1740..7dfe3657c 100644 --- a/src/components/icons/index.ts +++ b/src/components/icons/index.ts @@ -22,6 +22,12 @@ export { default as IconPassword } from './IconPassword' export { default as IconPasswordCross } from './IconPasswordCross' export { default as IconError } from './IconError' export { default as IconCheck } from './IconCheck' +export { default as Shipping} from './Shipping' +export { default as IconTime } from './IconTime' +export { default as IconPeople } from './IconPeople' +export { default as IconLocation } from './IconLocation' +export { default as IconClose } from './IconClose' +export { default as IconDelete } from './IconDelete' export { default as IconPlus } from './IconPlus' export { default as IconMinus } from './IconMinus' -export { default as Shipping} from './Shipping' \ No newline at end of file +export { default as IconCirclePlus } from './IconCirclePlus' diff --git a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss new file mode 100644 index 000000000..3ca7d7101 --- /dev/null +++ b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss @@ -0,0 +1,7 @@ +.warpper{ + @apply w-full; + .title{ + padding: 3.2rem 0; + @apply flex justify-start items-center + } +} \ No newline at end of file diff --git a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx new file mode 100644 index 000000000..3b4c64838 --- /dev/null +++ b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx @@ -0,0 +1,87 @@ +import React, { useState } from 'react' +import { CustomerInfoForm, Logo, ShippingInfoForm } from 'src/components/common' +import CheckoutCollapse from 'src/components/common/CheckoutCollapse/CheckoutCollapse' +import { CheckOutForm } from 'src/utils/types.utils' +import s from './CheckoutInfo.module.scss' +interface CheckoutInfoProps {} + +const CheckoutInfo = ({}: CheckoutInfoProps) => { + const [active, setActive] = useState(1) + const [done, setDone] = useState([]) + const [info, setInfo] = useState({}) + const onOpen = (id:number) => { + setActive(id) + } + + const onEdit = (id:number) => { + setActive(id) + } + + const onClose = (id:number) => { + setActive(id) + } + + const onConfirm = (id:number,formInfo:CheckOutForm) => { + if(id+1>formList.length){ + console.log({...info,...formInfo}) + }else{ + + setActive(id+1) + } + setDone([...done,id]) + setInfo({...info,...formInfo}) + } + const formList = [ + { + id: 1, + title: 'Customer Information', + form: , + }, + { + id: 2, + title: 'Shipping Information', + form: , + }, + ] + return ( +
      +
      + +
      + {formList.map((item) => { + return + {item.form} + + })} + {/* + + + + + */} +
      + ) +} + +export default CheckoutInfo diff --git a/src/components/modules/checkout/index.ts b/src/components/modules/checkout/index.ts index e69de29bb..24a765b23 100644 --- a/src/components/modules/checkout/index.ts +++ b/src/components/modules/checkout/index.ts @@ -0,0 +1 @@ +export { default as CheckoutInfo } from './CheckoutInfo/CheckoutInfo' diff --git a/src/components/modules/product-detail/ProductInfoDetail/ProductInfoDetail.module.scss b/src/components/modules/product-detail/ProductInfoDetail/ProductInfoDetail.module.scss new file mode 100644 index 000000000..645ff7259 --- /dev/null +++ b/src/components/modules/product-detail/ProductInfoDetail/ProductInfoDetail.module.scss @@ -0,0 +1,10 @@ +@import '../../../../styles/utilities'; + +.productInfoDetail { + @apply spacing-horizontal; + padding-bottom: 4rem; + @screen md { + @apply flex; + padding-bottom: 5.6rem; + } +} \ No newline at end of file diff --git a/src/components/modules/product-detail/ProductInfoDetail/ProductInfoDetail.tsx b/src/components/modules/product-detail/ProductInfoDetail/ProductInfoDetail.tsx new file mode 100644 index 000000000..d1047bd3a --- /dev/null +++ b/src/components/modules/product-detail/ProductInfoDetail/ProductInfoDetail.tsx @@ -0,0 +1,20 @@ +import React from 'react' +import ProductImgs from './components/ProductImgs/ProductImgs' +import ProductInfo from './components/ProductInfo/ProductInfo' +import s from './ProductInfoDetail.module.scss' + +interface Props { + className?: string + children?: any +} + +const ProductInfoDetail = ({ }: Props) => { + return ( +
      + + +
      + ) +} + +export default ProductInfoDetail diff --git a/src/components/modules/product-detail/ProductInfoDetail/components/ProductImgs/ProductImgs.module.scss b/src/components/modules/product-detail/ProductInfoDetail/components/ProductImgs/ProductImgs.module.scss new file mode 100644 index 000000000..a10eb5865 --- /dev/null +++ b/src/components/modules/product-detail/ProductInfoDetail/components/ProductImgs/ProductImgs.module.scss @@ -0,0 +1,9 @@ +.productImgs { + @apply w-full flex justify-between items-center; + @screen sm-only { + margin-bottom: 2rem; + } + @screen lg { + max-width: 60rem; + } +} diff --git a/src/components/modules/product-detail/ProductInfoDetail/components/ProductImgs/ProductImgs.tsx b/src/components/modules/product-detail/ProductInfoDetail/components/ProductImgs/ProductImgs.tsx new file mode 100644 index 000000000..325c6b453 --- /dev/null +++ b/src/components/modules/product-detail/ProductInfoDetail/components/ProductImgs/ProductImgs.tsx @@ -0,0 +1,40 @@ +import React from 'react' +import { CarouselCommon, ImgWithLink } from 'src/components/common' +import { ImgWithLinkProps } from 'src/components/common/ImgWithLink/ImgWithLink' +import s from './ProductImgs.module.scss' + +interface Props { + className?: string + children?: any, +} + +const DATA = [ + { + src: 'https://user-images.githubusercontent.com/76729908/130574371-3b75fa72-9552-4605-aba9-a4b31cd9dce7.png', + alt: 'Broccoli', + }, + { + src: 'https://user-images.githubusercontent.com/76729908/130574371-3b75fa72-9552-4605-aba9-a4b31cd9dce7.png', + alt: 'Broccoli', + } +] + +const option = { + slidesPerView: 1, +} + +const ProductImgs = ({ }: Props) => { + return ( +
      + + data={DATA} + itemKey="product-detail-img" + Component={ImgWithLink} + option={option} + isDot={true} + /> +
      + ) +} + +export default ProductImgs diff --git a/src/components/modules/product-detail/ProductInfoDetail/components/ProductInfo/ProductInfo.module.scss b/src/components/modules/product-detail/ProductInfoDetail/components/ProductInfo/ProductInfo.module.scss new file mode 100644 index 000000000..403782c51 --- /dev/null +++ b/src/components/modules/product-detail/ProductInfoDetail/components/ProductInfo/ProductInfo.module.scss @@ -0,0 +1,81 @@ +@import "../../../../../../styles/utilities"; + +.productInfo { + @screen md { + max-width: 39rem; + margin-left: 4.8rem; + } + @screen lg { + margin-left: 11.2rem; + } + .info { + margin-bottom: 3.2rem; + .heading { + @apply heading-2 font-heading; + margin-top: 0.8rem; + } + .price { + margin-top: 0.8rem; + .old { + margin-bottom: 0.8rem; + .number { + margin-right: 0.8rem; + color: var(--text-label); + text-decoration: line-through; + } + } + .current { + @apply text-active font-bold sm-headline; + } + } + .description { + margin-top: 0.8rem; + } + } + .actions { + @screen sm-only { + @apply fixed flex justify-between items-center bg-white w-full; + z-index: 10000; + bottom: 0; + left: 0; + padding: 2rem; + } + } + .bottom { + @screen sm-only { + @apply flex justify-between items-center flex-row-reverse; + margin-left: 1rem; + flex: 1; + button { + &:first-child { + min-width: 13rem; + } + &:nth-child(n + 1) { + margin-left: 0.8rem; + } + } + } + .buttonWithIcon { + @apply flex items-center; + .label { + @apply hidden; + @screen md { + @apply inline-block; + margin-left: 0.8rem; + } + } + } + button { + @apply w-full; + } + + @screen md { + margin-top: 2.4rem; + button { + &:first-child { + margin-bottom: 0.8rem; + } + } + } + } +} diff --git a/src/components/modules/product-detail/ProductInfoDetail/components/ProductInfo/ProductInfo.tsx b/src/components/modules/product-detail/ProductInfoDetail/components/ProductInfo/ProductInfo.tsx new file mode 100644 index 000000000..4abb62568 --- /dev/null +++ b/src/components/modules/product-detail/ProductInfoDetail/components/ProductInfo/ProductInfo.tsx @@ -0,0 +1,46 @@ +import React from 'react' +import { ButtonCommon, LabelCommon, QuanittyInput } from 'src/components/common' +import { IconBuy } from 'src/components/icons' +import { LANGUAGE } from 'src/utils/language.utils' +import s from './ProductInfo.module.scss' + +interface Props { + className?: string + children?: any, +} + +const ProductInfo = ({ }: Props) => { + return ( +
      +
      + SEAFOOD +

      SeaPAk

      +
      +
      + Rp 32.000 + -15% +
      +
      Rp 27.500
      +
      +
      + In a large non-reactive dish, mix together the orange juice, soy sauce, olive oil, lemon juice, parsley +
      +
      +
      + +
      + {/* {LANGUAGE.BUTTON_LABEL.PREORDER} */} + {LANGUAGE.BUTTON_LABEL.BUY_NOW} + + + + {LANGUAGE.BUTTON_LABEL.ADD_TO_CARD} + + +
      +
      +
      + ) +} + +export default ProductInfo diff --git a/src/components/modules/product-detail/RecommendedRecipes/RecommendedRecipes.module.scss b/src/components/modules/product-detail/RecommendedRecipes/RecommendedRecipes.module.scss new file mode 100644 index 000000000..d43e2d58c --- /dev/null +++ b/src/components/modules/product-detail/RecommendedRecipes/RecommendedRecipes.module.scss @@ -0,0 +1,27 @@ +@import "../../../../styles/utilities"; + +.recommendedRecipes { + margin: 6rem auto; + @screen md { + margin: 5.6rem auto; + } + .infoProducts { + @apply flex justify-between items-center spacing-horizontal; + margin-bottom: 3.2rem; + } + .productsWrap { + @apply spacing-horizontal-left; + @screen xl { + :global(.customArrow) { + @screen lg { + &:global(.leftArrow) { + left: calc(-6.4rem - 2rem); + } + &:global(.rightArrow) { + right: calc(-6.4rem - 2rem); + } + } + } + } + } +} diff --git a/src/components/modules/product-detail/RecommendedRecipes/RecommendedRecipes.tsx b/src/components/modules/product-detail/RecommendedRecipes/RecommendedRecipes.tsx new file mode 100644 index 000000000..34950fbab --- /dev/null +++ b/src/components/modules/product-detail/RecommendedRecipes/RecommendedRecipes.tsx @@ -0,0 +1,51 @@ +import { TOptionsEvents } from 'keen-slider'; +import React from 'react'; +import { CarouselCommon, HeadingCommon, RecipeCard, ViewAllItem } from 'src/components/common'; +import { RecipeCardProps } from 'src/components/common/RecipeCard/RecipeCard'; +import { ROUTE } from 'src/utils/constanst.utils'; +import s from './RecommendedRecipes.module.scss'; + +const OPTION_DEFAULT: TOptionsEvents = { + slidesPerView: 1.25, + mode: 'free', + spacing: 24, + breakpoints: { + '(min-width: 640px)': { + slidesPerView: 2, + }, + '(min-width: 1024px)': { + slidesPerView: 2.5, + }, + '(min-width: 1440px)': { + slidesPerView: 3, + }, + '(min-width: 1536px)': { + slidesPerView: 3.5, + }, + }, +} + +interface Props { + data: RecipeCardProps[], +} + +const RecommendedRecipes = ({ data }: Props) => { + return ( +
      +
      + Recommended Recipes + +
      +
      + + data={data} + Component={RecipeCard} + itemKey="Recommended Recipes" + option={OPTION_DEFAULT} + /> +
      +
      + ); +}; + +export default RecommendedRecipes; \ No newline at end of file diff --git a/src/components/modules/product-detail/ReleventProducts/ReleventProducts.tsx b/src/components/modules/product-detail/ReleventProducts/ReleventProducts.tsx new file mode 100644 index 000000000..e11d31065 --- /dev/null +++ b/src/components/modules/product-detail/ReleventProducts/ReleventProducts.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import ListProductWithInfo from 'src/components/common/ListProductWithInfo/ListProductWithInfo'; +import { PRODUCT_DATA_TEST } from 'src/utils/demo-data'; + +const ReleventProducts = () => { + return ( + + ); +}; + +export default ReleventProducts; \ No newline at end of file diff --git a/src/components/modules/product-detail/ViewedProducts/ViewedProducts.tsx b/src/components/modules/product-detail/ViewedProducts/ViewedProducts.tsx new file mode 100644 index 000000000..820af402f --- /dev/null +++ b/src/components/modules/product-detail/ViewedProducts/ViewedProducts.tsx @@ -0,0 +1,15 @@ +import React from 'react'; +import ListProductWithInfo from 'src/components/common/ListProductWithInfo/ListProductWithInfo'; +import { PRODUCT_DATA_TEST } from 'src/utils/demo-data'; + +const ViewedProducts = () => { + return ( + + ); +}; + +export default ViewedProducts; \ No newline at end of file diff --git a/src/components/modules/product-detail/index.ts b/src/components/modules/product-detail/index.ts new file mode 100644 index 000000000..ef4461432 --- /dev/null +++ b/src/components/modules/product-detail/index.ts @@ -0,0 +1,4 @@ +export { default as ProductInfoDetail } from './ProductInfoDetail/ProductInfoDetail' +export { default as ViewedProducts } from './ViewedProducts/ViewedProducts' +export { default as ReleventProducts } from './ReleventProducts/ReleventProducts' +export { default as RecommendedRecipes } from './RecommendedRecipes/RecommendedRecipes' diff --git a/src/styles/_base.scss b/src/styles/_base.scss index 67eb96726..e8719581f 100644 --- a/src/styles/_base.scss +++ b/src/styles/_base.scss @@ -6,7 +6,7 @@ --primary-lightest: #effaf4; --info-dark: #00317a; - --info: #297fff; + --info: #3468B7; --info-border-line: #d6e7ff; --info-light: #ebf3ff; @@ -21,7 +21,7 @@ --warning-light: #fef8eb; --negative-dark: #741a06; - --negative: #f34f2b; + --negative: #D1644D; --negative-border-line: #fddfd8; --negative-light: #feefec; @@ -33,6 +33,7 @@ --disabled: #cccccc; --border-line: #ebebeb; --background: #fff; + --background-gray: #F5F4F2; --gray: #f8f8f8; --white: #fff; --background-arrow:rgba(20, 20, 20, 0.05); @@ -79,5 +80,5 @@ html { } a { - -webkit-tap-highlight-color: var(--text-active); + -webkit-tap-highlight-color: var(--primary); } diff --git a/src/styles/_utilities.scss b/src/styles/_utilities.scss index 26cea17c0..cc13ea3cf 100644 --- a/src/styles/_utilities.scss +++ b/src/styles/_utilities.scss @@ -120,6 +120,25 @@ font-family: var(--font-logo); } + .custom-scroll { + overflow-y: auto; + &::-webkit-scrollbar-track { + background-color: var(--background-gray); + border-radius: 10px; + } + + &::-webkit-scrollbar { + border-radius: 10px; + width: 6px; + background-color: var(--background-gray); + } + + &::-webkit-scrollbar-thumb { + border-radius: 10px; + background-color: var(--primary) + } + } + .u-form { .body { > div { @@ -137,4 +156,9 @@ } } } + + .u-icon { + width: 2rem; + height: 2rem; + } } diff --git a/src/utils/constanst.utils.ts b/src/utils/constanst.utils.ts index f299e8e20..e5966ad7e 100644 --- a/src/utils/constanst.utils.ts +++ b/src/utils/constanst.utils.ts @@ -8,9 +8,12 @@ export const SOCIAL_LINKS = { export const ROUTE = { HOME: '/', PRODUCTS: '/products', + PRODUCT_DETAIL: '/product', ABOUT: '/about', BLOG_DETAIL: '/blogdetail', ACCOUNT: '/account', + RECIPES: '/recipes', + BUSSINESS: '/bussiness', CONTACT: '/contact', FAQ: '/faq', diff --git a/src/utils/demo-data.ts b/src/utils/demo-data.ts new file mode 100644 index 000000000..64c8128ae --- /dev/null +++ b/src/utils/demo-data.ts @@ -0,0 +1,215 @@ +import { RecipeCardProps } from "src/components/common/RecipeCard/RecipeCard" + +export const PRODUCT_DATA_TEST = [ + { + name: 'Tomato', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646211-d56b77ac-83f1-4dd2-b55c-e3f1e0ba4e49.png", + }, + { + name: 'Cucumber', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646211-d56b77ac-83f1-4dd2-b55c-e3f1e0ba4e49.png", + }, + { + name: 'Carrot', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646217-23b86160-45c9-4845-8dcc-b3e1a4483edd.png", + }, + { + name: 'Salad', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646221-aaa1d48d-bb80-470f-9400-ae2aa47285b6.png", + }, + { + name: 'Tomato', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646224-d22dc2e4-6ae8-4bbe-adcf-491ce191f09b.png", + }, + { + name: 'Cucumber', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646225-2728f192-481b-4142-99b0-dde92f53c6c6.png", + }, + { + name: 'Tomato', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646227-b5705e64-3b45-47a3-9433-9f4b5ee8d40c.png", + }, + { + name: 'Cucumber', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646231-2d1c3ad1-4f5b-4a8e-9874-ca731f4ce128.png", + }, +] + +export const PRODUCT_CART_DATA_TEST = [ + { + name: 'Tomato', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646211-d56b77ac-83f1-4dd2-b55c-e3f1e0ba4e49.png", + oldPrice: 'Rp 32.000', + discount: '15%', + quantity: 1, + }, + { + name: 'Cucumber', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646211-d56b77ac-83f1-4dd2-b55c-e3f1e0ba4e49.png", + oldPrice: 'Rp 32.000', + discount: '15%', + quantity: 2, + }, + { + name: 'Carrot', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646217-23b86160-45c9-4845-8dcc-b3e1a4483edd.png", + oldPrice: 'Rp 32.000', + discount: '20%', + quantity: 3, + }, + { + name: 'Salad', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646221-aaa1d48d-bb80-470f-9400-ae2aa47285b6.png", + quantity: 1, + }, +] + +export const INGREDIENT_DATA_TEST = [ + { + name: 'Tomato', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646211-d56b77ac-83f1-4dd2-b55c-e3f1e0ba4e49.png", + }, + { + name: 'Cucumber', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646211-d56b77ac-83f1-4dd2-b55c-e3f1e0ba4e49.png", + isNotSell: true, + }, + { + name: 'Carrot', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646217-23b86160-45c9-4845-8dcc-b3e1a4483edd.png", + }, + { + name: 'Salad', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646221-aaa1d48d-bb80-470f-9400-ae2aa47285b6.png", + isNotSell: true, + }, + { + name: 'Tomato', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646224-d22dc2e4-6ae8-4bbe-adcf-491ce191f09b.png", + }, + { + name: 'Cucumber', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646225-2728f192-481b-4142-99b0-dde92f53c6c6.png", + }, + { + name: 'Tomato', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646227-b5705e64-3b45-47a3-9433-9f4b5ee8d40c.png", + }, + { + name: 'Cucumber', + slug: 'tomato', + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646231-2d1c3ad1-4f5b-4a8e-9874-ca731f4ce128.png", + }, +] + +export const RECIPE_DATA_TEST: RecipeCardProps[] = [ + { + title: "Special Recipe of Vietnamese Phở", + description: "Alright, before we get to the actual recipe, let’s chat for a sec about the ingredients. To make this pho soup recipe, you will need:", + imageSrc: 'https://user-images.githubusercontent.com/76729908/132159257-f92574c7-d00d-4142-8ea7-0ca9515fb737.png' + }, + { + title: "Original Recipe of Curry", + description: "Chicken curry is common to several countries including India, countries in Asia and the Caribbean. My favorite of them though is this aromatic Indian...", + imageSrc: 'https://user-images.githubusercontent.com/76729908/132159259-ae4c986d-ab53-4758-9137-d06bafdd15d0.png' + }, + { + title: "The Best Recipe of Beef Noodle Soup", + description: "The broth for Bun Bo Hue is prepared by slowly simmering various types of beef and pork bones (ox tail, beef shank, pork neck bones, pork feet,...", + imageSrc: 'https://user-images.githubusercontent.com/76729908/132159262-f28a9fb9-4852-47e6-80b5-d600521b548a.png' + }, + { + title: "Special Recipe of Vietnamese Phở", + description: "Alright, before we get to the actual recipe, let’s chat for a sec about the ingredients. To make this pho soup recipe, you will need:", + imageSrc: 'https://user-images.githubusercontent.com/76729908/132159257-f92574c7-d00d-4142-8ea7-0ca9515fb737.png' + }, + { + title: "Original Recipe of Curry", + description: "Chicken curry is common to several countries including India, countries in Asia and the Caribbean. My favorite of them though is this aromatic Indian...", + imageSrc: 'https://user-images.githubusercontent.com/76729908/132159259-ae4c986d-ab53-4758-9137-d06bafdd15d0.png' + }, + { + title: "The Best Recipe of Beef Noodle Soup", + description: "The broth for Bun Bo Hue is prepared by slowly simmering various types of beef and pork bones (ox tail, beef shank, pork neck bones, pork feet,...", + imageSrc: 'https://user-images.githubusercontent.com/76729908/132159262-f28a9fb9-4852-47e6-80b5-d600521b548a.png' + }, +] \ No newline at end of file diff --git a/src/utils/language.utils.ts b/src/utils/language.utils.ts index 3f8d61926..191215aaa 100644 --- a/src/utils/language.utils.ts +++ b/src/utils/language.utils.ts @@ -2,6 +2,8 @@ export const LANGUAGE = { BUTTON_LABEL: { BUY_NOW: 'Buy now', SHOP_NOW: 'Shop now', + ADD_TO_CARD: 'Add to Cart', + PREORDER: 'Pre-Order Now', }, PLACE_HOLDER: { SEARCH: 'Search', diff --git a/src/utils/types.utils.ts b/src/utils/types.utils.ts index 6fa8df0e8..c927f977e 100644 --- a/src/utils/types.utils.ts +++ b/src/utils/types.utils.ts @@ -1,9 +1,13 @@ export interface ProductProps { - category: string + category?: string name: string + slug: string weight: string price: string + oldPrice?: string + discount?: string imageSrc: string + isNotSell?: boolean } export interface FeaturedProductProps { @@ -16,20 +20,20 @@ export interface FeaturedProductProps { export interface RecipeProps { title: string - description:string + description: string imageSrc: string } export interface CheckOutForm { - name: string - email:string - address: string - city:string - state:string - code:number - phone:number - method:string - shipping_fee:number + name?: string + email?:string + address?: string + city?:string + state?:string + code?:number + phone?:number + method?:string + shipping_fee?:number } diff --git a/tailwind.config.js b/tailwind.config.js index 028e78f05..69ab1ade5 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -47,19 +47,20 @@ module.exports = { 'line': 'var(--border-line)', 'background': 'var(--background)', + 'background-gray': 'var(--background-gray)', 'white': 'var(--white)', - 'background-arrow':'var(--background-arrow)', + 'background-arrow': 'var(--background-arrow)', + - 'disabled': 'var(--text-disabled)', line: 'var(--border-line)', background: 'var(--background)', white: 'var(--white)', gray: 'var(--gray)', disabled: 'var(--text-disabled)', - 'background-arrow':'var(--background-arrow)', - + 'background-arrow': 'var(--background-arrow)', + // @deprecated (NOT use these variables) 'primary-2': 'var(--primary-2)', secondary: 'var(--secondary)', @@ -93,7 +94,7 @@ module.exports = { label: 'var(--text-label)', placeholder: 'var(--text-placeholder)', primary: 'var(--primary)', - + // @deprecated (NOT use these variables) secondary: 'var(--text-secondary)', }, @@ -112,9 +113,11 @@ module.exports = { 'sm-only': {'min': '0', 'max': '767px'}, 'sm': '640px', // => @media (min-width: 640px) { ... } + 'md-only': {'min': '768px', 'max': '1023px'}, 'md': '768px', // => @media (min-width: 768px) { ... } + 'lg-only': {'min': '1024px', 'max': '1279px'}, 'lg': '1024px', // => @media (min-width: 1024px) { ... } @@ -125,8 +128,8 @@ module.exports = { '2xl': '1536px', // => @media (min-width: 1536px) { ... } }, - caroucel:{ - "arrow-height":"64px" + caroucel: { + "arrow-height": "64px" }, }, }, From 7fcea39572e3c0227e12d3df753a086ce958e2c3 Mon Sep 17 00:00:00 2001 From: sonnguyenkieio Date: Wed, 8 Sep 2021 09:58:06 +0700 Subject: [PATCH 12/19] :sparkles: feat: Tab Common --- src/components/common/TabCommon/TabCommon.tsx | 2 +- .../TabCommon/{ => components}/TabItem/TabItem.module.scss | 0 .../common/TabCommon/{ => components}/TabItem/TabItem.tsx | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename src/components/common/TabCommon/{ => components}/TabItem/TabItem.module.scss (100%) rename src/components/common/TabCommon/{ => components}/TabItem/TabItem.tsx (100%) diff --git a/src/components/common/TabCommon/TabCommon.tsx b/src/components/common/TabCommon/TabCommon.tsx index b837004d6..691b1d026 100644 --- a/src/components/common/TabCommon/TabCommon.tsx +++ b/src/components/common/TabCommon/TabCommon.tsx @@ -1,7 +1,7 @@ import React, { RefObject, useEffect } from "react" import s from './TabCommon.module.scss' -import TabItem from './TabItem/TabItem' +import TabItem from './components/TabItem/TabItem' interface TabCommonProps { tabs: {ref:RefObject, tabName: string, active: boolean, onClick: (tabIndex: number, tabPane?: string) => void}[]; diff --git a/src/components/common/TabCommon/TabItem/TabItem.module.scss b/src/components/common/TabCommon/components/TabItem/TabItem.module.scss similarity index 100% rename from src/components/common/TabCommon/TabItem/TabItem.module.scss rename to src/components/common/TabCommon/components/TabItem/TabItem.module.scss diff --git a/src/components/common/TabCommon/TabItem/TabItem.tsx b/src/components/common/TabCommon/components/TabItem/TabItem.tsx similarity index 100% rename from src/components/common/TabCommon/TabItem/TabItem.tsx rename to src/components/common/TabCommon/components/TabItem/TabItem.tsx From e21fc5ee303dadd4757c9b569947a8f19a338fe9 Mon Sep 17 00:00:00 2001 From: sonnguyenkieio Date: Wed, 8 Sep 2021 09:59:40 +0700 Subject: [PATCH 13/19] :sparkles: feat: Tab Common --- .../components/TabPane/TabPane.module.scss | 23 +++++++++++++++++++ .../TabCommon/components/TabPane/TabPane.tsx | 20 ++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/components/common/TabCommon/components/TabPane/TabPane.module.scss create mode 100644 src/components/common/TabCommon/components/TabPane/TabPane.tsx diff --git a/src/components/common/TabCommon/components/TabPane/TabPane.module.scss b/src/components/common/TabCommon/components/TabPane/TabPane.module.scss new file mode 100644 index 000000000..6904a6acb --- /dev/null +++ b/src/components/common/TabCommon/components/TabPane/TabPane.module.scss @@ -0,0 +1,23 @@ +@import '../../../../../../styles/utilities'; + +.tabPane { + @apply hidden; + animation-duration: 0.6s; + animation-name: appear; + @keyframes appear { + from { + margin-left: 100%; + width: 200%; + } + + to { + margin-left: 0%; + width: 100%; + } + } + + + &.active { + @apply block; + } +} \ No newline at end of file diff --git a/src/components/common/TabCommon/components/TabPane/TabPane.tsx b/src/components/common/TabCommon/components/TabPane/TabPane.tsx new file mode 100644 index 000000000..3b39291b7 --- /dev/null +++ b/src/components/common/TabCommon/components/TabPane/TabPane.tsx @@ -0,0 +1,20 @@ +import classNames from "classnames" +import React from "react" +import s from './TabPane.module.scss' + +interface TabPaneProps { + active: string; + children?: React.ReactNode; +} + +const TabPane = ({ active="", children } : TabPaneProps) => { + return ( +
      + {children} +
      + ) +} + +export default TabPane \ No newline at end of file From c4829f1d527cd8797a53565fc541dddbc6451048 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2021 14:48:53 +0700 Subject: [PATCH 14/19] :hammer: refactor: tabcommon -datnguyen :%s --- pages/test.tsx | 31 ++++-- .../common/TabCommon/TabCommon.module.scss | 43 ++++---- src/components/common/TabCommon/TabCommon.tsx | 97 ++++++++++++++----- .../components/TabItem/TabItem.module.scss | 22 ++--- .../TabCommon/components/TabItem/TabItem.tsx | 37 ++++--- .../components/TabPane/TabPane.module.scss | 28 +++--- .../TabCommon/components/TabPane/TabPane.tsx | 9 +- 7 files changed, 172 insertions(+), 95 deletions(-) diff --git a/pages/test.tsx b/pages/test.tsx index 970588581..6df50d601 100644 --- a/pages/test.tsx +++ b/pages/test.tsx @@ -1,8 +1,7 @@ import { useState } from 'react' -import { - ButtonCommon, - Layout, ModalInfo -} from 'src/components/common' +import { ButtonCommon, Layout, ModalInfo } from 'src/components/common' +import TabPane from 'src/components/common/TabCommon/components/TabPane/TabPane' +import TabCommon from 'src/components/common/TabCommon/TabCommon' export default function Test() { const [visible, setVisible] = useState(false) const onClose = () => { @@ -13,10 +12,26 @@ export default function Test() { } return ( <> - open - - Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nisi qui, esse eos nobis soluta suscipit aliquid nostrum corporis. Nihil eligendi similique recusandae minus mollitia aliquam, molestias fugit tenetur voluptatibus maiores et. Quaerat labore corporis inventore nostrum, amet autem exercitationem eligendi? - + + +
      + datdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdatdat +
      +
      + +
      + Lorem ipsum dolor sit, amet consectetur adipisicing elit. Suscipit harum sint maiores optio? Perspiciatis, necessitatibus pariatur, ut sed aperiam minus reiciendis alias deleniti eligendi obcaecati illum id maxime accusantium beatae. +
      +
      + +
      + 11111111111111111111111111111111111111111111111111111111111 +
      +
      +
      ) } diff --git a/src/components/common/TabCommon/TabCommon.module.scss b/src/components/common/TabCommon/TabCommon.module.scss index 3d3473d82..e087018be 100644 --- a/src/components/common/TabCommon/TabCommon.module.scss +++ b/src/components/common/TabCommon/TabCommon.module.scss @@ -1,21 +1,28 @@ @import '../../../styles/utilities'; - -.tabCommon { - @apply flex; - position: relative; - border-bottom: 2px solid #FBFBFB; - padding-top: 1.6rem; - padding-bottom: 1.6rem; - width: 100%; - - .slider { - @apply inline-block; - height: .2rem; - border-radius: 3px; - background-color: var(--primary); - position: absolute; - z-index: 1200; - bottom: 0; - transition: all .4s linear; +.tabWapper{ + @apply flex flex-col w-full; + .tabHeader{ + @apply relative; + .tabList { + @apply flex; + position: relative; + border-bottom: 2px solid #FBFBFB; + padding: 0.8rem 0; + width: 100%; + &.center{ + @apply justify-center; + } + + } + .slider { + @apply inline-block; + height: .2rem; + border-radius: 3px; + background-color: var(--primary); + position: absolute; + z-index: 1200; + bottom: 0; + transition: all .25s linear; + } } } diff --git a/src/components/common/TabCommon/TabCommon.tsx b/src/components/common/TabCommon/TabCommon.tsx index 691b1d026..ea0a762b3 100644 --- a/src/components/common/TabCommon/TabCommon.tsx +++ b/src/components/common/TabCommon/TabCommon.tsx @@ -1,36 +1,85 @@ -import React, { RefObject, useEffect } from "react" +import React, { + Children, + PropsWithChildren, + ReactElement, + RefObject, + useEffect, + useRef, + useState, + cloneElement, +} from 'react' import s from './TabCommon.module.scss' import TabItem from './components/TabItem/TabItem' +import { TabPaneProps } from './components/TabPane/TabPane' +import classNames from 'classnames' interface TabCommonProps { - tabs: {ref:RefObject, tabName: string, active: boolean, onClick: (tabIndex: number, tabPane?: string) => void}[]; - defaultActiveTab: number; - sliderRef : RefObject; - slideToTab: (ref: any) => void; + defaultActiveTab?: number + children: React.ReactNode + center?:boolean } -const TabCommon = ({ tabs, defaultActiveTab, sliderRef, slideToTab } : TabCommonProps) => { +const TabCommon = ({ + defaultActiveTab = 0, + children, + center +}: TabCommonProps) => { + const [active, setActive] = useState(0) + const slider = useRef(null) + const headerRef = useRef(null) + useEffect(() => { + setActive(defaultActiveTab) + }, []) - useEffect(() => { - slideToTab(tabs[defaultActiveTab].ref); - }, []) + useEffect(() => { + slide(active) + }, [active]) - return ( -
        - { - tabs.map((tab) => { - return ( -
      • - {tab.tabName} -
      • - ) - }) - } - -
        + function slide(index: number) { + const active = headerRef.current?.children + .item(index) + ?.getBoundingClientRect() + const current = slider.current + if (current && active) { + let width = active.width - 24 <= 0 ? 24 : active.width - 24 + let left = active.left + current.style.width = width.toString() + 'px' + current.style.left = left.toString() + 'px' + } + } + const onTabClick = (index: number) => { + setActive(index) + } + return ( +
        +
        +
          + {Children.map(children, (tab, index) => { + let item = tab as ReactElement> + return ( +
        • + + {item.props.tabName} + +
        • + ) + })}
        - ) +
        +
        +
        + {Children.map(children, (tab, index) => { + let item = tab as ReactElement> + return cloneElement(item, { active:index===active }); + }) + }
        +
        + ) } -export default TabCommon; +export default TabCommon diff --git a/src/components/common/TabCommon/components/TabItem/TabItem.module.scss b/src/components/common/TabCommon/components/TabItem/TabItem.module.scss index bdbb0b66a..2b4f6af7f 100644 --- a/src/components/common/TabCommon/components/TabItem/TabItem.module.scss +++ b/src/components/common/TabCommon/components/TabItem/TabItem.module.scss @@ -1,22 +1,14 @@ -@import '../../../../styles/utilities'; +@import '../../../../../styles/utilities'; .tabItem { - margin-right: 4.8rem; - padding-top: 1.6rem; - padding-bottom: 1.6rem; - + margin-right:2.4rem; + padding: 0.8rem 0; + min-width: 2.4rem; &:hover { @apply cursor-pointer; } -} - -.tabItemActive { - @apply font-bold; - margin-right: 4.8rem; - padding-top: 1.6rem; - padding-bottom: 1.6rem; - - &:hover { - @apply cursor-pointer; + &.tabItemActive { + @apply font-bold; } } + diff --git a/src/components/common/TabCommon/components/TabItem/TabItem.tsx b/src/components/common/TabCommon/components/TabItem/TabItem.tsx index 6881c2aca..742c1e0dd 100644 --- a/src/components/common/TabCommon/components/TabItem/TabItem.tsx +++ b/src/components/common/TabCommon/components/TabItem/TabItem.tsx @@ -1,19 +1,32 @@ -import React from "react" +import classNames from 'classnames' +import React, { RefObject, useRef } from 'react' import s from './TabItem.module.scss' interface TabItemProps { - active: boolean; - children: string; - onClick: (tabIndex: number, tabPane: string) => void; + active: boolean + children: string + onClick?: (tabIndex: number) => void + tabIndex: number } -const TabItem = ({ active = false, children, onClick } : TabItemProps) => { - - return ( - - {children} - - ) +const TabItem = ({ + active = false, + children, + onClick, + tabIndex, +}: TabItemProps) => { + const handleClick = () => { + onClick && onClick(tabIndex) + } + return ( + + {children} + + ) } -export default TabItem; +export default TabItem diff --git a/src/components/common/TabCommon/components/TabPane/TabPane.module.scss b/src/components/common/TabCommon/components/TabPane/TabPane.module.scss index 6904a6acb..380472828 100644 --- a/src/components/common/TabCommon/components/TabPane/TabPane.module.scss +++ b/src/components/common/TabCommon/components/TabPane/TabPane.module.scss @@ -1,20 +1,20 @@ -@import '../../../../../../styles/utilities'; - +@import "../../../../../styles/utilities"; .tabPane { @apply hidden; - animation-duration: 0.6s; - animation-name: appear; - @keyframes appear { - from { - margin-left: 100%; - width: 200%; - } + transition: all 0.6s; + // animation-duration: 0.6s; + // animation-name: appear; + // @keyframes appear { + // from { + // margin-left: 100%; + // width: 200%; + // } - to { - margin-left: 0%; - width: 100%; - } - } + // to { + // margin-left: 0%; + // width: 100%; + // } + // } &.active { diff --git a/src/components/common/TabCommon/components/TabPane/TabPane.tsx b/src/components/common/TabCommon/components/TabPane/TabPane.tsx index 3b39291b7..e67784535 100644 --- a/src/components/common/TabCommon/components/TabPane/TabPane.tsx +++ b/src/components/common/TabCommon/components/TabPane/TabPane.tsx @@ -2,15 +2,16 @@ import classNames from "classnames" import React from "react" import s from './TabPane.module.scss' -interface TabPaneProps { - active: string; +export interface TabPaneProps { + active: boolean; children?: React.ReactNode; + tabName: string } -const TabPane = ({ active="", children } : TabPaneProps) => { +const TabPane = ({ active, children } : TabPaneProps) => { return (
        {children}
        From 0920bef68b9e34d4f32b1b148abd2f83a1139855 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2021 15:30:12 +0700 Subject: [PATCH 15/19] :hammer: refactor: tabcommon :%s --- .../common/TabCommon/TabCommon.module.scss | 25 +++++++++---------- src/components/common/TabCommon/TabCommon.tsx | 7 +++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/common/TabCommon/TabCommon.module.scss b/src/components/common/TabCommon/TabCommon.module.scss index e087018be..6dcb203c1 100644 --- a/src/components/common/TabCommon/TabCommon.module.scss +++ b/src/components/common/TabCommon/TabCommon.module.scss @@ -2,27 +2,26 @@ .tabWapper{ @apply flex flex-col w-full; .tabHeader{ - @apply relative; + @apply flex; .tabList { @apply flex; position: relative; border-bottom: 2px solid #FBFBFB; padding: 0.8rem 0; - width: 100%; &.center{ - @apply justify-center; + margin: auto; } - } - .slider { - @apply inline-block; - height: .2rem; - border-radius: 3px; - background-color: var(--primary); - position: absolute; - z-index: 1200; - bottom: 0; - transition: all .25s linear; + .slider { + @apply inline-block; + height: .2rem; + border-radius: 3px; + background-color: var(--primary); + position: absolute; + z-index: 1200; + bottom: 0; + transition: all .25s linear; + } } } } diff --git a/src/components/common/TabCommon/TabCommon.tsx b/src/components/common/TabCommon/TabCommon.tsx index ea0a762b3..afefb0da3 100644 --- a/src/components/common/TabCommon/TabCommon.tsx +++ b/src/components/common/TabCommon/TabCommon.tsx @@ -40,10 +40,11 @@ const TabCommon = ({ const active = headerRef.current?.children .item(index) ?.getBoundingClientRect() + const header = headerRef.current?.getBoundingClientRect() const current = slider.current - if (current && active) { + if (current && active && header) { let width = active.width - 24 <= 0 ? 24 : active.width - 24 - let left = active.left + let left = active.left - header.left current.style.width = width.toString() + 'px' current.style.left = left.toString() + 'px' } @@ -69,8 +70,8 @@ const TabCommon = ({ ) })} -
      +
    {Children.map(children, (tab, index) => { From 1d17953816b4fd6b90ac2b0152c8d46654355884 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Sep 2021 17:41:26 +0700 Subject: [PATCH 16/19] init:bank transfer --- .../TabCommon/components/TabPane/TabPane.tsx | 2 +- src/components/common/index.ts | 2 ++ .../checkout/CheckoutInfo/CheckoutInfo.tsx | 6 ++++++ .../PaymentInfoForm/PaymentInfoForm.tsx | 21 ++++++++++++------- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/components/common/TabCommon/components/TabPane/TabPane.tsx b/src/components/common/TabCommon/components/TabPane/TabPane.tsx index e67784535..c0c7d2efa 100644 --- a/src/components/common/TabCommon/components/TabPane/TabPane.tsx +++ b/src/components/common/TabCommon/components/TabPane/TabPane.tsx @@ -3,7 +3,7 @@ import React from "react" import s from './TabPane.module.scss' export interface TabPaneProps { - active: boolean; + active?: boolean; children?: React.ReactNode; tabName: string } diff --git a/src/components/common/index.ts b/src/components/common/index.ts index a7b9075d3..33a555bff 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -41,3 +41,5 @@ export { default as ImgWithLink} from './ImgWithLink/ImgWithLink' export { default as RecipeDetail} from './RecipeDetail/RecipeDetail' export { default as DrawerCommon} from './DrawerCommon/DrawerCommon' export { default as CartDrawer} from './CartDrawer/CartDrawer' +export { default as TabPane} from './TabCommon/components/TabPane/TabPane' +export { default as TabCommon} from './TabCommon/TabCommon' diff --git a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx index 16852ea43..0e0c9ccaa 100644 --- a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx +++ b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx @@ -4,6 +4,7 @@ import CheckoutCollapse from 'src/components/common/CheckoutCollapse/CheckoutCol import { CheckOutForm } from 'src/utils/types.utils' import s from './CheckoutInfo.module.scss' import CustomerInfoForm from './components/CustomerInfoForm/CustomerInfoForm' +import PaymentInfoForm from './components/PaymentInfoForm/PaymentInfoForm' import ShippingInfoForm from './components/ShippingInfoForm/ShippingInfoForm' interface CheckoutInfoProps {} @@ -44,6 +45,11 @@ const CheckoutInfo = ({}: CheckoutInfoProps) => { title: 'Shipping Information', form: , }, + { + id: 3, + title: 'Payment Information', + form: , + }, ] return (
    diff --git a/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.tsx b/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.tsx index a947faa8b..1e29789c0 100644 --- a/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.tsx +++ b/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.tsx @@ -1,19 +1,26 @@ import React from 'react' -import TabPane from 'src/components/common/TabCommon/components/TabPane/TabPane' -import TabCommon from 'src/components/common/TabCommon/TabCommon' +import { TabCommon, TabPane } from 'src/components/common' +import { CheckOutForm } from 'src/utils/types.utils' +import BankTransfer from '../BankTransfer/BankTransfer' + import s from "./PaymentInfoForm.module.scss" interface PaymentInfoFormProps { - + onConfirm?: (id:number,formInfo:CheckOutForm)=>void + id:number } const PaymentInfoForm = ({}: PaymentInfoFormProps) => { return ( -
    +
    - {/* - - */} + + + + + + +
    ) } From 0eed5ab0512fb4b0f8c897801471b929713dd180 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 9 Sep 2021 16:18:51 +0700 Subject: [PATCH 17/19] :sparkles: feat: Checkout Page :%s --- pages/checkout.tsx | 13 ++++ pages/test.tsx | 36 +---------- .../CardItemCheckout.module.scss | 8 +-- .../common/CheckboxCommon/CheckboxCommon.tsx | 5 +- .../CheckoutCollapse.module.scss | 14 ++++- .../CheckoutCollapse/CheckoutCollapse.tsx | 10 ++- src/components/common/index.ts | 1 - src/components/icons/IconDoneCheckout.tsx | 20 ++++++ src/components/icons/index.ts | 1 + .../CheckoutBill/CheckoutBill.module.scss | 1 + .../checkout}/CheckoutBill/CheckoutBill.tsx | 4 +- .../CheckoutInfo/CheckoutInfo.module.scss | 3 +- .../checkout/CheckoutInfo/CheckoutInfo.tsx | 56 ++++++++--------- .../BankTransfer/BankTransfer.module.scss | 18 ++++-- .../components/BankTransfer/BankTransfer.tsx | 24 ++++---- .../CreditCardForm/CreditCardForm.module.scss | 12 ++++ .../CreditCardForm/CreditCardForm.tsx | 27 ++++++++ .../PaymentInfoForm.module.scss | 14 +++++ .../PaymentInfoForm/PaymentInfoForm.tsx | 61 +++++++++++++------ .../CheckoutPage/CheckoutPage.module.scss | 10 +++ .../checkout/CheckoutPage/CheckoutPage.tsx | 18 ++++++ src/components/modules/checkout/index.ts | 2 + src/utils/demo-data.ts | 33 +++++++++- src/utils/funtion.utils.ts | 8 +++ 24 files changed, 287 insertions(+), 112 deletions(-) create mode 100644 pages/checkout.tsx create mode 100644 src/components/icons/IconDoneCheckout.tsx rename src/components/{common => modules/checkout}/CheckoutBill/CheckoutBill.module.scss (95%) rename src/components/{common => modules/checkout}/CheckoutBill/CheckoutBill.tsx (89%) create mode 100644 src/components/modules/checkout/CheckoutInfo/components/CreditCardForm/CreditCardForm.module.scss create mode 100644 src/components/modules/checkout/CheckoutInfo/components/CreditCardForm/CreditCardForm.tsx create mode 100644 src/components/modules/checkout/CheckoutPage/CheckoutPage.module.scss create mode 100644 src/components/modules/checkout/CheckoutPage/CheckoutPage.tsx diff --git a/pages/checkout.tsx b/pages/checkout.tsx new file mode 100644 index 000000000..f2bc93517 --- /dev/null +++ b/pages/checkout.tsx @@ -0,0 +1,13 @@ +import { Layout } from 'src/components/common'; +import { CheckoutPage } from 'src/components/modules/checkout'; +import { HomeBanner, HomeCategories, HomeCollection, HomeCTA, HomeFeature, HomeRecipe, HomeSubscribe, HomeVideo } from 'src/components/modules/home'; + +export default function Checkout() { + return ( + <> + + + ) +} + +Checkout.Layout = Layout diff --git a/pages/test.tsx b/pages/test.tsx index b7298a091..f46bd55fe 100644 --- a/pages/test.tsx +++ b/pages/test.tsx @@ -1,6 +1,5 @@ import { useState } from 'react' import { - CheckoutBill, Layout, } from 'src/components/common' import { CardItemCheckoutProps } from 'src/components/common/CardItemCheckout/CardItemCheckout' @@ -9,43 +8,12 @@ import TabCommon from 'src/components/common/TabCommon/TabCommon' import { CheckoutInfo } from 'src/components/modules/checkout' import image7 from '../public/assets/images/image7.png' import image8 from '../public/assets/images/image8.png' -const dataTest:CardItemCheckoutProps[] = [ - { - name: 'Tomato', - slug: "tomato", - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - quantity:10 - }, - { - name: 'Carrot', - slug: "carrot", - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image7.src, - quantity:1 - }, - { - name: 'Salad', - slug:"salad", - weight: '250g', - category: 'VEGGIE', - price: 'Rp 27.500', - imageSrc: image8.src, - quantity:2 - }, -] + export default function Test() { return ( <> -
    - - -
    + { onChange?: (value: boolean) => void, defaultChecked?: boolean + text?:string } -const CheckboxCommon = ({onChange,defaultChecked = true,...props}: CheckboxProps) =>{ +const CheckboxCommon = ({onChange,defaultChecked = true,text="Billing address is same as shipping", ...props}: CheckboxProps) =>{ const [value, setValue] = useState(true); @@ -31,7 +32,7 @@ const CheckboxCommon = ({onChange,defaultChecked = true,...props}: CheckboxProps
    - +
    ) diff --git a/src/components/common/CheckoutCollapse/CheckoutCollapse.module.scss b/src/components/common/CheckoutCollapse/CheckoutCollapse.module.scss index b34630fed..9e8e1f8e5 100644 --- a/src/components/common/CheckoutCollapse/CheckoutCollapse.module.scss +++ b/src/components/common/CheckoutCollapse/CheckoutCollapse.module.scss @@ -1,7 +1,15 @@ .warpper{ + padding: 2.4rem 0; + @apply border-b border-solid border-line; + .note{ + font-size: 1.2rem; + line-height: 2rem; + letter-spacing: 0.01em; + color: var(--text-label); + padding: 0 5.6rem; + } .header{ @apply flex justify-between; - padding-bottom: 3.2rem; .left{ @apply flex items-center; .number{ @@ -16,6 +24,9 @@ border: none; color: var(--white); } + &.done{ + @apply border-2 border-solid border-primary; + } } .title{ padding-left: 2.4rem; @@ -33,6 +44,7 @@ height: 0; @apply overflow-hidden; &.show{ + margin-top: 3.2rem; height: initial; } } diff --git a/src/components/common/CheckoutCollapse/CheckoutCollapse.tsx b/src/components/common/CheckoutCollapse/CheckoutCollapse.tsx index 14348a625..077b94a79 100644 --- a/src/components/common/CheckoutCollapse/CheckoutCollapse.tsx +++ b/src/components/common/CheckoutCollapse/CheckoutCollapse.tsx @@ -1,5 +1,8 @@ import classNames from 'classnames' +import { divide } from 'lodash' import React from 'react' +import { IconDoneCheckout } from 'src/components/icons' +import { CheckOutForm } from 'src/utils/types.utils' import s from './CheckoutCollapse.module.scss' interface CheckoutCollapseProps { visible: boolean @@ -10,6 +13,7 @@ interface CheckoutCollapseProps { onClose?: (id:number) => void onOpen?: (id:number) => void onEditClick?:(id:number) => void + note?:string } const CheckoutCollapse = ({ @@ -18,6 +22,7 @@ const CheckoutCollapse = ({ title, isEdit, visible, + note, onOpen, onClose, onEditClick @@ -36,8 +41,8 @@ const CheckoutCollapse = ({
    -
    - {id} +
    + {isEdit?:id}
    {title} @@ -45,6 +50,7 @@ const CheckoutCollapse = ({
    {isEdit &&
    {'Edit'}
    }
    + {(!visible && isEdit) && (
    {note}
    ) }
    {children}
    ) diff --git a/src/components/common/index.ts b/src/components/common/index.ts index 33a555bff..15c2e4537 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -36,7 +36,6 @@ export { default as CardItemCheckout} from './CardItemCheckout/CardItemCheckout' export { default as CardBlog} from './CardBlog/CardBlog' export { default as RelevantBlogPosts} from './RelevantBlogPosts/RelevantBlogPosts' export { default as CollapseCommon} from './CollapseCommon/CollapseCommon' -export { default as CheckoutBill} from './CheckoutBill/CheckoutBill' export { default as ImgWithLink} from './ImgWithLink/ImgWithLink' export { default as RecipeDetail} from './RecipeDetail/RecipeDetail' export { default as DrawerCommon} from './DrawerCommon/DrawerCommon' diff --git a/src/components/icons/IconDoneCheckout.tsx b/src/components/icons/IconDoneCheckout.tsx new file mode 100644 index 000000000..418472d23 --- /dev/null +++ b/src/components/icons/IconDoneCheckout.tsx @@ -0,0 +1,20 @@ +import React from 'react' + +const IconDoneCheckout = () => { + return ( + + + + ) +} + +export default IconDoneCheckout diff --git a/src/components/icons/index.ts b/src/components/icons/index.ts index 7dfe3657c..152bb414c 100644 --- a/src/components/icons/index.ts +++ b/src/components/icons/index.ts @@ -31,3 +31,4 @@ export { default as IconDelete } from './IconDelete' export { default as IconPlus } from './IconPlus' export { default as IconMinus } from './IconMinus' export { default as IconCirclePlus } from './IconCirclePlus' +export { default as IconDoneCheckout } from './IconDoneCheckout' diff --git a/src/components/common/CheckoutBill/CheckoutBill.module.scss b/src/components/modules/checkout/CheckoutBill/CheckoutBill.module.scss similarity index 95% rename from src/components/common/CheckoutBill/CheckoutBill.module.scss rename to src/components/modules/checkout/CheckoutBill/CheckoutBill.module.scss index d0b15d516..d47382780 100644 --- a/src/components/common/CheckoutBill/CheckoutBill.module.scss +++ b/src/components/modules/checkout/CheckoutBill/CheckoutBill.module.scss @@ -17,6 +17,7 @@ min-height: 6.4rem; } .price { + margin-top: 3.2rem; .line { @apply flex justify-between items-center text-label; .total { diff --git a/src/components/common/CheckoutBill/CheckoutBill.tsx b/src/components/modules/checkout/CheckoutBill/CheckoutBill.tsx similarity index 89% rename from src/components/common/CheckoutBill/CheckoutBill.tsx rename to src/components/modules/checkout/CheckoutBill/CheckoutBill.tsx index cdbbe5165..259397980 100644 --- a/src/components/common/CheckoutBill/CheckoutBill.tsx +++ b/src/components/modules/checkout/CheckoutBill/CheckoutBill.tsx @@ -1,7 +1,7 @@ import React from 'react' import s from './CheckoutBill.module.scss' -import { CardItemCheckout } from '..' -import { CardItemCheckoutProps } from '../CardItemCheckout/CardItemCheckout' +import { CardItemCheckout } from '../../../common' +import { CardItemCheckoutProps } from '../../../common/CardItemCheckout/CardItemCheckout' import { IconCirclePlus } from 'src/components/icons' interface CheckoutBillProps { diff --git a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss index 3ca7d7101..6f97371a8 100644 --- a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss +++ b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss @@ -1,7 +1,8 @@ .warpper{ @apply w-full; + padding: 3.2rem; .title{ - padding: 3.2rem 0; + margin-bottom: 3.2rem; @apply flex justify-start items-center } } \ No newline at end of file diff --git a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx index 0e0c9ccaa..c989709e7 100644 --- a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx +++ b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx @@ -1,6 +1,7 @@ import React, { useState } from 'react' import { Logo } from 'src/components/common' import CheckoutCollapse from 'src/components/common/CheckoutCollapse/CheckoutCollapse' +import { removeItem } from 'src/utils/funtion.utils' import { CheckOutForm } from 'src/utils/types.utils' import s from './CheckoutInfo.module.scss' import CustomerInfoForm from './components/CustomerInfoForm/CustomerInfoForm' @@ -12,28 +13,41 @@ const CheckoutInfo = ({}: CheckoutInfoProps) => { const [active, setActive] = useState(1) const [done, setDone] = useState([]) const [info, setInfo] = useState({}) - const onOpen = (id:number) => { - setActive(id) - } const onEdit = (id:number) => { setActive(id) - } - - const onClose = (id:number) => { - setActive(id) + setDone(removeItem(done,id)) } const onConfirm = (id:number,formInfo:CheckOutForm) => { if(id+1>formList.length){ console.log({...info,...formInfo}) }else{ - - setActive(id+1) + if(done.length>0){ + for (let i = id+1; i <= formList.length; i++) { + if(!done.includes(i)){ + setActive(i) + } + } + }else{ + setActive(id+1) + } + setDone([...done,id]) } - setDone([...done,id]) setInfo({...info,...formInfo}) } + + const getNote = (id:number) => { + switch (id) { + case 1: + return `${info.name}, ${info.email}` + case 2: + return `${info.address}, ${info.state}, ${info.city}, ${info.code}, ${info.phone}, ` + default: + return "" + } + } + const formList = [ { id: 1, @@ -57,6 +71,7 @@ const CheckoutInfo = ({}: CheckoutInfoProps) => {
    {formList.map((item) => { + let note = getNote(item.id) return { title={item.title} onEditClick={onEdit} isEdit={done.includes(item.id)} + note={note} > {item.form} })} - {/* - - - - - */}
    ) } diff --git a/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.module.scss b/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.module.scss index e7d6e3573..44ac98048 100644 --- a/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.module.scss +++ b/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.module.scss @@ -1,9 +1,15 @@ .warpper{ - .title{ - min-width: 19.4rem; - @apply text-label; - } - .hightlight{ - @apply text-active; + .info{ + .line{ + @apply flex justify-start items-center; + .title{ + margin-right: 3.2rem; + min-width: 19.4rem; + @apply text-label; + } + .hightlight{ + @apply text-active; + } + } } } \ No newline at end of file diff --git a/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.tsx b/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.tsx index 463711618..7de11245c 100644 --- a/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.tsx +++ b/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.tsx @@ -5,17 +5,19 @@ interface BankTransferProps {} const BankTransfer = ({}: BankTransferProps) => { return (
    -
    -
    Account Name:
    -
    Duong Dinh Vu
    -
    -
    -
    Account Number:
    -
    1234 1234 1234 1234
    -
    -
    -
    Bank Name:
    -
    Techcombank - HCMC
    +
    +
    +
    Account Name:
    +
    Duong Dinh Vu
    +
    +
    +
    Account Number:
    +
    1234 1234 1234 1234
    +
    +
    +
    Bank Name:
    +
    Techcombank - HCMC
    +
    ) diff --git a/src/components/modules/checkout/CheckoutInfo/components/CreditCardForm/CreditCardForm.module.scss b/src/components/modules/checkout/CheckoutInfo/components/CreditCardForm/CreditCardForm.module.scss new file mode 100644 index 000000000..62dbbc8d3 --- /dev/null +++ b/src/components/modules/checkout/CheckoutInfo/components/CreditCardForm/CreditCardForm.module.scss @@ -0,0 +1,12 @@ +@import "../../../../../../styles/utilities"; +.warpper{ + @apply u-form; + .line{ + >div{ + width: 50%; + } + } + .checkbox{ + margin-top: 1.6rem; + } +} \ No newline at end of file diff --git a/src/components/modules/checkout/CheckoutInfo/components/CreditCardForm/CreditCardForm.tsx b/src/components/modules/checkout/CheckoutInfo/components/CreditCardForm/CreditCardForm.tsx new file mode 100644 index 000000000..d289165e0 --- /dev/null +++ b/src/components/modules/checkout/CheckoutInfo/components/CreditCardForm/CreditCardForm.tsx @@ -0,0 +1,27 @@ +import React, { useRef } from 'react' +import { CheckboxCommon, Inputcommon } from 'src/components/common' +import { CustomInputCommon } from 'src/utils/type.utils' +import s from "./CreditCardForm.module.scss" +interface CreditCardFormProps { + +} + +const CreditCardForm = ({}: CreditCardFormProps) => { + const cardNumberRef = useRef(null) + const dateRef = useRef(null) + const cvsRef = useRef(null) + return ( +
    +
    + +
    + + +
    +
    +
    +
    + ) +} + +export default CreditCardForm diff --git a/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.module.scss b/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.module.scss index e69de29bb..d70dcda16 100644 --- a/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.module.scss +++ b/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.module.scss @@ -0,0 +1,14 @@ +.wrapper{ + padding: 0 5.6rem; + .inner{ + padding: 4rem 0; + } + .bottom{ + margin-top: 2.4rem; + @apply flex justify-between items-center; + .note{ + font-size: 1.2rem; + line-height: 2rem; + } + } +} \ No newline at end of file diff --git a/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.tsx b/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.tsx index 1e29789c0..dc84fec38 100644 --- a/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.tsx +++ b/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.tsx @@ -1,28 +1,55 @@ import React from 'react' -import { TabCommon, TabPane } from 'src/components/common' +import { ButtonCommon, TabCommon, TabPane } from 'src/components/common' import { CheckOutForm } from 'src/utils/types.utils' import BankTransfer from '../BankTransfer/BankTransfer' +import Link from 'next/link' -import s from "./PaymentInfoForm.module.scss" +import s from './PaymentInfoForm.module.scss' +import CreditCardForm from '../CreditCardForm/CreditCardForm' interface PaymentInfoFormProps { - onConfirm?: (id:number,formInfo:CheckOutForm)=>void - id:number + onConfirm?: (id: number, formInfo: CheckOutForm) => void + id: number } -const PaymentInfoForm = ({}: PaymentInfoFormProps) => { - return ( -
    - - - - - - - - - +const PaymentInfoForm = ({onConfirm,id}: PaymentInfoFormProps) => { + const handleConfirmClick = () => { + onConfirm && onConfirm(id,{}) + } + return ( +
    + + +
    +
    + +
    +
    + +
    +
    +
    +
    +
    + By clicking continue you agree to Casper's{' '} + { + + terms and conditions + + }{' '} + and{' '} + { + + privacy policy + + } + .
    - ) + + Submit Order + +
    +
    + ) } export default PaymentInfoForm diff --git a/src/components/modules/checkout/CheckoutPage/CheckoutPage.module.scss b/src/components/modules/checkout/CheckoutPage/CheckoutPage.module.scss new file mode 100644 index 000000000..2038507d7 --- /dev/null +++ b/src/components/modules/checkout/CheckoutPage/CheckoutPage.module.scss @@ -0,0 +1,10 @@ +.warrper{ + @apply flex; + .right{ + min-width: 56.3rem; + } + .left{ + @apply w-full; + + } +} \ No newline at end of file diff --git a/src/components/modules/checkout/CheckoutPage/CheckoutPage.tsx b/src/components/modules/checkout/CheckoutPage/CheckoutPage.tsx new file mode 100644 index 000000000..5e2275f46 --- /dev/null +++ b/src/components/modules/checkout/CheckoutPage/CheckoutPage.tsx @@ -0,0 +1,18 @@ +import React from 'react' +import { CHECKOUT_BILL_DATA } from 'src/utils/demo-data' +import { CheckoutBill, CheckoutInfo } from '..' +import s from "./CheckoutPage.module.scss" +interface CheckoutPageProps { + +} + +const CheckoutPage = ({}: CheckoutPageProps) => { + return ( +
    +
    +
    +
    + ) +} + +export default CheckoutPage diff --git a/src/components/modules/checkout/index.ts b/src/components/modules/checkout/index.ts index 24a765b23..736375e4c 100644 --- a/src/components/modules/checkout/index.ts +++ b/src/components/modules/checkout/index.ts @@ -1 +1,3 @@ export { default as CheckoutInfo } from './CheckoutInfo/CheckoutInfo' +export { default as CheckoutPage } from './CheckoutPage/CheckoutPage' +export { default as CheckoutBill } from './CheckoutBill/CheckoutBill' diff --git a/src/utils/demo-data.ts b/src/utils/demo-data.ts index 64c8128ae..a4ebee5dc 100644 --- a/src/utils/demo-data.ts +++ b/src/utils/demo-data.ts @@ -1,3 +1,4 @@ +import { CardItemCheckoutProps } from "src/components/common/CardItemCheckout/CardItemCheckout" import { RecipeCardProps } from "src/components/common/RecipeCard/RecipeCard" export const PRODUCT_DATA_TEST = [ @@ -212,4 +213,34 @@ export const RECIPE_DATA_TEST: RecipeCardProps[] = [ description: "The broth for Bun Bo Hue is prepared by slowly simmering various types of beef and pork bones (ox tail, beef shank, pork neck bones, pork feet,...", imageSrc: 'https://user-images.githubusercontent.com/76729908/132159262-f28a9fb9-4852-47e6-80b5-d600521b548a.png' }, -] \ No newline at end of file +] + +export const CHECKOUT_BILL_DATA:CardItemCheckoutProps[] = [ + { + name: 'Tomato', + slug: "tomato", + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646227-b5705e64-3b45-47a3-9433-9f4b5ee8d40c.png", + quantity:10 + }, + { + name: 'Carrot', + slug: "carrot", + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646217-23b86160-45c9-4845-8dcc-b3e1a4483edd.png", + quantity:1 + }, + { + name: 'Salad', + slug:"salad", + weight: '250g', + category: 'VEGGIE', + price: 'Rp 27.500', + imageSrc: "https://user-images.githubusercontent.com/76729908/131646221-aaa1d48d-bb80-470f-9400-ae2aa47285b6.png", + quantity:2 + }, + ] \ No newline at end of file diff --git a/src/utils/funtion.utils.ts b/src/utils/funtion.utils.ts index b1e7b5536..619e9ae30 100644 --- a/src/utils/funtion.utils.ts +++ b/src/utils/funtion.utils.ts @@ -1,3 +1,11 @@ export function isMobile() { return window.innerWidth <= 768 +} + +export function removeItem(arr: Array, value: T): Array { + const index = arr.indexOf(value); + if (index > -1) { + arr.splice(index, 1); + } + return [...arr]; } \ No newline at end of file From c712d66fa57b98fb145cb6f48617f4b4c0472e54 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 10 Sep 2021 13:50:24 +0700 Subject: [PATCH 18/19] reponsive: checkout info --- .../CardItemCheckout.module.scss | 4 +- .../CheckoutBill/CheckoutBill.module.scss | 13 +++-- .../CheckoutInfo/CheckoutInfo.module.scss | 11 +++- .../checkout/CheckoutInfo/CheckoutInfo.tsx | 7 ++- .../CustomerInfoForm.module.scss | 4 +- .../PaymentInfoForm.module.scss | 4 +- .../ShippingInfoForm.module.scss | 4 +- .../CheckoutPage/CheckoutPage.module.scss | 52 +++++++++++++++++-- .../checkout/CheckoutPage/CheckoutPage.tsx | 25 +++++++-- 9 files changed, 108 insertions(+), 16 deletions(-) diff --git a/src/components/common/CardItemCheckout/CardItemCheckout.module.scss b/src/components/common/CardItemCheckout/CardItemCheckout.module.scss index c87b8efad..3617cb91f 100644 --- a/src/components/common/CardItemCheckout/CardItemCheckout.module.scss +++ b/src/components/common/CardItemCheckout/CardItemCheckout.module.scss @@ -1,8 +1,10 @@ .warpper{ - max-width: 49.9rem; max-height: 12rem; padding:1.6rem 0; @apply flex items-center; + @screen lg { + max-width: 49.9rem; + } .image{ width: 13.3rem; height: 8.8rem; diff --git a/src/components/modules/checkout/CheckoutBill/CheckoutBill.module.scss b/src/components/modules/checkout/CheckoutBill/CheckoutBill.module.scss index d47382780..403bdb76b 100644 --- a/src/components/modules/checkout/CheckoutBill/CheckoutBill.module.scss +++ b/src/components/modules/checkout/CheckoutBill/CheckoutBill.module.scss @@ -1,11 +1,18 @@ .warpper { - max-width: 56.3rem; - padding: 3.2rem; - @apply flex justify-between flex-col border-l-2 border-solid border-line; + padding: 3.2rem; + min-width: 100%; + @screen lg { + max-width: 56.3rem; + @apply flex justify-between flex-col border-l-2 border-solid border-line; + } .title { + display: none; font-weight: bold; font-size: 2rem; line-height: 2.8rem; + @screen md { + display: block; + } } .list { min-height: 52.8rem; diff --git a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss index 6f97371a8..cadf9f684 100644 --- a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss +++ b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.module.scss @@ -3,6 +3,15 @@ padding: 3.2rem; .title{ margin-bottom: 3.2rem; - @apply flex justify-start items-center + @apply flex justify-between items-center; + .viewCart{ + margin-right: 5.6rem; + @apply text-primary font-bold; + display: block; + cursor: pointer; + @screen lg { + display: none; + } + } } } \ No newline at end of file diff --git a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx index c989709e7..423f92635 100644 --- a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx +++ b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx @@ -7,9 +7,11 @@ import s from './CheckoutInfo.module.scss' import CustomerInfoForm from './components/CustomerInfoForm/CustomerInfoForm' import PaymentInfoForm from './components/PaymentInfoForm/PaymentInfoForm' import ShippingInfoForm from './components/ShippingInfoForm/ShippingInfoForm' -interface CheckoutInfoProps {} +interface CheckoutInfoProps { + onViewCart:()=>void +} -const CheckoutInfo = ({}: CheckoutInfoProps) => { +const CheckoutInfo = ({onViewCart}: CheckoutInfoProps) => { const [active, setActive] = useState(1) const [done, setDone] = useState([]) const [info, setInfo] = useState({}) @@ -69,6 +71,7 @@ const CheckoutInfo = ({}: CheckoutInfoProps) => {
    +
    View cart
    {formList.map((item) => { let note = getNote(item.id) diff --git a/src/components/modules/checkout/CheckoutInfo/components/CustomerInfoForm/CustomerInfoForm.module.scss b/src/components/modules/checkout/CheckoutInfo/components/CustomerInfoForm/CustomerInfoForm.module.scss index 8db473479..b0ecf8144 100644 --- a/src/components/modules/checkout/CheckoutInfo/components/CustomerInfoForm/CustomerInfoForm.module.scss +++ b/src/components/modules/checkout/CheckoutInfo/components/CustomerInfoForm/CustomerInfoForm.module.scss @@ -1,7 +1,9 @@ @import "../../../../../../styles/utilities"; .warpper{ @apply u-form; - padding: 0 5.6rem; + @screen md { + padding: 0 5.6rem; + } .bottom{ margin-top: 2.4rem; @apply flex justify-between items-center; diff --git a/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.module.scss b/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.module.scss index d70dcda16..15a70659c 100644 --- a/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.module.scss +++ b/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.module.scss @@ -1,5 +1,7 @@ .wrapper{ - padding: 0 5.6rem; + @screen md { + padding: 0 5.6rem; + } .inner{ padding: 4rem 0; } diff --git a/src/components/modules/checkout/CheckoutInfo/components/ShippingInfoForm/ShippingInfoForm.module.scss b/src/components/modules/checkout/CheckoutInfo/components/ShippingInfoForm/ShippingInfoForm.module.scss index 79057f7d4..c0c8b2795 100644 --- a/src/components/modules/checkout/CheckoutInfo/components/ShippingInfoForm/ShippingInfoForm.module.scss +++ b/src/components/modules/checkout/CheckoutInfo/components/ShippingInfoForm/ShippingInfoForm.module.scss @@ -2,7 +2,9 @@ .warpper{ @apply u-form; - padding: 0 5.6rem; + @screen md { + padding: 0 5.6rem; + } .bottom{ margin-top: 2.4rem; @apply flex justify-between items-center; diff --git a/src/components/modules/checkout/CheckoutPage/CheckoutPage.module.scss b/src/components/modules/checkout/CheckoutPage/CheckoutPage.module.scss index 2038507d7..1661f243c 100644 --- a/src/components/modules/checkout/CheckoutPage/CheckoutPage.module.scss +++ b/src/components/modules/checkout/CheckoutPage/CheckoutPage.module.scss @@ -1,10 +1,56 @@ +@import "../../../../styles/utilities"; .warrper{ @apply flex; .right{ - min-width: 56.3rem; + display: none; + @screen lg { + display: block; + min-width: 45rem; + } + @screen xl { + min-width: 56.3rem; + } } - .left{ + .left{ @apply w-full; - + } + .mobile{ + @apply hidden; + &.isShow{ + @apply block; + @screen lg { + @apply hidden; + } + } + .modal{ + background: rgba(0, 0, 0, 0.5); + position: fixed; + left: 0; + top: 0; + width: 100%; + height: 100%; + z-index: 10000; + .content{ + @apply spacing-horizontal; + margin-top: 3rem; + padding-top: 6.4rem ; + padding-bottom: 5rem; + background-color: white; + overflow: auto; + height: 100%; + border-radius: 2.4rem 2.4rem 0 0; + .head{ + @apply flex justify-between; + h3{ + @apply heading-3 font-bold; + color:var(--text-base); + } + } + button{ + margin-top: 2rem; + width: 100%; + } + } + } } } \ No newline at end of file diff --git a/src/components/modules/checkout/CheckoutPage/CheckoutPage.tsx b/src/components/modules/checkout/CheckoutPage/CheckoutPage.tsx index 5e2275f46..8cfcc31f3 100644 --- a/src/components/modules/checkout/CheckoutPage/CheckoutPage.tsx +++ b/src/components/modules/checkout/CheckoutPage/CheckoutPage.tsx @@ -1,16 +1,35 @@ -import React from 'react' +import classNames from 'classnames' +import React, { useState } from 'react' +import IconHide from 'src/components/icons/IconHide' import { CHECKOUT_BILL_DATA } from 'src/utils/demo-data' import { CheckoutBill, CheckoutInfo } from '..' import s from "./CheckoutPage.module.scss" interface CheckoutPageProps { - } const CheckoutPage = ({}: CheckoutPageProps) => { + const [isShow, setIsShow] = useState(false) + const onClose = () => { + setIsShow(false) + } + const onViewCart =() => { + setIsShow(true) + } return (
    -
    +
    +
    +
    +
    +
    +

    Your Cart({CHECKOUT_BILL_DATA.length})

    +
    +
    + +
    +
    +
    ) } From 53df72970812641f419d389a9f884a2c98693b12 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 10 Sep 2021 17:57:11 +0700 Subject: [PATCH 19/19] reponsive: product list page --- src/components/common/Layout/Layout.module.scss | 2 +- .../MenuNavigationProductList.module.scss | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/common/Layout/Layout.module.scss b/src/components/common/Layout/Layout.module.scss index d9649900a..30e4a077d 100644 --- a/src/components/common/Layout/Layout.module.scss +++ b/src/components/common/Layout/Layout.module.scss @@ -7,7 +7,7 @@ } } .filter{ - @screen md { + @screen xl { display: none; } } \ No newline at end of file diff --git a/src/components/common/MenuNavigationProductList/MenuNavigationProductList.module.scss b/src/components/common/MenuNavigationProductList/MenuNavigationProductList.module.scss index 3c05d840d..042785c05 100644 --- a/src/components/common/MenuNavigationProductList/MenuNavigationProductList.module.scss +++ b/src/components/common/MenuNavigationProductList/MenuNavigationProductList.module.scss @@ -1,8 +1,12 @@ @import "../../../styles/utilities"; .menuNavigationProductListDesktop{ - @screen sm-only { + @screen sm { @apply hidden; } + + @screen xl { + @apply block; + } } .menuNavigationProductListMobile{ @apply relative transition-all duration-100;