diff --git a/app/page.tsx b/app/page.tsx index dd2f32b..b28c3c3 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -1,16 +1,33 @@ "use client"; +import React from "react"; import { ReactFlowProvider } from "reactflow"; import { AppBar } from "@/components/Editor/AppBar"; import { Editor } from "@/components/Editor/Editor"; +import { createContext, useState } from 'react'; + +interface AppContextInterface { + isOpen: boolean; + setIsOpen: (value: boolean) => boolean; +} +export const ContextDefaultValue: AppContextInterface = { + isOpen: true, + setIsOpen: () => true +} +export const SidebarContext = createContext(ContextDefaultValue); export default function EditPage() { + const [isOpen, setIsOpen] = useState(true); + const value = { isOpen, setIsOpen } + return ( <> - - - - + + + + + + ) } \ No newline at end of file diff --git a/components/Editor/AppBar.tsx b/components/Editor/AppBar.tsx index 31245c2..52f5c60 100644 --- a/components/Editor/AppBar.tsx +++ b/components/Editor/AppBar.tsx @@ -1,16 +1,20 @@ -import { Save } from "lucide-react"; +import { Save, Layout } from "lucide-react"; import { ThemeToggle } from "../theme-toggle"; import { Icons } from "../icons"; import { siteConfig } from "@/config/site"; +import { useContext } from "react"; +import { SidebarContext } from "@/app/page"; export function AppBar() { + let { isOpen, setIsOpen } = useContext(SidebarContext); + return (
-
- - {siteConfig.name} -
+
+ + {siteConfig.name} +
*/} +
diff --git a/components/Editor/OptionBar/index.tsx b/components/Editor/OptionBar/index.tsx index 8611d38..474a64d 100644 --- a/components/Editor/OptionBar/index.tsx +++ b/components/Editor/OptionBar/index.tsx @@ -2,7 +2,8 @@ import { BackgroundVariant, Edge, MarkerType, Node, useOnSelectionChange } from import { ClassOptions } from "./Class"; import { DefaultOptions } from "./Default"; import { EdgeOptions } from "./Edge"; -import { useEffect, useState } from "react"; +import { useContext, useEffect, useState } from "react"; +import { SidebarContext } from "@/app/page"; interface OptionBarProps { editNode: (id: string, newData: any) => void; @@ -13,9 +14,10 @@ interface OptionBarProps { export function OptionBar({ editNode, setBgVariant, editEdge, deleteEdge }: OptionBarProps) { const [entitySelected, setEntitySelected] = useState(null); + let { isOpen } = useContext(SidebarContext); useOnSelectionChange({ - onChange: (e) => { + onChange: (e) => { const node = e.nodes[0]; const edge = e.edges[0]; if (entitySelected?.type === "floating" && !node) return; @@ -36,7 +38,7 @@ export function OptionBar({ editNode, setBgVariant, editEdge, deleteEdge }: Opti } return ( -
+
{getOptions()}
)