From d461284047c0bdb34df2ed3b8e99da36385e0db6 Mon Sep 17 00:00:00 2001 From: epodol <34190213+epodol@users.noreply.github.com> Date: Fri, 21 Oct 2022 22:29:36 -0700 Subject: [PATCH] UI Improvements (#140) * Add Basic Bottom Bar * Add Title (#134) * Fix Console Logs * Overlay Bottom Bar * Basic Recenter Button & Firebase Config Fix * Finalize Canvas Recenter * Remove Manually Regen Button * Add Node Glow * Update Animation * Update MindMap References * Better Title Input (#144) * longer dialog, ellipses on overflow * Deselect on enter * Remove comments cleanup * Actually let you change the title to what you want * Fix Firebase Config Issue * Keep Text Legible on Node Glow * Fix BubbleLink Node Type * Fix Help Dialog Co-authored-by: Saketh Reddy <45369057+SpiritSeal@users.noreply.github.com> --- .env | 18 ++ .env.development | 7 - .env.production | 9 - .github/CONTRIBUTING.md | 6 +- .gitignore | 1 - README.md | 6 +- public/index.html | 2 +- public/manifest.json | 4 +- src/App.tsx | 20 ++- src/components/Navigation/index.tsx | 6 +- src/components/Routing/index.tsx | 7 +- src/pages/Home/index.tsx | 56 +++++- src/pages/MindMap/Bubble.tsx | 2 + src/pages/MindMap/BubbleLink.tsx | 5 +- src/pages/MindMap/MindMap.css | 13 ++ src/pages/MindMap/MindMapSimulation.tsx | 122 ++++++++----- src/pages/MindMap/index.tsx | 47 +++-- .../KeyBindsDialog.css | 0 .../KeyBindsDialog.tsx | 0 .../MindMap/overlays/BottomBar/index.tsx | 156 ++++++++++++++++ .../overlays/BottomRightButtons/index.tsx | 80 --------- .../MindMap/overlays/GenIdeaPanel/index.tsx | 104 +++-------- .../overlays/SideMenu/DrawerListItem.tsx | 29 --- .../overlays/SideMenu/SettingsButton.tsx | 85 --------- .../overlays/SideMenu/SettingsDialog.tsx | 85 --------- .../MindMap/overlays/SideMenu/SideMenu.tsx | 169 ------------------ .../TestFunctionButton/TestFunctionButton.tsx | 25 --- 27 files changed, 402 insertions(+), 662 deletions(-) create mode 100644 .env delete mode 100644 .env.development delete mode 100644 .env.production rename src/pages/MindMap/overlays/{BottomRightButtons => BottomBar}/KeyBindsDialog.css (100%) rename src/pages/MindMap/overlays/{BottomRightButtons => BottomBar}/KeyBindsDialog.tsx (100%) create mode 100644 src/pages/MindMap/overlays/BottomBar/index.tsx delete mode 100644 src/pages/MindMap/overlays/BottomRightButtons/index.tsx delete mode 100644 src/pages/MindMap/overlays/SideMenu/DrawerListItem.tsx delete mode 100644 src/pages/MindMap/overlays/SideMenu/SettingsButton.tsx delete mode 100644 src/pages/MindMap/overlays/SideMenu/SettingsDialog.tsx delete mode 100644 src/pages/MindMap/overlays/SideMenu/SideMenu.tsx delete mode 100644 src/pages/MindMap/overlays/TestFunctionButton/TestFunctionButton.tsx diff --git a/.env b/.env new file mode 100644 index 0000000..2a194dd --- /dev/null +++ b/.env @@ -0,0 +1,18 @@ +REACT_APP_FIREBASE_API_KEY = AIzaSyAcH2oqXkfT2gJjbgmQeU62GmHy78PXyww +REACT_APP_FIREBASE_AUTH_DOMAIN = bubblemap-app.firebaseapp.com +REACT_APP_FIREBASE_PROJECT_ID = bubblemap-app +REACT_APP_FIREBASE_STORAGE_BUCKET = bubblemap-app.appspot.com +REACT_APP_FIREBASE_MESSAGING_SENDER_ID = 961385019430 +REACT_APP_FIREBASE_APP_ID = 1:961385019430:web:d81b367e47eaecfc430ee7 +REACT_APP_FIREBASE_MEASUREMENT_ID = G-EYXHSKR3ZV + +REACT_APP_FIREBASE_API_KEY_DEV = AIzaSyD-oEhhMx9GRPYa1Dn6qhFR_yBV18KOY8Q +REACT_APP_FIREBASE_AUTH_DOMAIN_DEV = mind-map-testing.firebaseapp.com +REACT_APP_FIREBASE_PROJECT_ID_DEV = mind-map-testing +REACT_APP_FIREBASE_STORAGE_BUCKET_DEV = mind-map-testing.appspot.com +REACT_APP_FIREBASE_MESSAGING_SENDER_ID_DEV = 427950169016 +REACT_APP_FIREBASE_APP_ID_DEV = 1:427950169016:web:ca279979776510972d0d4d +REACT_APP_FIREBASE_MEASUREMENT_ID_DEV = G-GZZRF9XDMM + + +GENERATE_SOURCEMAP=false diff --git a/.env.development b/.env.development deleted file mode 100644 index 4f25280..0000000 --- a/.env.development +++ /dev/null @@ -1,7 +0,0 @@ -REACT_APP_FIREBASE_API_KEY = AIzaSyD-oEhhMx9GRPYa1Dn6qhFR_yBV18KOY8Q -REACT_APP_FIREBASE_AUTH_DOMAIN = mind-map-testing.firebaseapp.com -REACT_APP_FIREBASE_PROJECT_ID = mind-map-testing -REACT_APP_FIREBASE_STORAGE_BUCKET = mind-map-testing.appspot.com -REACT_APP_FIREBASE_MESSAGING_SENDER_ID = 427950169016 -REACT_APP_FIREBASE_APP_ID = 1:427950169016:web:ca279979776510972d0d4d -REACT_APP_FIREBASE_MEASUREMENT_ID = G-GZZRF9XDMM diff --git a/.env.production b/.env.production deleted file mode 100644 index b1594b1..0000000 --- a/.env.production +++ /dev/null @@ -1,9 +0,0 @@ -REACT_APP_FIREBASE_API_KEY = AIzaSyAcH2oqXkfT2gJjbgmQeU62GmHy78PXyww -REACT_APP_FIREBASE_AUTH_DOMAIN = bubblemap-app.firebaseapp.com -REACT_APP_FIREBASE_PROJECT_ID = bubblemap-app -REACT_APP_FIREBASE_STORAGE_BUCKET = bubblemap-app.appspot.com -REACT_APP_FIREBASE_MESSAGING_SENDER_ID = 961385019430 -REACT_APP_FIREBASE_APP_ID = 1:961385019430:web:d81b367e47eaecfc430ee7 -REACT_APP_FIREBASE_MEASUREMENT_ID = G-EYXHSKR3ZV - -GENERATE_SOURCEMAP=false diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 008cfc9..4fc3d2e 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -11,13 +11,13 @@ 1. Clone the repo ``` - > git clone https://github.com/SpiritSeal/mindmap.git - > cd mindmap + > git clone https://github.com/SpiritSeal/bubblemap.git + > cd bubblemap ``` or - [![Open in Visual Studio Code](https://img.shields.io/static/v1?logo=visualstudiocode&label=&message=Open%20in%20Visual%20Studio%20Code&labelColor=2c2c32&color=007acc&logoColor=007acc)](https://open.vscode.dev/SpiritSeal/mindmap) + [![Open in Visual Studio Code](https://img.shields.io/static/v1?logo=visualstudiocode&label=&message=Open%20in%20Visual%20Studio%20Code&labelColor=2c2c32&color=007acc&logoColor=007acc)](https://open.vscode.dev/SpiritSeal/bubblemap) 1. Install dependencies ``` diff --git a/.gitignore b/.gitignore index 7b04035..48079e0 100644 --- a/.gitignore +++ b/.gitignore @@ -196,5 +196,4 @@ tsconfig.tsbuildinfo *.secret -.env .runtimeconfig.json diff --git a/README.md b/README.md index edcbd08..51d6e8f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ -# Force Directed Mind Map Tree for rapid (Collaborative) idea generation +# Bubble Map + +Force Directed Mind Mapping Tree for rapid (Collaborative) idea generation ## Contributing -Interesting in contributing? Check out the [GitHub repository](https://github.com/SpiritSeal/mindmap) and read our [contributing instructions](https://github.com/SpiritSeal/mindmap/blob/main/.github/CONTRIBUTING.md) +Interesting in contributing? Check out the [GitHub repository](https://github.com/SpiritSeal/bubblemap) and read our [contributing instructions](https://github.com/SpiritSeal/bubblemap/blob/main/.github/CONTRIBUTING.md) diff --git a/public/index.html b/public/index.html index c7d6da0..bc40b67 100644 --- a/public/index.html +++ b/public/index.html @@ -24,7 +24,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - Mind Map + Bubble Map diff --git a/public/manifest.json b/public/manifest.json index 3b985ad..a5b1422 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,6 +1,6 @@ { - "short_name": "Mind Map", - "name": "Mind Map", + "short_name": "Bubble Map", + "name": "Bubble Map", "icons": [], "start_url": ".", "display": "standalone", diff --git a/src/App.tsx b/src/App.tsx index d06cf30..8baca17 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -48,6 +48,7 @@ import Routing from './components/Routing'; import Loading from './components/Loading'; const isDev = process.env.NODE_ENV !== 'production'; +const isPreview = !(window.location.host === 'bubblemap.app'); const firebaseConfig = { apiKey: process.env.REACT_APP_FIREBASE_API_KEY, @@ -59,6 +60,16 @@ const firebaseConfig = { measurementId: process.env.REACT_APP_FIREBASE_MEASUREMENT_ID, }; +const firebaseConfigPreview = { + apiKey: process.env.REACT_APP_FIREBASE_API_KEY_DEV, + authDomain: process.env.REACT_APP_FIREBASE_AUTH_DOMAIN_DEV, + projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID_DEV, + storageBucket: process.env.REACT_APP_FIREBASE_STORAGE_BUCKET_DEV, + messagingSenderId: process.env.REACT_APP_FIREBASE_MESSAGING_SENDER_ID_DEV, + appId: process.env.REACT_APP_FIREBASE_APP_ID_DEV, + measurementId: process.env.REACT_APP_FIREBASE_MEASUREMENT_ID_DEV, +}; + const useInitFirebaseSDKs = (): { loading: boolean; auth: Auth | null; @@ -272,12 +283,12 @@ class ErrorBoundary extends Component { }} > Think you found a bug? Please open a new issue in our GitHub Repo: - https://github.com/SpiritSeal/mindmap + https://github.com/SpiritSeal/bubblemap @@ -290,7 +301,10 @@ class ErrorBoundary extends Component { const App = () => ( }> - + }> diff --git a/src/components/Navigation/index.tsx b/src/components/Navigation/index.tsx index e438381..0fd35a7 100644 --- a/src/components/Navigation/index.tsx +++ b/src/components/Navigation/index.tsx @@ -44,12 +44,12 @@ const Navigation = () => { navigate('/')}> Mind Map Logo - Mind Map + Bubble Map {/* */}
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 ? (
+ ); }; 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 ( -
- - - - - - - - - Sound - - - - - - - - - - - - - - -
- ); -} 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 - - - - - {/* 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; -}) => ; - -export default TestFunctionButton; - -// const TestFunctionButton = (props: { -// function: () => void; -// icon: JSX.Element; -// }) => { -// ; -// };