2024-05-13 11:14:51 +08:00
|
|
|
import { Tabs, TabPane } from "@douyinfe/semi-ui";
|
2024-04-02 00:44:50 +08:00
|
|
|
import { Tab } from "../../data/constants";
|
2024-04-05 10:12:50 +08:00
|
|
|
import { useLayout, useSelect } from "../../hooks";
|
2024-04-06 09:58:42 +08:00
|
|
|
import RelationshipsTab from "./RelationshipsTab/RelationshipsTab";
|
|
|
|
import TypesTab from "./TypesTab/TypesTab";
|
|
|
|
import Issues from "./Issues";
|
|
|
|
import AreasTab from "./AreasTab/AreasTab";
|
|
|
|
import NotesTab from "./NotesTab/NotesTab";
|
|
|
|
import TablesTab from "./TablesTab/TablesTab";
|
2023-09-19 20:47:01 +08:00
|
|
|
|
2024-03-14 02:39:16 +08:00
|
|
|
export default function SidePanel({ width, resize, setResize }) {
|
2024-03-10 01:42:09 +08:00
|
|
|
const { layout } = useLayout();
|
2024-03-14 02:39:16 +08:00
|
|
|
const { selectedElement, setSelectedElement } = useSelect();
|
2023-09-19 20:47:01 +08:00
|
|
|
|
2023-09-19 20:47:50 +08:00
|
|
|
const tabList = [
|
2024-05-13 11:14:51 +08:00
|
|
|
{ tab: "Tables", itemKey: Tab.TABLES, component: <TablesTab /> },
|
|
|
|
{ tab: "Relationships", itemKey: Tab.RELATIONSHIPS, component: <RelationshipsTab /> },
|
|
|
|
{ tab: "Subject Areas", itemKey: Tab.AREAS, component: <AreasTab /> },
|
|
|
|
{ tab: "Notes", itemKey: Tab.NOTES, component: <NotesTab /> },
|
|
|
|
{ tab: "Types", itemKey: Tab.TYPES, component: <TypesTab /> },
|
2023-09-19 20:47:50 +08:00
|
|
|
];
|
|
|
|
|
2023-09-19 20:47:01 +08:00
|
|
|
return (
|
2023-09-19 20:48:38 +08:00
|
|
|
<div className="flex h-full">
|
2023-09-19 20:49:14 +08:00
|
|
|
<div
|
2023-09-19 20:51:08 +08:00
|
|
|
className="flex flex-col h-full relative border-r border-color"
|
2024-03-14 02:39:16 +08:00
|
|
|
style={{ width: `${width}px` }}
|
2023-09-19 20:49:14 +08:00
|
|
|
>
|
2023-09-19 20:49:13 +08:00
|
|
|
<div className="h-full flex-1 overflow-y-auto">
|
2023-09-19 20:49:14 +08:00
|
|
|
<Tabs
|
|
|
|
type="card"
|
2024-03-14 02:39:16 +08:00
|
|
|
activeKey={selectedElement.currentTab}
|
2024-05-13 11:14:51 +08:00
|
|
|
lazyRender
|
2024-03-14 02:39:16 +08:00
|
|
|
onChange={(key) =>
|
|
|
|
setSelectedElement((prev) => ({ ...prev, currentTab: key }))
|
|
|
|
}
|
2023-09-19 20:49:14 +08:00
|
|
|
collapsible
|
|
|
|
>
|
2024-05-13 11:14:51 +08:00
|
|
|
{tabList.length && tabList.map(tab =>
|
|
|
|
<TabPane tab={tab.tab} itemKey={tab.itemKey} key={tab.itemKey}>
|
|
|
|
<div className="p-2">
|
|
|
|
{tab.component}
|
|
|
|
</div>
|
|
|
|
</TabPane>
|
|
|
|
)}
|
2023-09-19 20:49:14 +08:00
|
|
|
</Tabs>
|
2023-09-19 20:49:13 +08:00
|
|
|
</div>
|
2023-09-19 20:49:14 +08:00
|
|
|
{layout.issues && (
|
2023-09-19 20:51:08 +08:00
|
|
|
<div className="mt-auto border-t-2 border-color shadow-inner">
|
2023-09-19 20:49:14 +08:00
|
|
|
<Issues />
|
|
|
|
</div>
|
|
|
|
)}
|
2023-09-19 20:47:01 +08:00
|
|
|
</div>
|
2023-09-19 20:48:30 +08:00
|
|
|
<div
|
2023-09-19 20:51:08 +08:00
|
|
|
className={`flex justify-center items-center p-1 h-auto hover-2 cursor-col-resize ${
|
2024-03-16 08:23:10 +08:00
|
|
|
resize && "bg-semi-grey-2"
|
2023-09-19 20:48:32 +08:00
|
|
|
}`}
|
2024-03-14 02:39:16 +08:00
|
|
|
onMouseDown={() => setResize(true)}
|
2023-09-19 20:48:30 +08:00
|
|
|
>
|
2023-09-19 20:51:08 +08:00
|
|
|
<div className="w-1 border-x border-color h-1/6" />
|
2023-09-19 20:48:30 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-09-19 20:47:01 +08:00
|
|
|
);
|
2024-03-14 02:39:16 +08:00
|
|
|
}
|