diff --git a/src/components/Routing/index.tsx b/src/components/Routing/index.tsx
index 8169177..a64725d 100644
--- a/src/components/Routing/index.tsx
+++ b/src/components/Routing/index.tsx
@@ -98,7 +98,12 @@ const Routing = () => {
element={
<>
-
+
>
}
/>
diff --git a/src/pages/Home/index.tsx b/src/pages/Home/index.tsx
index 806133d..fee25d8 100644
--- a/src/pages/Home/index.tsx
+++ b/src/pages/Home/index.tsx
@@ -1,13 +1,21 @@
import React from 'react';
import { Box, Button, Container, styled, Typography } from '@mui/material';
import { useNavigate } from 'react-router-dom';
-import { useAuth, useSigninCheck } from 'reactfire';
-import { signInAnonymously } from 'firebase/auth';
+import { useAuth, useFirestore, useSigninCheck } from 'reactfire';
+import { signInAnonymously, UserCredential } from 'firebase/auth';
+import {
+ addDoc,
+ collection,
+ serverTimestamp,
+ Timestamp,
+} from 'firebase/firestore';
+import { MindMap } from '../../types';
const HomePage = () => {
const auth = useAuth();
+ const firestore = useFirestore();
const navigate = useNavigate();
- const signinCheck = useSigninCheck().data;
+ const signInCheck = useSigninCheck().data;
const Content = styled(Container)(({ theme }) => ({
display: 'flex',
@@ -45,16 +53,46 @@ const HomePage = () => {
},
}));
+ const mindmapsCollection = collection(firestore, 'mindmaps');
+
+ const createMindMap = (title: string, user: UserCredential) => {
+ const newDocData: MindMap = {
+ metadata: {
+ createdAt: serverTimestamp() as Timestamp,
+ createdBy: user.user.uid,
+ updatedAt: serverTimestamp() as Timestamp,
+ updatedBy: user.user.uid,
+ },
+ nodes: [
+ {
+ parent: 0,
+ text: title,
+ id: 0,
+ },
+ ],
+ permissions: {
+ owner: user.user.uid,
+ delete: [],
+ read: [],
+ write: [],
+ },
+ title,
+ };
+ addDoc(mindmapsCollection, newDocData).then((newDoc) => {
+ navigate(`/mindmaps/${newDoc.id}`);
+ });
+ };
+
return (
-
Mind Map
+
Bubble Map
{
An intuitive mind mapping tool for rapid collaborative AI-assisted
idea generation
- {!signinCheck.user ? (
+ {!signInCheck.user ? (
{
- signInAnonymously(auth).then(() => navigate('/mindmaps'));
+ signInAnonymously(auth).then((user) =>
+ createMindMap('Untitled MindMap', user)
+ );
}}
variant="contained"
size="large"
diff --git a/src/pages/MindMap/Bubble.tsx b/src/pages/MindMap/Bubble.tsx
index 7dfb51f..ff0812f 100644
--- a/src/pages/MindMap/Bubble.tsx
+++ b/src/pages/MindMap/Bubble.tsx
@@ -2,6 +2,7 @@ import React from 'react';
import { SimulationNodeDatum } from 'd3-force';
import { Divider, Menu, MenuItem, useTheme } from '@mui/material';
import { localNode as nodeType } from '../../types';
+import './MindMap.css';
const radius = 15;
const lineHeight = 15.5;
@@ -233,6 +234,7 @@ const Bubble = ({
: theme.palette.primary.main
}
stroke={getStrokeColor()}
+ className={selected ? 'root-node-glow' : ''}
/>
{/* print the main text in the bubble */}
{/* main text uses https://observablehq.com/@mbostock/fit-text-to-circle */}
diff --git a/src/pages/MindMap/BubbleLink.tsx b/src/pages/MindMap/BubbleLink.tsx
index 1733888..eca2bc8 100644
--- a/src/pages/MindMap/BubbleLink.tsx
+++ b/src/pages/MindMap/BubbleLink.tsx
@@ -1,13 +1,14 @@
import React from 'react';
import { SimulationNodeDatum } from 'd3-force';
import { useTheme } from '@mui/material';
+import { node } from '../../types';
const BubbleLink = ({
sourceNode,
targetNode,
}: {
- sourceNode: SimulationNodeDatum;
- targetNode: SimulationNodeDatum;
+ sourceNode: SimulationNodeDatum & node;
+ targetNode: SimulationNodeDatum & node;
}) => {
const theme = useTheme();
diff --git a/src/pages/MindMap/MindMap.css b/src/pages/MindMap/MindMap.css
index b249ce3..7688496 100644
--- a/src/pages/MindMap/MindMap.css
+++ b/src/pages/MindMap/MindMap.css
@@ -32,3 +32,16 @@ body::-webkit-scrollbar {
.no-translate {
transform: none !important;
}
+
+.root-node-glow {
+ animation: glow 1s infinite alternate;
+}
+
+@keyframes glow {
+ from {
+ stroke-width: 0.5;
+ }
+ to {
+ stroke-width: 1.5;
+ }
+}
diff --git a/src/pages/MindMap/MindMapSimulation.tsx b/src/pages/MindMap/MindMapSimulation.tsx
index fa8e69a..402150c 100644
--- a/src/pages/MindMap/MindMapSimulation.tsx
+++ b/src/pages/MindMap/MindMapSimulation.tsx
@@ -7,6 +7,7 @@ import React, {
useRef,
forwardRef,
useImperativeHandle,
+ MouseEvent,
} from 'react';
import { GlobalHotKeys } from 'react-hotkeys';
import {
@@ -25,8 +26,9 @@ import {
import './MindMap.css';
import Bubble from './Bubble';
import BubbleLink from './BubbleLink';
-import { MindMap, node } from '../../types';
+import { MindMap, node, WithID } from '../../types';
import Loading from '../../components/Loading';
+import BottomBar from './overlays/BottomBar';
const MindMapSimulationWithTransform = forwardRef(
(
@@ -37,6 +39,7 @@ const MindMapSimulationWithTransform = forwardRef(
// TODO: Implement the following functions: [addNode, deleteNode, updateNode]. Remove relevant eslint-disables when done.
// eslint-disable-next-line
addNode,
+ handleAddNode,
// eslint-disable-next-line
deleteNode,
// eslint-disable-next-line
@@ -44,12 +47,13 @@ const MindMapSimulationWithTransform = forwardRef(
selectedNode,
setSelectedNode,
}: {
- data: MindMap;
+ data: WithID;
dragNodeSelected: (SimulationNodeDatum & node) | undefined;
setDragNodeSelected: Dispatch<
SetStateAction<(SimulationNodeDatum & node) | undefined>
>;
addNode: (node: { parent: number; text: string }) => void;
+ handleAddNode: (parentNode?: SimulationNodeDatum & node) => void;
deleteNode: (node: node) => void;
updateNode: (oldNode: node, newNode: node) => void;
selectedNode: SimulationNodeDatum & node;
@@ -117,17 +121,6 @@ const MindMapSimulationWithTransform = forwardRef(
lastNodeLockStates.current = nodeLockStates;
}, [nodeLockStates, simulation]);
- // const [selectedNode, setSelectedNode] = useState<
- // SimulationNodeDatum & node
- // >();
-
- const handleAddNode = (parentNode: SimulationNodeDatum & node) => {
- // eslint-disable-next-line no-alert
- const newText = prompt('Enter new text', '');
- if (newText) {
- addNode({ parent: parentNode.id, text: newText });
- }
- };
const checkIfRecursiveChildrenisSelected = (
nodeTo: (SimulationNodeDatum & node) | undefined,
nodeFrom: (SimulationNodeDatum & node) | undefined = selectedNode
@@ -376,8 +369,7 @@ const MindMapSimulationWithTransform = forwardRef(
}
};
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const onMouseMove = (e: any) => {
+ const onMouseMove = (e: MouseEvent) => {
if (dragNodeSelected && dragNodeSelected.id !== 0) {
dragNodeSelected.fx =
(e.clientX - context.state.positionX + mouseDelta.x) /
@@ -393,8 +385,7 @@ const MindMapSimulationWithTransform = forwardRef(
releaseBubble() {
releaseBubble();
},
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- onMouseMove(e: any) {
+ onMouseMove(e: MouseEvent) {
onMouseMove(e);
},
handleAddNode() {
@@ -440,6 +431,12 @@ const MindMapSimulationWithTransform = forwardRef(
handleToggleNodeLock(selectedNode);
}
},
+ getContext() {
+ return context;
+ },
+ restartSimulation() {
+ if (simulation) simulation.alpha(1).restart();
+ },
}));
if (simulation === null) return ;
@@ -451,6 +448,8 @@ const MindMapSimulationWithTransform = forwardRef(
style={{
overflow: 'visible',
}}
+ width={1}
+ height={1}
onMouseDown={(e) => {
// if right click
if (e.button === 2) {
@@ -537,7 +536,7 @@ const MindMapSimulation = ({
selectedNode,
setSelectedNode,
}: {
- data: MindMap;
+ data: WithID;
addNode: (node: { parent: number; text: string }) => void;
deleteNode: (node: node) => void;
updateNode: (oldNode: node, newNode: node) => void;
@@ -548,52 +547,78 @@ const MindMapSimulation = ({
(SimulationNodeDatum & node) | undefined
>(undefined);
- /* eslint-disable @typescript-eslint/no-explicit-any */
- const childRef: any = useRef();
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ const childRef = useRef();
+
+ const handleAddNode = (parentNode?: SimulationNodeDatum & node) => {
+ if (!parentNode) return;
+ // eslint-disable-next-line no-alert
+ const newText = prompt('Enter new text', '');
+ if (newText) {
+ addNode({ parent: parentNode.id, text: newText });
+ }
+ };
const shortcutHandlers = {
- ADD_NODE: (e: any) => {
- childRef.current.handleAddNode();
- e.preventDefault();
+ ADD_NODE: (e?: KeyboardEvent) => {
+ handleAddNode(selectedNode);
+ e?.preventDefault();
},
- DELETE_NODE: (e: any) => {
+ DELETE_NODE: (e?: KeyboardEvent) => {
childRef.current.handleDeleteNode();
- e.preventDefault();
+ e?.preventDefault();
},
- EDIT_NODE_TEXT: (e: any) => {
+ EDIT_NODE_TEXT: (e?: KeyboardEvent) => {
childRef.current.handleEditNode();
- e.preventDefault();
+ e?.preventDefault();
},
- MOVE_SELECTION_TO_PARENT: (e: any) => {
+ MOVE_SELECTION_TO_PARENT: (e?: KeyboardEvent) => {
childRef.current.handleMoveSelectionToParent();
- e.preventDefault();
+ e?.preventDefault();
},
- MOVE_SELECTION_TO_CHILD: (e: any) => {
+ MOVE_SELECTION_TO_CHILD: (e?: KeyboardEvent) => {
childRef.current.handleMoveSelectionToChild();
- e.preventDefault();
+ e?.preventDefault();
},
- MOVE_SELECTION_TO_NEXT_SIBLING: (e: any) => {
+ MOVE_SELECTION_TO_NEXT_SIBLING: (e?: KeyboardEvent) => {
childRef.current.handleMoveSelectionToNextSibling();
- e.preventDefault();
+ e?.preventDefault();
},
- MOVE_SELECTION_TO_PREVIOUS_SIBLING: (e: any) => {
+ MOVE_SELECTION_TO_PREVIOUS_SIBLING: (e?: KeyboardEvent) => {
childRef.current.handleMoveSelectionToPreviousSibling();
- e.preventDefault();
+ e?.preventDefault();
},
- MOVE_SELECTION_TO_ROOT: (e: any) => {
+ MOVE_SELECTION_TO_ROOT: (e?: KeyboardEvent) => {
childRef.current.handleMoveSelectionToRoot();
- e.preventDefault();
+ e?.preventDefault();
},
- RESET_VIEW: (e: any) => {
- // TODO: Reset the Transform
- e.preventDefault();
- },
- LOCK_NODE: (e: any) => {
+ LOCK_NODE: (e?: KeyboardEvent) => {
childRef.current.handleToggleNodeLock();
- e.preventDefault();
+ e?.preventDefault();
+ },
+ RESET_VIEW: (e?: KeyboardEvent) => {
+ resetCanvas();
+ e?.preventDefault();
},
};
- /* eslint-enable @typescript-eslint/no-explicit-any */
+
+ const resetCanvas = () => {
+ const context = childRef.current.getContext();
+ const { contentComponent, wrapperComponent } = context.instance;
+ const { scale } = context.state;
+
+ const contentWidth = (contentComponent?.offsetWidth ?? 0) * scale;
+ const contentHeight = (contentComponent?.offsetHeight ?? 0) * scale;
+
+ const centerPositionX =
+ ((wrapperComponent?.offsetWidth ?? 0) - contentWidth) / 2;
+ const centerPositionY =
+ ((wrapperComponent?.offsetHeight ?? 0) - contentHeight) / 2;
+
+ context.setTransform(centerPositionX, centerPositionY, 7);
+
+ childRef.current.restartSimulation();
+ };
return (
@@ -606,7 +631,6 @@ const MindMapSimulation = ({
minScale={0.1}
maxScale={25}
limitToBounds={false}
- // centerZoomedOut
centerOnInit
panning={{
disabled: !!dragNodeSelected,
@@ -623,7 +647,6 @@ const MindMapSimulation = ({
width: '100%',
height: '100%',
}}
- // contentClass="no-translate"
>
+
);
};
diff --git a/src/pages/MindMap/index.tsx b/src/pages/MindMap/index.tsx
index 9004dba..b675d6a 100644
--- a/src/pages/MindMap/index.tsx
+++ b/src/pages/MindMap/index.tsx
@@ -6,14 +6,15 @@ import {
arrayUnion,
writeBatch,
} from 'firebase/firestore';
+import { Fab } from '@mui/material';
+import { BubbleChart } from '@mui/icons-material';
import { useFirestore, useFirestoreDocData } from 'reactfire';
-import { useParams } from 'react-router-dom';
-import { configure, GlobalHotKeys } from 'react-hotkeys';
+import { useNavigate, useParams } from 'react-router-dom';
// You can use getApplicationKeyMap from react-hotkeys to get the keymaps for the application
+import { GlobalHotKeys } from 'react-hotkeys';
import { SimulationNodeDatum } from 'd3-force';
-import { localNode, MindMap as MindMapType, node } from '../../types';
+import { localNode, MindMap as MindMapType, node, WithID } from '../../types';
import MindMapSimulation from './MindMapSimulation';
-import SideMenu from './overlays/SideMenu/SideMenu';
import GenIdeaPanel from './overlays/GenIdeaPanel';
const keyMap = {
@@ -37,10 +38,12 @@ const keyMap = {
const MindMap = () => {
const { mindmapID } = useParams();
+ const navigate = useNavigate();
const firestore = useFirestore();
const mindMapRef = doc(firestore, `mindmaps/${mindmapID}`);
- const mindmap = useFirestoreDocData(mindMapRef).data as MindMapType;
+ const mindmap = useFirestoreDocData(mindMapRef, { idField: 'ID' })
+ .data as WithID;
const addNode = ({ parent, text }: { parent: number; text: string }) => {
const newID =
@@ -103,6 +106,7 @@ const MindMap = () => {
nodes: arrayRemove(strippedNodeToDelete),
});
};
+
const updateNode = (oldNode: node, newNode: node) => {
const batch = writeBatch(firestore);
if (oldNode.id !== newNode.id) {
@@ -114,6 +118,7 @@ const MindMap = () => {
batch.update(mindMapRef, {
nodes: arrayRemove(stripInputNodeProperties(oldNode)),
});
+
if (newNode.id === 0) {
batch.update(mindMapRef, {
title: newNode.text,
@@ -129,9 +134,6 @@ const MindMap = () => {
setSelectedNode(newNode);
}
};
- // const updateNodePrompt = (nodeToUpdate: node) => {
- // // Create an MUI dialog box to update the node
- // };
if (!mindmap) return Sorry, I couldn't find that mindmap.
;
@@ -140,23 +142,8 @@ const MindMap = () => {
// eslint-disable-next-line no-console
console.log('Toggle Settings');
},
- RESET_VIEW: () => {
- // eslint-disable-next-line no-console
- console.log('Reset View');
- },
};
- // Create a sidebar active state
- const [sideMenuActive, setSideMenuActive] = useState(false);
-
- configure({
- ignoreEventsCondition: () => {
- // Ignore keypresses while side menu is open
- if (sideMenuActive) return true;
- return false;
- },
- });
-
// Get the mindmap node with id 0, which is the root node
const rootNode = mindmap.nodes.find((o) => o.id === 0);
@@ -179,14 +166,24 @@ const MindMap = () => {
selectedNode={selectedNode}
setSelectedNode={setSelectedNode}
/>
-
+ navigate('/mindmaps')}
+ >
+
+ MindMaps
+
- {/* */}
);
};
diff --git a/src/pages/MindMap/overlays/BottomRightButtons/KeyBindsDialog.css b/src/pages/MindMap/overlays/BottomBar/KeyBindsDialog.css
similarity index 100%
rename from src/pages/MindMap/overlays/BottomRightButtons/KeyBindsDialog.css
rename to src/pages/MindMap/overlays/BottomBar/KeyBindsDialog.css
diff --git a/src/pages/MindMap/overlays/BottomRightButtons/KeyBindsDialog.tsx b/src/pages/MindMap/overlays/BottomBar/KeyBindsDialog.tsx
similarity index 100%
rename from src/pages/MindMap/overlays/BottomRightButtons/KeyBindsDialog.tsx
rename to src/pages/MindMap/overlays/BottomBar/KeyBindsDialog.tsx
diff --git a/src/pages/MindMap/overlays/BottomBar/index.tsx b/src/pages/MindMap/overlays/BottomBar/index.tsx
new file mode 100644
index 0000000..8a6da3d
--- /dev/null
+++ b/src/pages/MindMap/overlays/BottomBar/index.tsx
@@ -0,0 +1,156 @@
+import React, { useEffect, useRef, useState } from 'react';
+import { styled } from '@mui/material/styles';
+import {
+ AppBar,
+ Box,
+ Toolbar,
+ IconButton,
+ Fab,
+ alpha,
+ InputBase,
+} from '@mui/material';
+import { Add, Help, MyLocation } from '@mui/icons-material';
+import { doc, updateDoc } from 'firebase/firestore';
+import { useFirestore } from 'reactfire';
+import { SimulationNodeDatum } from 'd3-force';
+import { MindMap, node, WithID } from '../../../../types';
+import KeyBindsDialog from './KeyBindsDialog';
+
+const StyledFab = styled(Fab)({
+ position: 'absolute',
+ zIndex: 1,
+ top: -30,
+ left: 0,
+ right: 0,
+ margin: '0 auto',
+});
+
+const Search = styled('form')(({ theme }) => ({
+ position: 'relative',
+ borderRadius: theme.shape.borderRadius,
+ // backgroundColor: alpha(theme.palette.common.white, 0.15),
+ '&:hover': {
+ backgroundColor: alpha(theme.palette.common.white, 0.15),
+ },
+ marginRight: theme.spacing(2),
+ marginLeft: 0,
+ width: '100%',
+ [theme.breakpoints.up('sm')]: {
+ marginLeft: theme.spacing(3),
+ width: 'auto',
+ },
+}));
+
+const screenWidth = window.innerWidth;
+
+const StyledInputBase = styled(InputBase)(({ theme }) => ({
+ color: 'inherit',
+ '& .MuiInputBase-input': {
+ padding: theme.spacing(1, 1, 1, 1),
+ transition: theme.transitions.create('width'),
+ width: '100%',
+ textOverflow: 'ellipsis',
+ [theme.breakpoints.up('md')]: {
+ width: screenWidth * 0.3,
+ },
+ },
+}));
+
+const BottomBar = ({
+ data,
+ handleAddNode,
+ selectedNode,
+ resetCanvas,
+}: {
+ data: WithID
;
+ handleAddNode: (parentNode: SimulationNodeDatum & node) => void;
+ selectedNode: SimulationNodeDatum & node;
+ resetCanvas: () => void;
+}) => {
+ const [isKeyBindsDialogOpen, setIsKeyBindsDialogOpen] = useState(false);
+ const [title, setTitle] = useState(data.title ?? 'Untitled MindMap');
+ const firestore = useFirestore();
+
+ const titleRef = useRef(title);
+ titleRef.current = title;
+
+ const dataTitleRef = useRef(data.title);
+ dataTitleRef.current = data.title;
+
+ const updateTitle = (newTitle: string) => {
+ const newData: Partial = {
+ title: newTitle,
+ };
+ updateDoc(doc(firestore, `mindmaps/${data.ID}`), newData)
+ .then()
+ .catch((err) => console.error(err));
+ };
+
+ useEffect(() => {
+ setTimeout(() => {
+ if (
+ title === titleRef.current &&
+ titleRef.current !== dataTitleRef.current
+ ) {
+ updateTitle(titleRef.current);
+ }
+ }, 1500);
+ }, [title]);
+
+ return (
+
+
+ setIsKeyBindsDialogOpen(false)}
+ />
+ setIsKeyBindsDialogOpen(true)}
+ >
+
+
+ {
+ e.preventDefault();
+ updateTitle(title);
+ }}
+ >
+ setTitle(e.target.value)}
+ sx={{
+ textOverflow: 'ellipsis',
+ }}
+ onKeyUp={(e) => {
+ if (e.key === 'Enter') {
+ e.currentTarget.blur();
+ }
+ }}
+ onBlur={() => {
+ setTitle(title || 'Untitled MindMap');
+ }}
+ />
+
+ handleAddNode(selectedNode)}
+ >
+
+
+
+
+
+
+
+
+ );
+};
+export default BottomBar;
diff --git a/src/pages/MindMap/overlays/BottomRightButtons/index.tsx b/src/pages/MindMap/overlays/BottomRightButtons/index.tsx
deleted file mode 100644
index 5f13189..0000000
--- a/src/pages/MindMap/overlays/BottomRightButtons/index.tsx
+++ /dev/null
@@ -1,80 +0,0 @@
-import React, { useState } from 'react';
-import { CenterFocusStrong, QuestionMark } from '@mui/icons-material';
-import { Fab } from '@mui/material';
-import KeyBindsDialog from './KeyBindsDialog';
-
-const HelpButton = () => {
- const [isKeyBindsDialogOpen, setIsKeyBindsDialogOpen] = useState(false);
-
- return (
- <>
- setIsKeyBindsDialogOpen(false)}
- />
- setIsKeyBindsDialogOpen(true)}
- // variant="extended"
- sx={{
- right: 20,
- bottom: 20,
- position: 'absolute',
- }}
- >
-
-
- >
- );
-};
-
-const ResetViewportButton = () => {
- // eslint-disable-next-line
- const one = 1;
- return (
- {
- // reset the viewport
- }}
- >
-
-
- );
-};
-
-const BottomRightButtons = ({
- drawerOpen,
- drawerWidth,
-}: {
- // State
- drawerOpen: boolean;
- // Drawer width
- drawerWidth: number;
-}) => (
-
-
-
-
-);
-
-export default BottomRightButtons;
diff --git a/src/pages/MindMap/overlays/GenIdeaPanel/index.tsx b/src/pages/MindMap/overlays/GenIdeaPanel/index.tsx
index 799ef9e..4e87f24 100644
--- a/src/pages/MindMap/overlays/GenIdeaPanel/index.tsx
+++ b/src/pages/MindMap/overlays/GenIdeaPanel/index.tsx
@@ -1,25 +1,26 @@
-import * as React from 'react';
+import React, { useEffect, useState } from 'react';
import { styled, useTheme } from '@mui/material/styles';
-import Drawer from '@mui/material/Drawer';
-import CssBaseline from '@mui/material/CssBaseline';
-import List from '@mui/material/List';
-import Divider from '@mui/material/Divider';
-import IconButton from '@mui/material/IconButton';
-import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
-import ChevronRightIcon from '@mui/icons-material/ChevronRight';
-import ListItem from '@mui/material/ListItem';
-import ListItemButton from '@mui/material/ListItemButton';
-import ListItemText from '@mui/material/ListItemText';
+import {
+ Drawer,
+ List,
+ Divider,
+ Fab,
+ ListItemSecondaryAction,
+ IconButton,
+ ListItem,
+ ListItemButton,
+ ListItemText,
+} from '@mui/material';
+import {
+ SettingsSuggest,
+ ChevronLeft,
+ ChevronRight,
+} from '@mui/icons-material';
import { httpsCallable } from 'firebase/functions';
import { useFunctions } from 'reactfire';
import { SimulationNodeDatum } from 'd3-force';
import { GlobalHotKeys } from 'react-hotkeys';
-/* eslint-disable */
-import { Fab, ListItemSecondaryAction } from '@mui/material';
-import { Help, QuestionMark, SettingsSuggest } from '@mui/icons-material';
-/* eslint-enable */
import { MindMap, node } from '../../../../types';
-import BottomRightButtons from '../BottomRightButtons';
const drawerWidthPercent = '20%';
// Calculate the width of the drawer based on the percentage
@@ -54,7 +55,7 @@ const PersistentDrawerRight = ({
// eslint-disable-next-line
const theme = useTheme();
- const [open, setOpen] = React.useState(false);
+ const [open, setOpen] = useState(false);
const handleDrawerOpen = () => {
setOpen(true);
@@ -64,18 +65,18 @@ const PersistentDrawerRight = ({
setOpen(false);
};
- // const [realNode, setRealNode] = React.useState(null);
+ // const [realNode, setRealNode] = useState(null);
// create a state to store the value of the input
- const [input, setInput] = React.useState('');
+ const [input, setInput] = useState('');
- const [textCache, setTextCache] = React.useState<{
+ const [textCache, setTextCache] = useState<{
[key: number]: string | undefined;
}>({});
- const [datamuseCache, setDatamuseCache] = React.useState<{
+ const [datamuseCache, setDatamuseCache] = useState<{
[key: number]: string[] | undefined;
}>({});
- const [gpt3Cache, setGpt3Cache] = React.useState<{
+ const [gpt3Cache, setGpt3Cache] = useState<{
[key: number]: string[] | undefined;
}>({});
@@ -131,9 +132,9 @@ const PersistentDrawerRight = ({
};
// Creat a state called "initialLoad"
- const [initialLoad, setInitialLoad] = React.useState(true);
+ const [initialLoad, setInitialLoad] = useState(true);
- React.useEffect(() => {
+ useEffect(() => {
setInput(selectedNode.text);
if (initialLoad) {
generateIdeas(selectedNode.id, selectedNode.text);
@@ -147,17 +148,8 @@ const PersistentDrawerRight = ({
}
}, [selectedNode]);
- React.useEffect(() => {
- // console.log('datamuse cache', datamuseCache);
- }, [datamuseCache]);
- React.useEffect(() => {
- // console.log('gpt3 cache', gpt3Cache);
- }, [gpt3Cache]);
- React.useEffect(() => {
- // console.log('text cache', textCache);
- }, [textCache]);
// When the panel is opened, generate ideas for the selected node
- React.useEffect(() => {
+ useEffect(() => {
if (open) {
generateIdeas(selectedNode.id, selectedNode.text);
}
@@ -188,7 +180,6 @@ const PersistentDrawerRight = ({
return (
-
-
+
Idea Menu
-
+
Idea Generation Panel
@@ -337,46 +328,7 @@ const PersistentDrawerRight = ({
))}
-
-
- {/* Test GPT3_PARENT */}
- {/* PART ONE */}
- {/* {
- if (selectedNode.id === 0) {
- return;
- }
- const { text } = selectedNode;
- const parentID = selectedNode.parent;
- const parentNode = data.nodes.find(
- (nodeF) => nodeF.id === parentID
- );
- // get the text of the parent node
- const parentText = parentNode?.text;
- httpsCallable(
- functions,
- 'gpt3_parent'
- )({ data: [text, parentText] }).then((res) => {
- // eslint-disable-next-line no-console
- console.log(res);
- });
- }}
- >
-
- */}
-
-
- {
- generateIdeas(selectedNode.id, selectedNode.text, true);
- }}
- >
-
-
-
- {/* Create a Help Button that is positioned on the bottom right of the page relative to the drawer */}
-
//
);
diff --git a/src/pages/MindMap/overlays/SideMenu/DrawerListItem.tsx b/src/pages/MindMap/overlays/SideMenu/DrawerListItem.tsx
deleted file mode 100644
index 65ec678..0000000
--- a/src/pages/MindMap/overlays/SideMenu/DrawerListItem.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-import React from 'react';
-import {
- ListItem,
- ListItemButton,
- ListItemIcon,
- ListItemText,
- SvgIconProps,
-} from '@mui/material';
-
-interface DrawerListItemProps {
- text: string;
- icon: React.ReactElement;
- onClick: () => void;
-}
-
-const DrawerListItem: React.FC = ({
- text,
- icon,
- onClick,
-}) => (
-
-
- {icon}
-
-
-
-);
-
-export default DrawerListItem;
diff --git a/src/pages/MindMap/overlays/SideMenu/SettingsButton.tsx b/src/pages/MindMap/overlays/SideMenu/SettingsButton.tsx
deleted file mode 100644
index 911409d..0000000
--- a/src/pages/MindMap/overlays/SideMenu/SettingsButton.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import * as React from 'react';
-import {
- Button,
- Dialog,
- ListItemText,
- ListItem,
- List,
- Divider,
- AppBar,
- Toolbar,
- IconButton,
- Typography,
- Slide,
-} from '@mui/material';
-
-import { TransitionProps } from '@mui/material/transitions';
-
-import { Close } from '@mui/icons-material';
-
-const Transition = React.forwardRef(
- (
- props: TransitionProps & {
- children: React.ReactElement;
- },
- ref: React.Ref
- // eslint-disable-next-line react/jsx-props-no-spreading
- ) =>
-);
-
-// eslint-disable-next-line
-export default function SettingsButton() {
- const [open, setOpen] = React.useState(false);
-
- const handleClickOpen = () => {
- setOpen(true);
- };
-
- const handleClose = () => {
- setOpen(false);
- };
- return (
-
-
- Open full-screen dialog
-
-
-
-
-
-
-
-
- Sound
-
-
- save
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/src/pages/MindMap/overlays/SideMenu/SettingsDialog.tsx b/src/pages/MindMap/overlays/SideMenu/SettingsDialog.tsx
deleted file mode 100644
index 6244f5b..0000000
--- a/src/pages/MindMap/overlays/SideMenu/SettingsDialog.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import * as React from 'react';
-import Button from '@mui/material/Button';
-import Dialog from '@mui/material/Dialog';
-import ListItemText from '@mui/material/ListItemText';
-import ListItem from '@mui/material/ListItem';
-import List from '@mui/material/List';
-import Divider from '@mui/material/Divider';
-import AppBar from '@mui/material/AppBar';
-import Toolbar from '@mui/material/Toolbar';
-import IconButton from '@mui/material/IconButton';
-import Typography from '@mui/material/Typography';
-import CloseIcon from '@mui/icons-material/Close';
-import Slide from '@mui/material/Slide';
-import { TransitionProps } from '@mui/material/transitions';
-
-const Transition = React.forwardRef(
- (
- props: TransitionProps & {
- children: React.ReactElement;
- },
- ref: React.Ref
- // eslint-disable-next-line react/jsx-props-no-spreading
- ) =>
-);
-
-// open and setOpen are React.useState(false)
-const SettingsDialog = ({
- open,
- setOpen,
-}: {
- open: boolean;
- setOpen: React.Dispatch>;
-}) => {
- const handleClose = () => {
- setOpen(false);
- };
- return (
-
-
-
-
-
-
-
- Preferences
-
-
- save
-
-
-
- {/* Below is the actual contents of the Preferences Menu */}
- {/* Edit as you see fit */}
-
-
-
-
-
-
-
-
-
-
- );
-};
-
-export default SettingsDialog;
diff --git a/src/pages/MindMap/overlays/SideMenu/SideMenu.tsx b/src/pages/MindMap/overlays/SideMenu/SideMenu.tsx
deleted file mode 100644
index 53b3087..0000000
--- a/src/pages/MindMap/overlays/SideMenu/SideMenu.tsx
+++ /dev/null
@@ -1,169 +0,0 @@
-import * as React from 'react';
-import { Box, Drawer, List, Divider, Fab } from '@mui/material';
-
-import {
- Menu,
- Lightbulb,
- Map,
- Home,
- BrowseGallery,
- DeleteSweep,
- Info,
- QueryStats,
- AccountCircle,
- Settings,
-} from '@mui/icons-material';
-
-import { useFunctions } from 'reactfire';
-import { httpsCallable } from 'firebase/functions';
-
-// Navigation
-import { useNavigate } from 'react-router-dom';
-
-// Import component dependencies
-import DrawerListItem from './DrawerListItem';
-
-// Import css file
-import SettingsDialog from './SettingsDialog';
-
-// SideMenu component accepts 2 props
-// 1. active: boolean
-// 2. setActive: function that takes a boolean and returns void
-const SideMenu = ({
- active,
- setActive,
-}: {
- active: boolean;
- setActive: React.Dispatch>;
-}) => {
- const functions = useFunctions();
- const navigate = useNavigate();
-
- /* Drawer SubFunctions */
- // Test AI
- const testAI = () => {
- httpsCallable(
- functions,
- 'ai'
- )({ data: 'trees' }).then((result) => {
- // eslint-disable-next-line no-console
- console.log(result);
- });
- };
-
- /* End Drawer SubFunctions */
-
- const toggleDrawer =
- (isOpen: boolean) => (event: React.KeyboardEvent | React.MouseEvent) => {
- if (
- event.type === 'keydown' &&
- ((event as React.KeyboardEvent).key === 'Tab' ||
- (event as React.KeyboardEvent).key === 'Shift')
- ) {
- return;
- }
-
- setActive(isOpen);
- };
-
- // Pref Dialog Functions
- // NOTE: the open and setOpen functions all refer to the preferences dialog, and NOT THE DRAWER!!!
- const [open, setOpen] = React.useState(false);
- const handleClickOpen = () => {
- setOpen(true);
- };
-
- // const handleClose = () => {
- // setOpen(false);
- // };
-
- // eslint-disable-next-line react/no-unstable-nested-components
- const SideMenuItems = () => (
-
-
- }
- onClick={() => {
- navigate('/');
- }}
- />
- }
- onClick={() => {
- navigate('/mindmaps');
- }}
- />
- }
- onClick={() => {}}
- />
- }
- onClick={() => {}}
- />
-
-
-
- } onClick={testAI} />
- }
- onClick={() => {}}
- />
-
-
-
- {/* Move Help to Main Screen, in it's own separate button */}
- {/* }
- onClick={() => {}}
- /> */}
- } onClick={() => {}} />
- }
- onClick={handleClickOpen}
- />
-
- }
- onClick={() => {}}
- />
-
-
- );
-
- return (
-
-
- {/* spacer element */}
-
-
-
-
-
-
-
-
- );
-};
-
-export default SideMenu;
diff --git a/src/pages/MindMap/overlays/TestFunctionButton/TestFunctionButton.tsx b/src/pages/MindMap/overlays/TestFunctionButton/TestFunctionButton.tsx
deleted file mode 100644
index cefadbc..0000000
--- a/src/pages/MindMap/overlays/TestFunctionButton/TestFunctionButton.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import * as React from 'react';
-import { Button } from '@mui/material';
-
-// Create a component that takes a function, parameters for the function, and an icon as a parameter and creates a test button for the function
-// The button should be a material ui button with the icon as the icon and the function as the onClick
-
-const TestFunctionButton = ({
- onClick,
- icon,
-}: {
- onClick: () => void;
- // icon is a JSX element
- icon: JSX.Element;
-}) => {icon} ;
-
-export default TestFunctionButton;
-
-// const TestFunctionButton = (props: {
-// function: () => void;
-// icon: JSX.Element;
-// }) => {
-//
-// Test {props.function.name}
-// ;
-// };