From ddaeec79ec73c12b494cd23c91c33c21f78f7bd9 Mon Sep 17 00:00:00 2001 From: 1ilit Date: Tue, 19 Sep 2023 15:48:25 +0300 Subject: [PATCH] functional navbar yey --- src/components/canvas.jsx | 10 +- src/components/control_panel.jsx | 30 ++-- src/components/editor_panel.jsx | 31 ++++- src/data/data.js | 230 +++++++++++++++++++++++++------ 4 files changed, 242 insertions(+), 59 deletions(-) diff --git a/src/components/canvas.jsx b/src/components/canvas.jsx index 911d8f7..bb1f111 100644 --- a/src/components/canvas.jsx +++ b/src/components/canvas.jsx @@ -241,8 +241,12 @@ export default function Canvas(props) { onMouseMove={handleMouseMove} onMouseDown={handleMouseDown} onMouseUp={handleMouseUp} - style={{ width: "100%", height: "100%", cursor: cursor, backgroundColor:"white" }} - + style={{ + width: "100%", + height: "100%", + cursor: cursor, + backgroundColor: "white", + }} > {Object.keys(menu[category]).map((item, index) => { - if (menu[category][item].length > 0) { + if (menu[category][item].children.length > 0) { return ( - {menu[category][item].map((e) => ( - -
{e}
-
- ))} + {menu[category][item].children.map( + (e, i) => ( + + + + ) + )} } > @@ -65,14 +71,22 @@ export default function ControlPanel() { alignItems: "center", }} > -
{item}
+
); } return ( - {item} + + + ); })} diff --git a/src/components/editor_panel.jsx b/src/components/editor_panel.jsx index a8e0220..b63bc9e 100644 --- a/src/components/editor_panel.jsx +++ b/src/components/editor_panel.jsx @@ -5,7 +5,7 @@ import { createTheme } from "@uiw/codemirror-themes"; import { sql } from "@codemirror/lang-sql"; import { tags as t } from "@lezer/highlight"; import Shape from "./shape"; -import { saveAs } from "file-saver"; +// import { saveAs } from "file-saver"; import { toPng } from "html-to-image"; import { Parser } from "node-sql-parser"; import { Tabs } from "@douyinfe/semi-ui"; @@ -13,6 +13,7 @@ import "react-resizable/css/styles.css"; import TableOverview from "./table_overview"; import ReferenceOverview from "./reference_overview"; import { defaultTableTheme } from "../data/data"; +import { ImagePreview, Image } from "@douyinfe/semi-ui"; const myTheme = createTheme({ dark: "light", @@ -32,6 +33,13 @@ const EditorPanel = (props) => { const [tab, setTab] = useState("1"); const map = useRef(new Map()); + const [visible1, setVisible1] = useState(false); + const [dataUrl, setDataUrl] = useState(""); + + const visibleChange1 = (v) => { + setVisible1(v); + }; + const tabList = [ { tab: "Tables", itemKey: "1" }, { tab: "References", itemKey: "2" }, @@ -112,7 +120,7 @@ const EditorPanel = (props) => { type: "text/plain;charset=utf-8", }); - saveAs(blob, "src.txt"); + window.saveAs(blob, "src.txt"); }} > export src @@ -166,12 +174,29 @@ const EditorPanel = (props) => { + +
+ {visible1&&{`lamp${1}`}} +
+
); diff --git a/src/data/data.js b/src/data/data.js index 89657a6..280fee9 100644 --- a/src/data/data.js +++ b/src/data/data.js @@ -1,59 +1,191 @@ const menu = { File: { - New: [], - "New window": [], - Save: [], - "Save as": [], - Share: [], - Rename: [], - Import: [], - "Export as": [".png", ".jpg", ".pdf", ".xml"], - "Export source": ["MySQL", "PostgreSQL", "DBML"], - Properties: [], - Close: [], + New: { + children: [], + function: () => console.log("New"), + }, + "New window": { + children: [], + function: () => {}, + }, + Save: { + children: [], + function: () => {}, + }, + "Save as": { + children: [], + function: () => {}, + }, + Share: { + children: [], + function: () => {}, + }, + Rename: { + children: [], + function: () => {}, + }, + Import: { + children: [], + function: () => {}, + }, + "Export as": { + children: [{".png": ()=>console.log("exporting png")}, {".jpg": ()=>{}}, {".xml": ()=>{}},{".svg": ()=>{}}, {".xml": ()=>{}}], + function: () => {}, + }, + "Export source": { + children: [{"MySQL": ()=>{}}, {"PostgreSQL": ()=>{}}, {"DBML": ()=>{}}], + function: () => {}, + }, + Properties: { + children: [], + function: () => {}, + }, + Close: { + children: [], + function: () => {}, + }, }, Edit: { - Undo: [], - Redo: [], - Cut: [], - Copy: [], - "Copy as image": [], - Paste: [], - Delete: [], - "Edit table": [], + Undo: { + children: [], + function: () => {}, + }, + Redo: { + children: [], + function: () => {}, + }, + Cut: { + children: [], + function: () => {}, + }, + Copy: { + children: [], + function: () => {}, + }, + "Copy as image": { + children: [], + function: () => {}, + }, + Paste: { + children: [], + function: () => {}, + }, + Delete: { + children: [], + function: () => {}, + }, + "Edit table": { + children: [], + function: () => {}, + }, }, View: { - Toolbar: [], - Grid: [], - Sidebar: [], - Editor: [], - "Strict mode": [], - "Reset view": [], - "View schema": [], - Theme: ["Light", "Dark"], - "Zoom in": [], - "Zoom out": [], - Fullscreen: [], + Toolbar: { + children: [], + function: () => {}, + }, + Grid: { + children: [], + function: () => {}, + }, + Sidebar: { + children: [], + function: () => {}, + }, + Editor: { + children: [], + function: () => {}, + }, + "Strict mode": { + children: [], + function: () => {}, + }, + "Reset view": { + children: [], + function: () => {}, + }, + "View schema": { + children: [], + function: () => {}, + }, + Theme: { + children: [{Light: ()=>{}}, {Dark: ()=>{}}], + function: ()=>{} + }, + "Zoom in": { + children: [], + function: () => {}, + }, + "Zoom out": { + children: [], + function: () => {}, + }, + Fullscreen: { + children: [], + function: () => {}, + }, }, Insert: { - "New table": [], - "New relationship": [], - Note: [], - Image: [], - Textbox: [], - Shape: ["Rhombus", "Rectangle"], + "New table": { + children: [], + function: () => {}, + }, + "New relationship": { + children: [], + function: () => {}, + }, + Note: { + children: [], + function: () => {}, + }, + Image: { + children: [], + function: () => {}, + }, + Textbox: { + children: [], + function: () => {}, + }, + Shape: { + children: [], + function: () => {}, + }, }, Logs: { - "Open logs": [], - "Commit changes": [], - "Revert changes": [], - "View commits": [], + "Open logs": { + children: [], + function: () => {}, + }, + "Commit changes": { + children: [], + function: () => {}, + }, + "Revert changes": { + children: [], + function: () => {}, + }, + "View commits": { + children: [], + function: () => {}, + }, }, Help: { - Shortcuts: [], - "Ask us on discord": [], - "Tweet us": [], - "Found a bug": [], + Shortcuts: { + children: [], + function: () => {}, + }, + "Ask us on discord": { + children: [], + function: () => {}, + }, + "Tweet us": { + children: [], + function: () => {}, + }, + "Found a bug": { + children: [], + function: () => {}, + }, }, }; @@ -116,4 +248,12 @@ const Constraint = { setDefault: "Set default", }; -export { menu, bgBlue, sqlDataTypes, tableThemes, defaultTableTheme, Cardinality, Constraint }; +export { + menu, + bgBlue, + sqlDataTypes, + tableThemes, + defaultTableTheme, + Cardinality, + Constraint, +};