mirror of
https://github.com/chaoticbackup/chaoticbackup.github.io.git
synced 2026-04-26 01:02:54 -05:00
menu increase mobile friendly
This commit is contained in:
parent
5e27dd9d6b
commit
e98e915b1c
|
|
@ -38,7 +38,7 @@ export const CardComponent = (
|
||||||
return (ext === false)
|
return (ext === false)
|
||||||
? (
|
? (
|
||||||
<Card sx={{ display: 'flex',
|
<Card sx={{ display: 'flex',
|
||||||
[theme.breakpoints.down('sm')]: { flexWrap: 'wrap', alignItems: "flex-start" }
|
[theme.breakpoints.down('md')]: { flexWrap: 'wrap', alignItems: "flex-start" }
|
||||||
}} raised>
|
}} raised>
|
||||||
<CardMedia
|
<CardMedia
|
||||||
component="img"
|
component="img"
|
||||||
|
|
@ -51,7 +51,7 @@ export const CardComponent = (
|
||||||
<Box sx={{ marginLeft: .5, marginRight: .5, minWidth: "242px" }}>
|
<Box sx={{ marginLeft: .5, marginRight: .5, minWidth: "242px" }}>
|
||||||
{left}
|
{left}
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ display: "flex", justifyContent: 'space-between' }}>
|
<Box sx={{ display: "flex", flexGrow: 1 }}>
|
||||||
<Box sx={{ marginRight: "auto", flexGrow: 1 }}>
|
<Box sx={{ marginRight: "auto", flexGrow: 1 }}>
|
||||||
{right}
|
{right}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,62 @@
|
||||||
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 MenuIcon from '@mui/icons-material/Menu';
|
||||||
|
import { Drawer, IconButton, MenuItem, MenuList, Toolbar, useTheme } from '@mui/material';
|
||||||
|
import React, { useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
const NavMenu = () => {
|
const NavMenu = () => {
|
||||||
|
const theme = useTheme();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const handleToggle = () => {
|
||||||
|
setOpen((prevOpen) => !prevOpen);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (<>
|
||||||
|
<IconButton
|
||||||
|
size="large"
|
||||||
|
edge="start"
|
||||||
|
color="inherit"
|
||||||
|
aria-label="menu"
|
||||||
|
onClick={handleToggle}
|
||||||
|
sx={{ mr: 1, p: 2,
|
||||||
|
[theme.breakpoints.up("sm")]: {
|
||||||
|
margin: "auto",
|
||||||
|
},
|
||||||
|
[theme.breakpoints.down("sm")]: {
|
||||||
|
// top: `-${theme.spacing(2)}`,
|
||||||
|
marginBottom: 0,
|
||||||
|
marginLeft: 1
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MenuIcon />
|
||||||
|
</IconButton>
|
||||||
|
<Drawer
|
||||||
|
anchor="left"
|
||||||
|
open={open}
|
||||||
|
onClose={handleToggle}
|
||||||
|
>
|
||||||
|
<Toolbar />
|
||||||
|
<MenuList
|
||||||
|
autoFocusItem={open}
|
||||||
|
id="composition-menu"
|
||||||
|
aria-labelledby="composition-button"
|
||||||
|
>
|
||||||
|
<MenuItem component={Link} to="/">Home</MenuItem>
|
||||||
|
<MenuItem onClick={handleToggle}>Collection</MenuItem>
|
||||||
|
<MenuItem component={Link} to="/portal/">Portal</MenuItem>
|
||||||
|
<MenuItem component="a" href="https://chaoticbackup.forumotion.com">Forum</MenuItem>
|
||||||
|
<MenuItem component="a" href="https://chaoticrecode.com">Play</MenuItem>
|
||||||
|
</MenuList>
|
||||||
|
</Drawer>
|
||||||
|
</>);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default NavMenu;
|
||||||
|
|
||||||
|
/*
|
||||||
|
const NavMenu = () => {
|
||||||
|
const theme = useTheme();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const anchorRef = React.useRef<HTMLButtonElement>(null);
|
const anchorRef = React.useRef<HTMLButtonElement>(null);
|
||||||
const prevOpen = React.useRef(open);
|
const prevOpen = React.useRef(open);
|
||||||
|
|
@ -37,6 +90,8 @@ const NavMenu = () => {
|
||||||
prevOpen.current = open;
|
prevOpen.current = open;
|
||||||
}, [open]);
|
}, [open]);
|
||||||
|
|
||||||
|
// TODO change from popper to drawer
|
||||||
|
|
||||||
return (<>
|
return (<>
|
||||||
<IconButton
|
<IconButton
|
||||||
size="large"
|
size="large"
|
||||||
|
|
@ -45,7 +100,12 @@ const NavMenu = () => {
|
||||||
aria-label="menu"
|
aria-label="menu"
|
||||||
ref={anchorRef}
|
ref={anchorRef}
|
||||||
onClick={handleToggle}
|
onClick={handleToggle}
|
||||||
sx={{ margin: "auto", mr: 1, p: 2 }}
|
sx={{ mr: 1, p: 2,
|
||||||
|
[theme.breakpoints.down("sm")]: {
|
||||||
|
top: `-${theme.spacing(2)}`,
|
||||||
|
marginBottom: 0
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<MenuIcon />
|
<MenuIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|
@ -96,4 +156,4 @@ const NavMenu = () => {
|
||||||
</>);
|
</>);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default NavMenu;
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import {
|
import {
|
||||||
AppBar, Box, Card, Checkbox, createTheme, FormControl, FormControlLabel, InputLabel, MenuItem,
|
AppBar, Box, Card, Checkbox, createTheme, FormControl, FormControlLabel, InputLabel, MenuItem,
|
||||||
Pagination, Paper, Select, SelectChangeEvent, Stack, styled, ThemeProvider, Typography
|
Pagination, Paper, Select, SelectChangeEvent, Stack, styled, ThemeProvider, Typography, useMediaQuery
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { Attack, Battlegear, Card as ChaoticCard, Location, Mugic, Creature } from '../../common/definitions';
|
import { Attack, Battlegear, Card as ChaoticCard, Location, Mugic, Creature } from '../../common/definitions';
|
||||||
|
|
@ -19,8 +19,8 @@ let theme = createTheme({
|
||||||
breakpoints: {
|
breakpoints: {
|
||||||
values: {
|
values: {
|
||||||
xs: 0,
|
xs: 0,
|
||||||
sm: 650,
|
sm: 430,
|
||||||
md: 900,
|
md: 650,
|
||||||
lg: 1200,
|
lg: 1200,
|
||||||
xl: 1536,
|
xl: 1536,
|
||||||
}
|
}
|
||||||
|
|
@ -63,6 +63,7 @@ export default function Collection (_props) {
|
||||||
const [content, setContent] = useState<ChaoticCard[]>([]);
|
const [content, setContent] = useState<ChaoticCard[]>([]);
|
||||||
const [info, setInfo] = useState<{text?: string}>({});
|
const [info, setInfo] = useState<{text?: string}>({});
|
||||||
const [selected, setSelected] = useState<ChaoticCard | null>(null);
|
const [selected, setSelected] = useState<ChaoticCard | null>(null);
|
||||||
|
const isSmall = useMediaQuery(theme.breakpoints.down("sm"));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const load = localStorage.getItem("collection");
|
const load = localStorage.getItem("collection");
|
||||||
|
|
@ -122,6 +123,65 @@ export default function Collection (_props) {
|
||||||
setSelected(null);
|
setSelected(null);
|
||||||
}, [content]);
|
}, [content]);
|
||||||
|
|
||||||
|
const TopMenu = () => (<>
|
||||||
|
<Typography>{content.length} results</Typography>
|
||||||
|
<FormControl>
|
||||||
|
<InputLabel htmlFor="per-page">Per Page</InputLabel>
|
||||||
|
<CustomSelect
|
||||||
|
id="per-page"
|
||||||
|
value={n}
|
||||||
|
/* @ts-ignore */
|
||||||
|
onChange={handlePerPage}
|
||||||
|
sx={{ marginLeft: "2px", width: "70px" }}
|
||||||
|
>
|
||||||
|
<MenuItem value={5}>5</MenuItem>
|
||||||
|
<MenuItem value={10}>10</MenuItem>
|
||||||
|
<MenuItem value={25}>25</MenuItem>
|
||||||
|
<MenuItem value={50}>50</MenuItem>
|
||||||
|
</CustomSelect>
|
||||||
|
</FormControl>
|
||||||
|
<Pagination variant="outlined" shape="rounded"
|
||||||
|
count={Math.ceil(content.length / n)}
|
||||||
|
page={p}
|
||||||
|
onChange={handlePage}
|
||||||
|
/>
|
||||||
|
<FormControl>
|
||||||
|
<InputLabel htmlFor="stats-drop">Stats</InputLabel>
|
||||||
|
<CustomSelect
|
||||||
|
id="stats-drop"
|
||||||
|
value={stats}
|
||||||
|
/* @ts-ignore */
|
||||||
|
onChange={hanldeStats}
|
||||||
|
sx={{ width: "106px" }}
|
||||||
|
>
|
||||||
|
<MenuItem value="min">Min</MenuItem>
|
||||||
|
<MenuItem value="avg">Average</MenuItem>
|
||||||
|
<MenuItem value="max">Max</MenuItem>
|
||||||
|
</CustomSelect>
|
||||||
|
</FormControl>
|
||||||
|
<FormControlLabel
|
||||||
|
label="Extended"
|
||||||
|
labelPlacement="start"
|
||||||
|
control={<Checkbox checked={ext} onChange={handleExt} />}
|
||||||
|
sx={{
|
||||||
|
margin: "auto 0",
|
||||||
|
'& > .MuiCheckbox-root': {
|
||||||
|
padding: 0
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<FormControlLabel label="Hide Stats"
|
||||||
|
labelPlacement="start"
|
||||||
|
control={<Checkbox checked={hideStats} onChange={handleHideStats} />}
|
||||||
|
sx={{
|
||||||
|
margin: "auto 0",
|
||||||
|
'& > .MuiCheckbox-root': {
|
||||||
|
padding: 0
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>);
|
||||||
|
|
||||||
return (<ThemeProvider theme={theme}>
|
return (<ThemeProvider theme={theme}>
|
||||||
<Paper square sx={{
|
<Paper square sx={{
|
||||||
minHeight: "100vh", height: "100%",
|
minHeight: "100vh", height: "100%",
|
||||||
|
|
@ -129,82 +189,47 @@ export default function Collection (_props) {
|
||||||
// backgroundColor: "hsl(0deg 0% 97%)"
|
// backgroundColor: "hsl(0deg 0% 97%)"
|
||||||
}}>
|
}}>
|
||||||
<Search {...({ setContent, setInfo })} />
|
<Search {...({ setContent, setInfo })} />
|
||||||
<AppBar color="inherit" sx={{ paddingLeft: theme.spacing(1) }} >
|
<AppBar color="inherit" sx={{ paddingLeft: 0 }} >
|
||||||
<Stack
|
{isSmall ? (<>
|
||||||
direction="row"
|
|
||||||
justifyContent="flex-start"
|
|
||||||
>
|
|
||||||
<NavMenu />
|
|
||||||
<Box sx={{
|
<Box sx={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
width: 'fit-content',
|
width: 'fit-content',
|
||||||
flexWrap: 'wrap',
|
flexWrap: 'wrap',
|
||||||
alignItems: "flex-start",
|
|
||||||
rowGap: theme.spacing(1),
|
rowGap: theme.spacing(1),
|
||||||
columnGap: theme.spacing(1),
|
columnGap: theme.spacing(1),
|
||||||
paddingTop: theme.spacing(2),
|
|
||||||
paddingBottom: theme.spacing(1),
|
paddingBottom: theme.spacing(1),
|
||||||
|
alignItems: "center"
|
||||||
}}>
|
}}>
|
||||||
<Typography>{content.length} results</Typography>
|
<NavMenu />
|
||||||
<FormControl>
|
<TopMenu />
|
||||||
<InputLabel htmlFor="per-page">Per Page</InputLabel>
|
|
||||||
<CustomSelect
|
|
||||||
id="per-page"
|
|
||||||
value={n}
|
|
||||||
/* @ts-ignore */
|
|
||||||
onChange={handlePerPage}
|
|
||||||
sx={{ marginLeft: "2px", width: "70px" }}
|
|
||||||
>
|
|
||||||
<MenuItem value={5}>5</MenuItem>
|
|
||||||
<MenuItem value={10}>10</MenuItem>
|
|
||||||
<MenuItem value={25}>25</MenuItem>
|
|
||||||
<MenuItem value={50}>50</MenuItem>
|
|
||||||
</CustomSelect>
|
|
||||||
</FormControl>
|
|
||||||
<Pagination variant="outlined" shape="rounded"
|
|
||||||
count={Math.ceil(content.length / n)}
|
|
||||||
page={p}
|
|
||||||
onChange={handlePage}
|
|
||||||
/>
|
|
||||||
<FormControl>
|
|
||||||
<InputLabel htmlFor="stats-drop">Stats</InputLabel>
|
|
||||||
<CustomSelect
|
|
||||||
id="stats-drop"
|
|
||||||
value={stats}
|
|
||||||
/* @ts-ignore */
|
|
||||||
onChange={hanldeStats}
|
|
||||||
sx={{ width: "106px" }}
|
|
||||||
>
|
|
||||||
<MenuItem value="min">Min</MenuItem>
|
|
||||||
<MenuItem value="avg">Average</MenuItem>
|
|
||||||
<MenuItem value="max">Max</MenuItem>
|
|
||||||
</CustomSelect>
|
|
||||||
</FormControl>
|
|
||||||
<FormControlLabel
|
|
||||||
label="Extended"
|
|
||||||
labelPlacement="start"
|
|
||||||
control={<Checkbox checked={ext} onChange={handleExt} />}
|
|
||||||
sx={{
|
|
||||||
margin: "auto 0",
|
|
||||||
'& > .MuiCheckbox-root': {
|
|
||||||
padding: 0
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<FormControlLabel label="Hide Stats"
|
|
||||||
labelPlacement="start"
|
|
||||||
control={<Checkbox checked={hideStats} onChange={handleHideStats} />}
|
|
||||||
sx={{
|
|
||||||
margin: "auto 0",
|
|
||||||
'& > .MuiCheckbox-root': {
|
|
||||||
padding: 0
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
</Box>
|
||||||
</Stack>
|
</>): (<>
|
||||||
|
<Stack
|
||||||
|
direction="row"
|
||||||
|
justifyContent="flex-start"
|
||||||
|
>
|
||||||
|
<NavMenu />
|
||||||
|
<Box sx={{
|
||||||
|
display: 'flex',
|
||||||
|
width: 'fit-content',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
alignItems: "center",
|
||||||
|
rowGap: theme.spacing(1),
|
||||||
|
columnGap: theme.spacing(1),
|
||||||
|
paddingTop: theme.spacing(2),
|
||||||
|
paddingBottom: theme.spacing(1),
|
||||||
|
}}>
|
||||||
|
<TopMenu />
|
||||||
|
</Box>
|
||||||
|
</Stack>
|
||||||
|
</>)}
|
||||||
</AppBar>
|
</AppBar>
|
||||||
<Box sx={{ height: "90px" }}/>
|
<Box sx={{
|
||||||
|
["@media (min-width:917px)"]: { height: "58px" },
|
||||||
|
["@media (max-width:917px)"]: { height: "98px" },
|
||||||
|
["@media (max-width:612px)"]: { height: "132px" },
|
||||||
|
["@media (max-width:600px)"]: { height: "152px" }
|
||||||
|
}}/>
|
||||||
{info.text ? (
|
{info.text ? (
|
||||||
<Typography style={{ textAlign: 'left' }}>{info.text}</Typography>
|
<Typography style={{ textAlign: 'left' }}>{info.text}</Typography>
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user