feat: BlogsList

This commit is contained in:
unknown
2021-09-02 19:36:11 +07:00
parent 199517caa6
commit 8588245128
8 changed files with 178 additions and 5 deletions

View File

@@ -17,9 +17,9 @@ const Layout: FC<Props> = ({ children }) => {
return (
<CommerceProvider locale={locale}>
<div className={s.mainLayout}>
{/* <Header /> */}
<Header />
<main >{children}</main>
{/* <Footer /> */}
<Footer />
</div>
</CommerceProvider>

View File

@@ -0,0 +1,15 @@
@import "../../../../styles/utilities";
.wrapper{
@apply flex flex-col spacing-horizontal;
.list{
@apply flex flex-wrap flex justify-around;
}
.card{
padding-bottom: 4rem;
}
.pagination{
padding-top: 0.8rem;
@apply flex justify-center items-center ;
}
}

View File

@@ -0,0 +1,37 @@
import React, { useState } from 'react'
import CardBlog, { BlogCardProps } from 'src/components/common/CardBlog/CardBlog'
import PaginationCommon from 'src/components/common/PaginationCommon/PaginationCommon'
import s from "./BlogsList.module.scss"
interface BlogsListProps {
data: BlogCardProps[],
}
const BlogsList = ({ data }:BlogsListProps) => {
const [currentPage, setCurrentPage] = useState(0)
const onPageChange = (page:number) => {
setCurrentPage(page)
}
return (
<section>
<div className={s.wrapper}>
<div className={s.list}>
{
data.slice(currentPage*6,(currentPage+1)*6).map((product,index)=>{
return(
<div className={s.card}>
<CardBlog {...product} key={index}/>
</div>
)
})
}
</div>
<div className={s.pagination}>
<PaginationCommon total={data.length} pageSize={6} onChange={onPageChange}/>
</div>
</div>
</section>
)
}
export default BlogsList

View File

@@ -1 +1,2 @@
export { default as FeaturedCardBlog } from './FeaturedCardBlog/FeaturedCardBlog'
export { default as FeaturedCardBlog } from './FeaturedCardBlog/FeaturedCardBlog'
export { default as BlogsList } from './BlogsList/BlogsList'