drawDB/src/components/SidePanel.jsx

70 lines
2.0 KiB
React
Raw Normal View History

2023-12-16 11:39:13 +08:00
import { useContext } from "react";
2023-09-19 20:47:50 +08:00
import { Tabs } from "@douyinfe/semi-ui";
import TableOverview from "./TableOverview";
import ReferenceOverview from "./ReferenceOverview";
import AreaOverview from "./AreaOverview";
2023-09-19 20:48:57 +08:00
import { Tab } from "../data/data";
2024-03-10 01:42:09 +08:00
import { TabContext } from "../pages/Editor";
import NotesOverview from "./NotesOverview";
import Issues from "./Issues";
import TypesOverview from "./TypesOverview";
2024-03-10 01:42:09 +08:00
import useLayout from "../hooks/useLayout";
2023-09-19 20:47:01 +08:00
const SidePanel = (props) => {
2023-09-19 20:49:13 +08:00
const { tab, setTab } = useContext(TabContext);
2024-03-10 01:42:09 +08:00
const { layout } = useLayout();
2023-09-19 20:47:01 +08:00
2023-09-19 20:47:50 +08:00
const tabList = [
2023-09-19 20:48:57 +08:00
{ tab: "Tables", itemKey: Tab.tables },
{ tab: "Relationships", itemKey: Tab.relationships },
{ tab: "Subject Areas", itemKey: Tab.subject_areas },
2023-09-19 20:49:09 +08:00
{ tab: "Notes", itemKey: Tab.notes },
2023-09-19 20:51:28 +08:00
{ tab: "Types", itemKey: Tab.types },
2023-09-19 20:47:50 +08:00
];
const contentList = [
2023-12-16 11:39:13 +08:00
<TableOverview key={1}/>,
<ReferenceOverview key={2}/>,
<AreaOverview key={3}/>,
<NotesOverview key={4}/>,
<TypesOverview key={5}/>,
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"
2023-09-19 20:49:14 +08:00
style={{ width: `${props.width}px` }}
>
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"
activeKey={tab}
tabList={tabList}
onChange={(key) => {
setTab(key);
}}
collapsible
>
<div className="p-2">{contentList[parseInt(tab) - 1]}</div>
</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 ${
props.resize ? "bg-semi-grey-2" : ""
2023-09-19 20:48:32 +08:00
}`}
2023-09-19 20:48:30 +08:00
onMouseDown={() => props.setResize(true)}
>
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
);
2023-09-19 20:48:14 +08:00
};
2023-09-19 20:48:13 +08:00
export default SidePanel;