parent
f23606f397
commit
3901190c58
5 changed files with 109 additions and 12 deletions
@ -0,0 +1,51 @@ |
||||
import React, { useState } from "react"; |
||||
import Table from "./table"; |
||||
|
||||
const ProductTab = ({ tabs }) => { |
||||
const [selectedTab, setSelectedTab] = useState(null); |
||||
|
||||
return ( |
||||
<section className="m-10"> |
||||
<div className="rounded bg-white"> |
||||
<ul className="flex flex-row"> |
||||
{tabs.map((tab, index) => ( |
||||
<li |
||||
className={`text-sm m-4 cursor-pointer hover:border-b-2 leading-7 hover:text-blue-600 ${ |
||||
selectedTab === tab ? "text-blue-600" : "" |
||||
}`}
|
||||
onClick={() => setSelectedTab(tab)} |
||||
key={index} |
||||
> |
||||
{tab.title} |
||||
</li> |
||||
))} |
||||
</ul> |
||||
</div> |
||||
<div className={`rounded w-full flex items-center ${selectedTab?.bg}`}> |
||||
{selectedTab?.components} |
||||
</div> |
||||
</section> |
||||
); |
||||
}; |
||||
|
||||
export default ProductTab; |
||||
|
||||
ProductTab.defaultProps = { |
||||
tabs: [ |
||||
{ |
||||
title: "مشخصات", |
||||
components: <Table />, |
||||
bg: "bg-transparent", |
||||
}, |
||||
{ |
||||
title: "پرسش", |
||||
components: "نقد و بررسی", |
||||
bg: "bg-blue-500", |
||||
}, |
||||
{ |
||||
title: "سوال", |
||||
components: "پرسش و پاسخ", |
||||
bg: "bg-yellow-500", |
||||
}, |
||||
], |
||||
}; |
@ -0,0 +1,44 @@ |
||||
import React from "react"; |
||||
|
||||
const persian = { |
||||
weight: "وزن", |
||||
pageNumber: "تعداد صفحات", |
||||
pageType: "نوع کاغذ", |
||||
bookNumber: "شماره شابک", |
||||
publisher: "انتشارات", |
||||
author: "نویسنده", |
||||
bookType: "قطع", |
||||
publishedYear: "سال انتشار", |
||||
}; |
||||
|
||||
const Table = ({ specifications }) => { |
||||
return ( |
||||
<ul className="w-full"> |
||||
{Object.keys(specifications).map((specification, index) => ( |
||||
<li className="flex my-3"> |
||||
<div className="bg-white rounded p-3 ml-2" style={{ flex: 2 }}> |
||||
{persian[specification]} |
||||
</div> |
||||
<div className="bg-white rounded p-3" style={{ flex: 8 }}> |
||||
{specifications[specification]} |
||||
</div> |
||||
</li> |
||||
))} |
||||
</ul> |
||||
); |
||||
}; |
||||
|
||||
export default Table; |
||||
|
||||
Table.defaultProps = { |
||||
specifications: { |
||||
weight: "1 کیلوگرم", |
||||
pageNumber: "400 صفحه", |
||||
pageType: "گلاسه", |
||||
bookNumber: "124900985340561870112312499", |
||||
publisher: "رزمندگان", |
||||
author: "یک نویسنده گمنام", |
||||
bookType: "خشتی", |
||||
publishedYear: "1399", |
||||
}, |
||||
}; |
Loading…
Reference in new issue