From 90e6ea18850ee01af21b65a9cff4537d9018c606 Mon Sep 17 00:00:00 2001
From: Kirill Rogovoy <kirill@rogovoy.me>
Date: Thu, 22 Jul 2021 20:53:38 +0300
Subject: Make Tweaks closable

---
 pages/index.tsx | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

(limited to 'pages/index.tsx')

diff --git a/pages/index.tsx b/pages/index.tsx
index e0619ba..04f1fc7 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -178,6 +178,7 @@ export function GraphPage() {
   }, [])
 
   const [threeDim, setThreeDim] = useState(false)
+  const [showTweeks, setShowTweeks] = useState(true)
 
   if (!graphData) {
     return null
@@ -185,13 +186,16 @@ export function GraphPage() {
 
   return (
     <div>
-      <Tweaks
+      {showTweeks && <Tweaks
         {...{
           physics,
           setPhysics,
           threeDim,
         }}
-      />
+        onClose={() => {
+          setShowTweeks(false)
+        }}
+      />}
       <Graph
         nodeById={nodeByIdRef.current!}
         linksByNodeId={linksByNodeIdRef.current!}
@@ -282,9 +286,10 @@ export interface TweakProps {
   physics: typeof initialPhysics
   setPhysics: any
   threeDim: boolean
+  onClose: () => void
 }
 export const Tweaks = function (props: TweakProps) {
-  const { physics, setPhysics, threeDim } = props
+  const { physics, setPhysics, threeDim, onClose } = props
   return (
     <Box
       zIndex="overlay"
@@ -305,7 +310,7 @@ export const Tweaks = function (props: TweakProps) {
             onClick={() => setPhysics(initialPhysics)}
           />
         </Tooltip>
-        <CloseButton />
+        <CloseButton onClick={onClose} />
       </Box>
       <Accordion allowMultiple defaultIndex={[0]} allowToggle>
         <AccordionItem>
-- 
cgit v1.2.3

