parent
40256c162a
commit
be5c38ce5d
43 changed files with 359 additions and 420 deletions
@ -1,135 +1,126 @@ |
|||||||
|
|
||||||
import React from "react"; |
import React from "react"; |
||||||
import { useState } from "react"; |
import { useState } from "react"; |
||||||
|
|
||||||
const ProductDescription = ({ |
const ProductDescription = ({ navTitles, items, addToCart }) => { |
||||||
navTitles, |
|
||||||
items, |
|
||||||
addToCart |
|
||||||
}) =>{ |
|
||||||
const [name, setName] = useState(navTitles[0].name); |
const [name, setName] = useState(navTitles[0].name); |
||||||
const [type, setType] = useState([]); |
const [type, setType] = useState([]); |
||||||
return ( |
return ( |
||||||
<> |
<> |
||||||
<div className="flex w-full rounded bg-gray-200 justify-center mt-6 "> |
<div className="flex w-full rounded bg-gray-200 justify-center mt-6 "> |
||||||
<ul className="w-full flex justify-center"> |
<ul className="w-full flex justify-center"> |
||||||
{navTitles.map(item => <li key={`NavTitle_${item.id}`}
|
{navTitles.map((item, index) => ( |
||||||
|
<li |
||||||
|
key={index} |
||||||
className={`p-6 mx-4 cursor-pointer
|
className={`p-6 mx-4 cursor-pointer
|
||||||
${type[item.id] ? 'border-0 border-b-4 border-solid border-blue-500' : null}` |
${ |
||||||
}
|
type[item.id] |
||||||
|
? "border-0 border-b-4 border-solid border-blue-500" |
||||||
|
: null |
||||||
|
}`}
|
||||||
onClick={() => { |
onClick={() => { |
||||||
// type[item.id] = type
|
setName(item.name); |
||||||
// type[item.id] = !type[item.id]
|
}} |
||||||
setName(item.name) |
> |
||||||
// setType(type)
|
{item.title} |
||||||
// console.log(type)
|
</li> |
||||||
// console.log(item.id)
|
))} |
||||||
// console.log(type[item.id])
|
|
||||||
|
|
||||||
}}> |
|
||||||
{item.title}</li>)} |
|
||||||
</ul> |
</ul> |
||||||
</div> |
</div> |
||||||
<div className="flex w-full "> |
<div className="flex w-full "> |
||||||
<div className="flex-1 "> |
<div className="flex-1 "> |
||||||
|
{items.map((item, index) => |
||||||
{items.map(e => (
|
item.name == name |
||||||
e.name == name ? |
? item.items.map((item, index) => ( |
||||||
e.items.map(item => ( |
<ul className="flex w-full flex-1 my-2 items-center" key={index}> |
||||||
<ul className="flex w-full flex-1 my-2 items-center"> |
{item.title ? ( |
||||||
|
<li |
||||||
{item.title ?
|
className="py-4 px-8 min-w-md bg-gray-200 ml-4 text-blueC0" |
||||||
<li className="py-4 px-8 min-w-md bg-gray-200 ml-4 text-blueC0" style={{minWidth: '300px'}}>{item.title}</li> : null} |
style={{ minWidth: "300px" }} |
||||||
<li className="py-4 px-8 min-w-md bg-gray-200 ml-4 w-full">{item.description}</li> |
> |
||||||
|
{item.title} |
||||||
|
</li> |
||||||
|
) : null} |
||||||
|
<li className="py-4 px-8 min-w-md bg-gray-200 ml-4 w-full"> |
||||||
|
{item.description} |
||||||
|
</li> |
||||||
</ul> |
</ul> |
||||||
|
)) |
||||||
)) : null |
: null |
||||||
|
)} |
||||||
|
|
||||||
))}
|
|
||||||
</div> |
</div> |
||||||
<div className="my-2"> |
<div className="my-2">{addToCart}</div> |
||||||
{addToCart} |
|
||||||
</div> |
|
||||||
|
|
||||||
</div> |
</div> |
||||||
</> |
</> |
||||||
); |
); |
||||||
}; |
}; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default ProductDescription; |
export default ProductDescription; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ProductDescription.defaultProps = { |
ProductDescription.defaultProps = { |
||||||
navTitles: [ |
navTitles: [ |
||||||
{ |
{ |
||||||
id: 0, |
id: 0, |
||||||
title: 'مشخصات', |
title: "مشخصات", |
||||||
isActive: true, |
isActive: true, |
||||||
name: 'moshakhasat' |
name: "moshakhasat", |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
id: 1, |
id: 1, |
||||||
title: 'نقد و بررسی', |
title: "نقد و بررسی", |
||||||
isActive: false, |
isActive: false, |
||||||
name: 'review' |
name: "review", |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
id: 2, |
id: 2, |
||||||
title: 'برسش و باسخ', |
title: "برسش و باسخ", |
||||||
isActive:false |
isActive: false, |
||||||
}, |
}, |
||||||
], |
], |
||||||
items: [ |
items: [ |
||||||
{ |
{ |
||||||
name: 'moshakhasat', |
name: "moshakhasat", |
||||||
items: [ |
items: [ |
||||||
{ |
{ |
||||||
title : 'وزن کتاب', |
title: "وزن کتاب", |
||||||
description: '۱ کیلوگرم' |
description: "۱ کیلوگرم", |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
title : 'تعداد صفحات', |
title: "تعداد صفحات", |
||||||
description: '400 صفحه' |
description: "400 صفحه", |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
title : 'نوع کاغذ', |
title: "نوع کاغذ", |
||||||
description: 'گلاسه' |
description: "گلاسه", |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
title : 'شماره شابک', |
title: "شماره شابک", |
||||||
description: '1225548218000005818765' |
description: "1225548218000005818765", |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
title : 'انتشارات', |
title: "انتشارات", |
||||||
description: 'رزمندگان' |
description: "رزمندگان", |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
title : 'نویسنده و یا معلف', |
title: "نویسنده و یا معلف", |
||||||
description: 'یک نویسنده گمنام' |
description: "یک نویسنده گمنام", |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
title : 'قطع', |
title: "قطع", |
||||||
description: 'خشتی' |
description: "خشتی", |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
title : 'سال انتشار', |
title: "سال انتشار", |
||||||
description: '1399' |
description: "1399", |
||||||
}, |
}, |
||||||
] |
], |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
name: 'review', |
name: "review", |
||||||
items: [{ |
items: [ |
||||||
description: 'لورم ایبسوم' |
{ |
||||||
}] |
description: "لورم ایبسوم", |
||||||
} |
}, |
||||||
] |
], |
||||||
|
}, |
||||||
} |
], |
||||||
|
}; |
||||||
|
Loading…
Reference in new issue