🎨 styles: drawer comon

:%s
This commit is contained in:
lytrankieio123
2021-09-06 14:10:55 +07:00
parent 7b5e7af8f9
commit 432c7b403c
7 changed files with 121 additions and 8 deletions

View File

@@ -1,6 +1,8 @@
import { CommerceProvider } from '@framework'
import { useRouter } from 'next/router'
import { FC } from 'react'
import { useModalCommon } from 'src/components/hooks'
import { DrawerCommon, ScrollToTop } from '..'
import Footer from '../Footer/Footer'
import Header from '../Header/Header'
import s from './Layout.module.scss'
@@ -13,12 +15,25 @@ interface Props {
// note: demo code
const Layout: FC<Props> = ({ children }) => {
const { locale = 'en-US' } = useRouter()
const { visible: visibleCartDrawer, openModal, closeModal: closeCartDrawer } = useModalCommon({ initialValue: true })
const toggle = () => {
if (visibleCartDrawer) {
closeCartDrawer()
} else {
openModal()
}
}
return (
<CommerceProvider locale={locale}>
<div className={s.mainLayout}>
<button onClick={toggle}>toggle card: {visibleCartDrawer.toString()}</button>
<Header />
<main >{children}</main>
<DrawerCommon
title="Cart"
visible={visibleCartDrawer}
onClose={closeCartDrawer} />
<Footer />
</div>
</CommerceProvider>