diff --git a/pages/test.tsx b/pages/test.tsx index 7fb1f9294..b7298a091 100644 --- a/pages/test.tsx +++ b/pages/test.tsx @@ -1,17 +1,12 @@ 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 TabPane from 'src/components/common/TabCommon/components/TabPane/TabPane' +import TabCommon from 'src/components/common/TabCommon/TabCommon' 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' import image8 from '../public/assets/images/image8.png' const dataTest:CardItemCheckoutProps[] = [ @@ -43,27 +38,34 @@ const dataTest:CardItemCheckoutProps[] = [ quantity:2 }, ] + export default function Test() { - const [visible, setVisible] = useState(false) - const onClose = () => { - setVisible(false) - } - const onOpen = () => { - setVisible(true) - } - const [visible2, setVisible2] = useState(false) - const onClose2 = () => { - setVisible2(false) - } - const onOpen2 = () => { - setVisible2(true) - } return ( <>
+ + +
+ 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/PaymentInfoForm/PaymentInfoForm.tsx b/src/components/common/PaymentInfoForm/PaymentInfoForm.tsx deleted file mode 100644 index 6ba65dc43..000000000 --- a/src/components/common/PaymentInfoForm/PaymentInfoForm.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react' -import TabCommon from 'src/components/common/TabCommon/TabCommon' - -interface PaymentInfoFormProps { - -} - -const PaymentInfoForm = ({}: PaymentInfoFormProps) => { - return ( -
-
- ) -} - -export default PaymentInfoForm 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}
    diff --git a/src/components/common/index.ts b/src/components/common/index.ts index 8d5a44b73..a7b9075d3 100644 --- a/src/components/common/index.ts +++ b/src/components/common/index.ts @@ -37,9 +37,6 @@ 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' 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/modules/checkout/CheckoutInfo/CheckoutInfo.tsx b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx index 3b4c64838..16852ea43 100644 --- a/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx +++ b/src/components/modules/checkout/CheckoutInfo/CheckoutInfo.tsx @@ -1,8 +1,10 @@ import React, { useState } from 'react' -import { CustomerInfoForm, Logo, ShippingInfoForm } from 'src/components/common' +import { Logo } 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' +import CustomerInfoForm from './components/CustomerInfoForm/CustomerInfoForm' +import ShippingInfoForm from './components/ShippingInfoForm/ShippingInfoForm' interface CheckoutInfoProps {} const CheckoutInfo = ({}: CheckoutInfoProps) => { diff --git a/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.module.scss b/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.module.scss new file mode 100644 index 000000000..e7d6e3573 --- /dev/null +++ b/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.module.scss @@ -0,0 +1,9 @@ +.warpper{ + .title{ + 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 new file mode 100644 index 000000000..463711618 --- /dev/null +++ b/src/components/modules/checkout/CheckoutInfo/components/BankTransfer/BankTransfer.tsx @@ -0,0 +1,24 @@ +import React from 'react' +import s from './BankTransfer.module.scss' +interface BankTransferProps {} + +const BankTransfer = ({}: BankTransferProps) => { + return ( +
    +
    +
    Account Name:
    +
    Duong Dinh Vu
    +
    +
    +
    Account Number:
    +
    1234 1234 1234 1234
    +
    +
    +
    Bank Name:
    +
    Techcombank - HCMC
    +
    +
    + ) +} + +export default BankTransfer diff --git a/src/components/common/CustomerInfoForm/CustomerInfoForm.module.scss b/src/components/modules/checkout/CheckoutInfo/components/CustomerInfoForm/CustomerInfoForm.module.scss similarity index 83% rename from src/components/common/CustomerInfoForm/CustomerInfoForm.module.scss rename to src/components/modules/checkout/CheckoutInfo/components/CustomerInfoForm/CustomerInfoForm.module.scss index f31bc57b0..8db473479 100644 --- a/src/components/common/CustomerInfoForm/CustomerInfoForm.module.scss +++ b/src/components/modules/checkout/CheckoutInfo/components/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/common/CustomerInfoForm/CustomerInfoForm.tsx b/src/components/modules/checkout/CheckoutInfo/components/CustomerInfoForm/CustomerInfoForm.tsx similarity index 100% rename from src/components/common/CustomerInfoForm/CustomerInfoForm.tsx rename to src/components/modules/checkout/CheckoutInfo/components/CustomerInfoForm/CustomerInfoForm.tsx diff --git a/src/components/common/PaymentInfoForm/PaymentInfoForm.module.scss b/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.module.scss similarity index 100% rename from src/components/common/PaymentInfoForm/PaymentInfoForm.module.scss rename to src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.module.scss diff --git a/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.tsx b/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.tsx new file mode 100644 index 000000000..a947faa8b --- /dev/null +++ b/src/components/modules/checkout/CheckoutInfo/components/PaymentInfoForm/PaymentInfoForm.tsx @@ -0,0 +1,21 @@ +import React from 'react' +import TabPane from 'src/components/common/TabCommon/components/TabPane/TabPane' +import TabCommon from 'src/components/common/TabCommon/TabCommon' +import s from "./PaymentInfoForm.module.scss" +interface PaymentInfoFormProps { + +} + +const PaymentInfoForm = ({}: PaymentInfoFormProps) => { + return ( +
    + + {/* + + */} + +
    + ) +} + +export default PaymentInfoForm diff --git a/src/components/common/ShippingInfoForm/ShippingInfoForm.module.scss b/src/components/modules/checkout/CheckoutInfo/components/ShippingInfoForm/ShippingInfoForm.module.scss similarity index 94% rename from src/components/common/ShippingInfoForm/ShippingInfoForm.module.scss rename to src/components/modules/checkout/CheckoutInfo/components/ShippingInfoForm/ShippingInfoForm.module.scss index acda6bc56..79057f7d4 100644 --- a/src/components/common/ShippingInfoForm/ShippingInfoForm.module.scss +++ b/src/components/modules/checkout/CheckoutInfo/components/ShippingInfoForm/ShippingInfoForm.module.scss @@ -1,4 +1,4 @@ -@import "../../../styles/utilities"; +@import "../../../../../../styles/utilities"; .warpper{ @apply u-form; diff --git a/src/components/common/ShippingInfoForm/ShippingInfoForm.tsx b/src/components/modules/checkout/CheckoutInfo/components/ShippingInfoForm/ShippingInfoForm.tsx similarity index 100% rename from src/components/common/ShippingInfoForm/ShippingInfoForm.tsx rename to src/components/modules/checkout/CheckoutInfo/components/ShippingInfoForm/ShippingInfoForm.tsx