drawDB/src/components/editor_panel.jsx

66 lines
1.9 KiB
React
Raw Normal View History

2023-09-19 20:48:57 +08:00
import { React, useContext } from "react";
2023-09-19 20:47:50 +08:00
import { Tabs } from "@douyinfe/semi-ui";
import TableOverview from "./table_overview";
import ReferenceOverview from "./reference_overview";
2023-09-19 20:48:55 +08:00
import AreaOverview from "./area_overview";
2023-09-19 20:48:57 +08:00
import { Tab } from "../data/data";
2023-09-19 20:49:14 +08:00
import { LayoutContext, TabContext } from "../pages/editor";
2023-09-19 20:49:09 +08:00
import NotesOverview from "./notes_overview";
2023-09-19 20:49:13 +08:00
import Issues from "./issues";
2023-09-19 20:47:01 +08:00
2023-09-19 20:48:14 +08:00
const EditorPanel = (props) => {
2023-09-19 20:49:13 +08:00
const { tab, setTab } = useContext(TabContext);
2023-09-19 20:49:14 +08:00
const { layout } = useContext(LayoutContext);
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:47:50 +08:00
];
const contentList = [
2023-09-19 20:50:28 +08:00
<TableOverview />,
2023-09-19 20:48:53 +08:00
<ReferenceOverview />,
2023-09-19 20:49:13 +08:00
<AreaOverview />,
<NotesOverview />,
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 EditorPanel;