diff --git a/src/components/area.jsx b/src/components/area.jsx index ca9bd6d..0cf4d6c 100644 --- a/src/components/area.jsx +++ b/src/components/area.jsx @@ -4,7 +4,7 @@ export default function Area(props) { const [hovered, setHovered] = useState(false); const handleMouseDown = (e, dir) => { - props.setResize({id: props.areaData.id, dir: dir}); + props.setResize({ id: props.areaData.id, dir: dir }); props.setInitCoords({ x: props.areaData.x, y: props.areaData.y, @@ -28,53 +28,61 @@ export default function Area(props) { height={props.areaData.height > 0 ? props.areaData.height : 0} onMouseDown={props.onMouseDown} > -
+
+
+
+
{props.areaData.name}
{hovered && ( <> - handleMouseDown(e, "tl")} /> - handleMouseDown(e, "tr")} /> - handleMouseDown(e, "bl")} /> - handleMouseDown(e, "br")} /> diff --git a/src/components/area_overview.jsx b/src/components/area_overview.jsx new file mode 100644 index 0000000..9cfc540 --- /dev/null +++ b/src/components/area_overview.jsx @@ -0,0 +1,225 @@ +import React, { useContext, useState } from "react"; +import { + Empty, + Row, + Col, + AutoComplete, + Button, + Input, + Popover, + Toast, +} from "@douyinfe/semi-ui"; +import { + IllustrationNoContent, + IllustrationNoContentDark, +} from "@douyinfe/semi-illustrations"; +import { + IconPlus, + IconSearch, + IconCheckboxTick, + IconDeleteStroked, +} from "@douyinfe/semi-icons"; +import { defaultTableTheme, tableThemes } from "../data/data"; +import { AreaContext } from "../pages/editor"; + +export default function AreaOverview(props) { + const { areas, setAreas } = useContext(AreaContext); + + const [value, setValue] = useState(""); + const [filteredResult, setFilteredResult] = useState( + areas.map((t) => { + return t.name; + }) + ); + + const handleStringSearch = (value) => { + setFilteredResult( + areas + .map((t) => { + return t.name; + }) + .filter((i) => i.includes(value)) + ); + }; + + const updateArea = (aid, updatedValues) => { + setAreas((prev) => + prev.map((a, i) => { + if (aid === i) { + return { + ...a, + ...updatedValues, + }; + } + return a; + }) + ); + }; + + return ( +
+ + + } + placeholder="Search..." + emptyContent={
No areas found
} + onSearch={(v) => handleStringSearch(v)} + onChange={(v) => setValue(v)} + onSelect={(v) => { + const { id } = areas.find((t) => t.name === v); + document + .getElementById(`scroll_area_${id}`) + .scrollIntoView({ behavior: "smooth" }); + }} + className="w-full" + /> + + + + +
+ {areas.length <= 0 ? ( +
+ + } + darkModeImage={ + + } + title="No subject areas" + description="Add subject areas to compartmentalize tables!" + /> +
+ ) : ( +
+ {areas.map((a, i) => ( + + + updateArea(a.id, { name: value })} + field="name" + /> + + + +
+
Theme
+ +
+
+
+
+ {tableThemes + .slice(0, Math.ceil(tableThemes.length / 2)) + .map((c) => ( + + ))} +
+
+ {tableThemes + .slice(Math.ceil(tableThemes.length / 2)) + .map((c) => ( + + ))} +
+
+
+ } + trigger="click" + position="bottomLeft" + showArrow + > +
+ + + + + + + ))} +
+ )} +
+ ); +} diff --git a/src/components/control_panel.jsx b/src/components/control_panel.jsx index 886f511..2efeb06 100644 --- a/src/components/control_panel.jsx +++ b/src/components/control_panel.jsx @@ -590,6 +590,23 @@ export default function ControlPanel(props) { > Issues + + ) : ( +
+ ) + } + onClick={() => + setLayout((prev) => ({ + ...prev, + areas: !prev.areas, + })) + } + > + Subject areas +
{ const [tab, setTab] = useState("1"); // const map = useRef(new Map()); // const {tables, setTables} = useContext(TableContext); - const { areas, setAreas } = useContext(AreaContext); const tabList = [ { tab: "Tables", itemKey: "1" }, { tab: "Relationships", itemKey: "2" }, - { tab: "Shapes", itemKey: "3" }, - { tab: "Editor", itemKey: "4" }, + { tab: "Subject Areas", itemKey: "3" }, + { tab: "Shapes", itemKey: "4" }, + { tab: "Editor", itemKey: "5" }, ]; const contentList = [ { setSelectedTable={props.setSelectedTable} />, , + , , { >
{contentList[parseInt(tab) - 1]}
-
} position="rightTop" diff --git a/src/pages/editor.jsx b/src/pages/editor.jsx index a677cc0..283fc76 100644 --- a/src/pages/editor.jsx +++ b/src/pages/editor.jsx @@ -23,6 +23,7 @@ export default function Editor(props) { sidebar: true, services: true, tables: true, + areas: true, relationships: true, issues: true, editor: true,