|
|
|
@ -0,0 +1,91 @@ |
|
|
|
|
import React, { useState } from "react"; |
|
|
|
|
|
|
|
|
|
import folder from "./images/folder.svg"; |
|
|
|
|
import selectedFolder from "./images/selectedFolder.svg"; |
|
|
|
|
|
|
|
|
|
import arrow from "./images/arrow.svg"; |
|
|
|
|
import selectedArrow from "./images/selectedArrow.svg"; |
|
|
|
|
|
|
|
|
|
const FolderTree = ({ items }) => { |
|
|
|
|
const [activeDropdown, setActiveDropdown] = useState(null); |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<div className="bg-white w-72 p-4 mx-auto"> |
|
|
|
|
{items.map((item, index) => ( |
|
|
|
|
<div> |
|
|
|
|
{/* level1 */} |
|
|
|
|
<div |
|
|
|
|
key={index} |
|
|
|
|
className="flex flex-row items-center mb-2 cursor-pointer" |
|
|
|
|
onClick={() => |
|
|
|
|
setActiveDropdown(activeDropdown === item ? null : item) |
|
|
|
|
} |
|
|
|
|
> |
|
|
|
|
{/* روش اول */} |
|
|
|
|
{/* {activeDropdown === item && <img src={item.normalArrow} />} |
|
|
|
|
{activeDropdown === null && <img src={item.icon} />} */} |
|
|
|
|
{/* روش دوم */} |
|
|
|
|
{activeDropdown === item ? ( |
|
|
|
|
<img src={selectedArrow} className="-rotate-90" /> |
|
|
|
|
) : ( |
|
|
|
|
<img src={arrow} /> |
|
|
|
|
)} |
|
|
|
|
{activeDropdown === item ? ( |
|
|
|
|
<img src={selectedFolder} /> |
|
|
|
|
) : ( |
|
|
|
|
<img src={folder} /> |
|
|
|
|
)} |
|
|
|
|
{/* {activeDropdown === null && <img src={folder} />} |
|
|
|
|
{activeDropdown === item && <img src={selectedFolder} />} */} |
|
|
|
|
<span className="text-sm mr-2" style={{ color: "#00253A" }}> |
|
|
|
|
{item.name} |
|
|
|
|
</span> |
|
|
|
|
</div> |
|
|
|
|
{item.menuItems.map((menuItem, i) => ( |
|
|
|
|
<div |
|
|
|
|
key={i} |
|
|
|
|
className="flex flex-row items-center mb-2 cursor-pointer mr-5" |
|
|
|
|
> |
|
|
|
|
<img src={arrow} /> |
|
|
|
|
<img src={folder} /> |
|
|
|
|
<span className="text-sm mr-2" style={{ color: "#00253A" }}> |
|
|
|
|
{menuItem.title} |
|
|
|
|
</span> |
|
|
|
|
</div> |
|
|
|
|
))} |
|
|
|
|
</div> |
|
|
|
|
))} |
|
|
|
|
</div> |
|
|
|
|
); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export default FolderTree; |
|
|
|
|
|
|
|
|
|
FolderTree.defaultProps = { |
|
|
|
|
items: [ |
|
|
|
|
{ |
|
|
|
|
name: "فیلمها وعکس مربوط به حادثه", |
|
|
|
|
menuItems: [ |
|
|
|
|
{ title: "فایلهای مربوط به پارسال" }, |
|
|
|
|
{ title: "اخبار و گزارشات سال 1399" }, |
|
|
|
|
{ title: "فایلهای مربوط به پارسال" }, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "فرایندهای بازرسی", |
|
|
|
|
menuItems: [], |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "صوت جلسات استاد براتی", |
|
|
|
|
menuItems: [], |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "رویشه اصلی سایت", |
|
|
|
|
menuItems: [], |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: "فرایندهای بازرسی", |
|
|
|
|
menuItems: [], |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}; |