diff --git a/frontend/src/App.css b/frontend/src/App.css index 4068e7a..d612d92 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -1,5 +1,5 @@ div { - box-sizing: border-box + box-sizing: border-box; } .TabPanel { @@ -68,22 +68,27 @@ div { box-sizing: border-box; overflow-x: visible; min-width: 10rem; - width: 100%; flex-grow: 1; } -/* Prevent toolbar from shrinking vertically when media < 600px */ -.MuiToolbar-root { - min-height: 56px !important; - padding-left: 16px !important; - padding-right: 16px !important; +.MenuCard.MuiCard-root { + display: flex; + flex-direction: column; + min-width: 10rem; + flex-grow: 1; + background-color: #1A2536; /* Midnight Blue */ + color: #D3CDBF; /* Warm Gray */ + border-radius: 0; } -@media (min-width: 768px) { - .Controls { - width: 600px; /* or whatever you prefer for a desktop */ - max-width: 80vw; /* Optional: Prevent it from taking up too much space */ - } +.MenuCard.MuiCard-root button { + min-height: 64px; +} +/* Prevent toolbar from shrinking vertically when media < 600px */ +.MuiToolbar-root { + min-height: 72px !important; + padding-left: 16px !important; + padding-right: 16px !important; } .Conversation { diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 286ebbe..0e8002d 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,5 +1,7 @@ import React, { useState, useEffect, useRef, useCallback, ReactElement } from 'react'; +import useMediaQuery from '@mui/material/useMediaQuery'; import FormGroup from '@mui/material/FormGroup'; +import Card from '@mui/material/Card'; import FormControlLabel from '@mui/material/FormControlLabel'; import { styled } from '@mui/material/styles'; import Avatar from '@mui/material/Avatar'; @@ -21,13 +23,13 @@ import AppBar from '@mui/material/AppBar'; import Drawer from '@mui/material/Drawer'; import Toolbar from '@mui/material/Toolbar'; import SettingsIcon from '@mui/icons-material/Settings'; -import CloseIcon from '@mui/icons-material/Close'; import IconButton from '@mui/material/IconButton'; import Box from '@mui/material/Box'; import CssBaseline from '@mui/material/CssBaseline'; import ResetIcon from '@mui/icons-material/History'; import SendIcon from '@mui/icons-material/Send'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; +import MenuIcon from '@mui/icons-material/Menu'; import PropagateLoader from "react-spinners/PropagateLoader"; @@ -320,8 +322,8 @@ const App = () => { const [processing, setProcessing] = useState(false); const [sessionId, setSessionId] = useState(undefined); const [connectionBase,] = useState(getConnectionBase(window.location)) - const [mobileOpen, setMobileOpen] = useState(false); - const [isClosing, setIsClosing] = useState(false); + const [menuOpen, setMenuOpen] = useState(false); + const [isMenuClosing, setIsMenuClosing] = useState(false); const [snackOpen, setSnackOpen] = useState(false); const [snackMessage, setSnackMessage] = useState(""); const [snackSeverity, setSnackSeverity] = useState("success"); @@ -343,6 +345,8 @@ const App = () => { const [resume, setResume] = useState(undefined); const [facts, setFacts] = useState(undefined); const timerRef = useRef(null); + const isDesktop = useMediaQuery('(min-width:600px)'); + const prevIsDesktopRef = useRef(isDesktop); const startCountdown = (seconds: number) => { if (timerRef.current) clearInterval(timerRef.current); @@ -400,6 +404,17 @@ const App = () => { setSnackOpen(true); }, []); + useEffect(() => { + if (prevIsDesktopRef.current === isDesktop) + return; + + if (menuOpen) { + setMenuOpen(false); + } + + prevIsDesktopRef.current = isDesktop; + }, [isDesktop, setMenuOpen, menuOpen]) + // Get the system information useEffect(() => { if (systemInfo !== undefined || sessionId === undefined) { @@ -810,28 +825,76 @@ const App = () => { } }; - const handleDrawerClose = () => { - setIsClosing(true); - setMobileOpen(false); + const handleMenuClose = () => { + setIsMenuClosing(true); + setMenuOpen(false); }; - const handleDrawerTransitionEnd = () => { - setIsClosing(false); + const handleMenuTransitionEnd = () => { + setIsMenuClosing(false); }; - const handleDrawerToggle = () => { - if (!isClosing) { - setMobileOpen(!mobileOpen); + const handleMenuToggle = () => { + if (!isMenuClosing) { + setMenuOpen(!menuOpen); } }; - const drawer = ( + const settingsPanel = ( <> {sessionId !== undefined && systemInfo !== undefined && } ); + const handleTabChange = (event: React.SyntheticEvent, newValue: number) => { + setTab(newValue); + }; + + + const menuDrawer = ( + + + + } + iconPosition="start" /> + + + + } /> + + + ); + const submitQuery = (text: string) => { sendQuery(text); } @@ -1037,10 +1100,6 @@ const App = () => { setSnackOpen(false); }; - const handleTabChange = (event: React.SyntheticEvent, newValue: number) => { - setTab(newValue); - }; - /* toolbar height is 56px + 8px margin-top */ const Offset = styled('div')(({ theme }) => ({ ...theme.mixins.toolbar, minHeight: '64px', height: '64px' })); @@ -1056,45 +1115,67 @@ const App = () => { > { - mobileOpen === false && - - - } iconPosition="start" /> - - - - - - + + { + !isDesktop && - + + + - + } + + { menuOpen === false && + + + } + iconPosition="start" /> + { isDesktop && + + } + {isDesktop && + + } + + }/> + + } } - { - mobileOpen === true && - - - - - - } @@ -1106,13 +1187,12 @@ const App = () => { component="nav" aria-label="mailbox folders" > - {/* The implementation can be swapped with js to avoid SEO duplication of links. */} { }} > - {drawer} + {menuDrawer} @@ -1203,6 +1283,14 @@ const App = () => { + + + + { settingsPanel } + + + +