From f4401242f7175951e99fda90637e318f99891984 Mon Sep 17 00:00:00 2001 From: Daniel Date: Wed, 24 Nov 2021 14:23:44 -0500 Subject: [PATCH] added nav menu --- src/components/_mobile/collection/NavMenu.tsx | 99 ++++++++++++ src/components/_mobile/collection/index.tsx | 145 +++++++++--------- src/components/app.js | 7 +- 3 files changed, 176 insertions(+), 75 deletions(-) create mode 100644 src/components/_mobile/collection/NavMenu.tsx diff --git a/src/components/_mobile/collection/NavMenu.tsx b/src/components/_mobile/collection/NavMenu.tsx new file mode 100644 index 0000000..4a76f88 --- /dev/null +++ b/src/components/_mobile/collection/NavMenu.tsx @@ -0,0 +1,99 @@ +import React, { useState, useEffect } from 'react'; +import { ClickAwayListener, Grow, IconButton, MenuItem, MenuList, Paper, Popper } from '@mui/material'; +import MenuIcon from '@mui/icons-material/Menu'; +import { Link } from 'react-router-dom'; + +const NavMenu = () => { + const [open, setOpen] = useState(false); + const anchorRef = React.useRef(null); + const prevOpen = React.useRef(open); + + const handleToggle = () => { + setOpen((prevOpen) => !prevOpen); + }; + + function handleListKeyDown(event: React.KeyboardEvent) { + if (event.key === 'Escape') { + setOpen(false); + } + } + + const handleClose = (event: Event | React.SyntheticEvent) => { + if (anchorRef.current && + anchorRef.current.contains(event.target as HTMLElement) + ) { + return; + } + + setOpen(false); + }; + + // return focus to the button when we transitioned from !open -> open + useEffect(() => { + if (prevOpen.current === true && open === false) { + anchorRef.current!.focus(); + } + + prevOpen.current = open; + }, [open]); + + return (<> + + + + + {({ TransitionProps, placement }) => ( + + + + + Home + Collection + Portal + Forum + Play + + + + + )} + + ); +}; + +export default NavMenu; diff --git a/src/components/_mobile/collection/index.tsx b/src/components/_mobile/collection/index.tsx index 8cdeff8..e66ffd2 100644 --- a/src/components/_mobile/collection/index.tsx +++ b/src/components/_mobile/collection/index.tsx @@ -1,6 +1,6 @@ import { AppBar, Box, Card, Checkbox, createTheme, FormControl, FormControlLabel, InputLabel, MenuItem, - Pagination, Paper, Select, SelectChangeEvent, styled, ThemeProvider, Toolbar, Typography + Pagination, Paper, Select, SelectChangeEvent, Stack, styled, ThemeProvider, Typography } from '@mui/material'; import React, { useEffect, useState } from 'react'; import { Attack, Battlegear, Card as ChaoticCard, Location, Mugic, Creature } from '../../common/definitions'; @@ -10,6 +10,7 @@ import { chaoticCardProps, statsType } from './CardBase'; import CreatureCard from './Creature'; import LocationCard from './Location'; import MugicCard from './Mugic'; +import NavMenu from './NavMenu'; import Search from './Search'; import './collection.scss'; @@ -129,75 +130,81 @@ export default function Collection (_props) { }}> - - {content.length} results - - Per Page - - 5 - 10 - 25 - 50 - - - - - Stats - - Min - Average - Max - - - } - sx={{ - margin: "auto 0", - '& > .MuiCheckbox-root': { - padding: 0 - } - }} - /> - } - sx={{ - margin: "auto 0", - '& > .MuiCheckbox-root': { - padding: 0 - } - }} - /> - + + + + {content.length} results + + Per Page + + 5 + 10 + 25 + 50 + + + + + Stats + + Min + Average + Max + + + } + sx={{ + margin: "auto 0", + '& > .MuiCheckbox-root': { + padding: 0 + } + }} + /> + } + sx={{ + margin: "auto 0", + '& > .MuiCheckbox-root': { + padding: 0 + } + }} + /> + + - + {info.text ? ( {info.text} ) : ( diff --git a/src/components/app.js b/src/components/app.js index 81338c3..f9963be 100644 --- a/src/components/app.js +++ b/src/components/app.js @@ -28,8 +28,7 @@ const Collection = loadable( ); const MobileCollection = loadable( - () => import('./_mobile/collection'), - { fallback: } + () => import('./_mobile/collection') ); export default function App() { @@ -43,10 +42,6 @@ export default function App() { } }, [isMobile]); - useEffect(() => { - console.log("render"); - }, []); - return (