diff --git a/src/app/components/Header/Header.tsx b/src/app/components/Header/Header.tsx
index c826a3f..6687e26 100644
--- a/src/app/components/Header/Header.tsx
+++ b/src/app/components/Header/Header.tsx
@@ -5,6 +5,7 @@ import { BiSolidBook } from "react-icons/bi";
import { MdDownload } from "react-icons/md";
import AutoLayoutSwitch from "./AutoLayoutSwitch";
import SaveLoadFileButton from "./SaveLoadFileButton";
+import NewDiagramButton from "./NewDiagramButton";
const PROJECT_GITHUB = "https://github.com/matias-lg/er";
@@ -43,14 +44,16 @@ export const Header = () => {
return (
<>
-
+
ERdoc Playground
- <>
-
- >
+
+
+
+
+
diff --git a/src/app/components/Header/NewDiagramButton.tsx b/src/app/components/Header/NewDiagramButton.tsx
new file mode 100644
index 0000000..8786f8b
--- /dev/null
+++ b/src/app/components/Header/NewDiagramButton.tsx
@@ -0,0 +1,60 @@
+"use client";
+import {
+ Button,
+ Modal,
+ ModalBody,
+ ModalCloseButton,
+ ModalContent,
+ ModalFooter,
+ ModalHeader,
+ ModalOverlay,
+ useDisclosure,
+} from "@chakra-ui/react";
+import { Context } from "../../context";
+import { useMonaco } from "@monaco-editor/react";
+import { useContext } from "react";
+import { useTranslations } from "next-intl";
+import { LuFilePlus } from "react-icons/lu";
+
+const NewDiagramButton = () => {
+ const { isOpen, onOpen, onClose } = useDisclosure();
+ const { setLoadedDiagramFromOutside } = useContext(Context);
+ const monaco = useMonaco();
+ const t = useTranslations("home.header.newDiagram");
+
+ const onModalButtonClick = () => {
+ // we want to trigger a diagram update event in this case
+ setLoadedDiagramFromOutside(false);
+ const codeEditorModel = monaco?.editor.getModels()[0];
+ codeEditorModel?.setValue("");
+ onClose();
+ };
+
+ return (
+ <>
+
+
+
+
+
+ {t("modalTitle")}
+
+ {t("modalDescription")}
+
+
+
+
+
+ >
+ );
+};
+
+export default NewDiagramButton;
diff --git a/src/locales/en.json b/src/locales/en.json
index fe5d981..38ca0dd 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -20,6 +20,14 @@
"description": "Load an existing ER Diagram and ERDoc from a JSON file. This will replace the current ER Diagram.",
"upload": "Upload JSON file"
},
+
+ "newDiagram": {
+ "title": "New Diagram",
+ "modalTitle": "Create a new ER diagram",
+ "modalDescription": "Start a new ER diagram from scratch. This will delete the current diagram",
+ "modalConfirm": "Confirm"
+ },
+
"autoLayout": "Auto Layout",
"exportDiagram": "Export Diagram",
"asJSON": "Export as JSON",
@@ -44,7 +52,6 @@
"subclass": "Subclass",
"aggregation": "Aggregation",
"roles": "Roles"
-
},
"erDiagram": {