drawDB/src/components/EditorSidePanel/SidePanel.jsx

69 lines
2.1 KiB
React
Raw Normal View History

2023-09-19 20:47:50 +08:00
import { Tabs } 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-03-15 22:37:22 +08:00
{ tab: "Tables", itemKey: Tab.TABLES },
{ tab: "Relationships", itemKey: Tab.RELATIONSHIPS },
{ tab: "Subject Areas", itemKey: Tab.AREAS },
{ tab: "Notes", itemKey: Tab.NOTES },
{ tab: "Types", itemKey: Tab.TYPES },
2023-09-19 20:47:50 +08:00
];
2024-03-16 08:23:10 +08:00
2023-09-19 20:47:50 +08:00
const contentList = [
2024-04-06 09:58:42 +08:00
<TablesTab key="tables" />,
<RelationshipsTab key="relationships" />,
<AreasTab key="areas" />,
<NotesTab key="notes" />,
<TypesTab key="types" />,
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}
2023-09-19 20:49:14 +08:00
tabList={tabList}
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-03-14 02:39:16 +08:00
<div className="p-2">
{contentList[parseInt(selectedElement.currentTab) - 1]}
</div>
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
}