diff --git a/src/components/_mobile/collection/Search.tsx b/src/components/_mobile/collection/Search.tsx index 4e6dbfe..ea9ca80 100644 --- a/src/components/_mobile/collection/Search.tsx +++ b/src/components/_mobile/collection/Search.tsx @@ -2,9 +2,9 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import SearchIcon from '@mui/icons-material/Search'; import { - Accordion as MUIAccordion, AccordionDetails, AccordionSummary, Box, Button, Checkbox, Dialog, DialogActions, DialogContent, - Fab, FormControlLabel, FormGroup, InputAdornment, Modal, styled, TextField, ToggleButton, ToggleButtonGroup, - Typography, useTheme, Zoom + Accordion as MuiAccordion, AccordionDetails, AccordionSummary, Box, Button, Checkbox as MuiCheckbox, Dialog, DialogActions, DialogContent, + Fab, FormControlLabel as MuiFCL, FormGroup, InputAdornment, styled, TextField, ToggleButton, ToggleButtonGroup, + Typography, useMediaQuery, useTheme, Zoom } from '@mui/material'; import React, { FormEvent, useEffect, useMemo, useReducer, useRef, useState } from 'react'; import { useHistory, useLocation } from 'react-router-dom'; @@ -12,12 +12,21 @@ import search_api from '../../collection/search/search'; import { ElementIcon, TribeIcon } from '../../Snippets'; import API, { sets } from '../../SpreadsheetData/API'; -const Accordion = styled(MUIAccordion)(() => ({ +const Accordion = styled(MuiAccordion)(() => ({ "&.Mui-expanded": { margin: 0 } })); +const Checkbox = styled(MuiCheckbox)(() => ({ + padding: "4px" +})); + +const FormControlLabel = styled(MuiFCL)(() => ({ + marginLeft: "-4px", + marginRight: "8px" +})); + const initInput = (() => { /* @ts-ignore */ const cardSets: {[key in keyof typeof sets]: boolean} = {}; @@ -53,7 +62,6 @@ const initExpand = ({ const queryList = ["sets", "types", "rarity", "tribes", "elements", "mull", "gender"]; const inputReducer = (state: typeof initInput, newState: Partial) => { - console.log(state, newState); return { ...state, ...newState }; }; @@ -70,6 +78,7 @@ function Search ({ setContent, setInfo }) { const [expand, dispatchExpand] = useReducer(expandReducer, initExpand, parseExpand); const [loaded, setLoaded] = useState(false); const [open, setOpen] = useState(false); + const fullscreen = useMediaQuery("@media (max-width:530px)"); useEffect(() => { setInfo({ 'text': 'Loading..' }); @@ -125,21 +134,11 @@ function Search ({ setContent, setInfo }) { localStorage.setItem("collapsed", JSON.stringify({ ...expand, [field]: isExpanded })); }; - const handleOpen = () => { - setOpen(true); - }; + const handleOpen = () => {setOpen(true)}; - const handleClose = () => { - setOpen(false); - }; - - const transitionDuration = { - enter: theme.transitions.duration.enteringScreen, - exit: theme.transitions.duration.leavingScreen, - }; + const handleClose = () => {setOpen(false)}; const generate = (type: string, row: boolean, label: (item: string) => React.ReactNode) => { - console.log(type, input[type]); return Object.keys(input[type]).map((item, i) => ( @@ -149,13 +148,13 @@ function Search ({ setContent, setInfo }) { const tribes = useMemo(() => ( generate("tribes", true, (item) => - + ) ), [input.tribes]); const elements = useMemo(() => ( generate("elements", true, (item) => - + ).slice(0, -2) ), [input.elements]); @@ -182,7 +181,15 @@ function Search ({ setContent, setInfo }) { - - {((loaded == false) ? <> : ( - - - - - - {dispatchInput({ flavor: !e.target.checked })}} /> - } label="Ignore Flavortext & Artist" /> - - - - } label="Unique" /> - - } label="Loyal" /> - - } label="Legendary" /> - - - } label="Non-Loyal" /> - - {tribes} - - - {elements} - - } label="None" /> - - {dispatchInput({ "elements": { ...input.elements, "and": value }})} } + {(loaded === true) && (<> + + - {(input.elements.none) ? "none" : "or"} - {(input.elements.none) ? "only" : "and"} - - {disciplines} - - }> - Card Type - - - {types} - - - - }> - Rarity - - - {rarity} - - - - }> - Sets - - - {sets} - - - - - + + + + + {dispatchInput({ flavor: !e.target.checked })}} /> + } label="Ignore Flavortext & Artist" /> + + + + } label="Unique" /> + + } label="Loyal" /> + + } label="Legendary" /> + + } label="Non-Loyal" /> + + + {tribes} + + + {elements} + + } label="None" /> + + {dispatchInput({ "elements": { ...input.elements, "and": value }})} } + > + {(input.elements.none) ? "none" : "or"} + {(input.elements.none) ? "only" : "and"} + + + {disciplines} + + } label="Max" /> + + + Energy + + + + + + + Build Points & Mugic Counters/Cost + + + + + + + }> + Card Type + + + {types} + + + + }> + Rarity + + + {rarity} + + + + }> + Sets + + + {sets} + + - - ))} - + + + + + + + )} + ([]); const [info, setInfo] = useState<{text?: string}>({}); const [selected, setSelected] = useState(null); - const isSmall = useMediaQuery(theme.breakpoints.down("sm")); + const isSmall = useMediaQuery(theme.breakpoints.down("sm"), { noSsr: true }); useEffect(() => { const load = localStorage.getItem("collection");