diff --git a/src/App.css b/src/App.css index 3f8b269..7acb4fb 100644 --- a/src/App.css +++ b/src/App.css @@ -53,6 +53,23 @@ gap: 1rem; } +.modal > .MuiPopover-paper { + overflow: hidden; +} + +.picker-search { + margin: 0.5rem; +} + +.image-grid-wrapper { + overflow: auto; +} + +.image-grid { + margin: 0.5rem; + border-radius: 0.25rem; +} + .buttons { display: flex; align-items: center; @@ -73,4 +90,15 @@ .footer > a:hover { color: rgb(255, 255, 255); -} \ No newline at end of file +} + +::-webkit-scrollbar { + width: 0.5rem; + height: 0.5rem; +} + +::-webkit-scrollbar-thumb { + background-color: white; + border-radius: 1rem; + min-height: 2rem; +} diff --git a/src/App.jsx b/src/App.jsx index eb27b91..10dd4c3 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -162,7 +162,7 @@ ctx.drawImage(img, 0,0, img.width, img.height,centerShift_x,centerShift_y,img.wi onChange={(e, v) => setRotate(v)} min={-10} max={10} - step={1} + step={0.2} track={false} color="secondary" /> diff --git a/src/components/Picker.jsx b/src/components/Picker.jsx index d7c1fe4..8ce0096 100644 --- a/src/components/Picker.jsx +++ b/src/components/Picker.jsx @@ -1,12 +1,30 @@ -import ImageList from "@mui/material/ImageList"; -import ImageListItem from "@mui/material/ImageListItem"; -import Popover from "@mui/material/Popover"; -import Button from "@mui/material/Button"; -import { useState } from "react"; -import characters from "../characters.json"; +import { + ImageList, + ImageListItem, + Popover, + Button, + TextField, +} from "@mui/material"; +import { useState, useEffect } from "react"; +import default_characters from "../characters.json"; export default function Picker({ setCharacter }) { const [anchorEl, setAnchorEl] = useState(null); + const [search, setSearch] = useState(""); + const [characters, setCharacters] = useState(default_characters); + + useEffect(() => { + setCharacters( + default_characters.filter((char) => { + const s = search.toLowerCase(); + return ( + s === char.id || + char.name.toLowerCase().includes(s) || + char.character.toLowerCase().includes(s) + ); + }) + ); + }, [search]); const handleClick = (event) => { setAnchorEl(event.currentTarget); @@ -38,41 +56,57 @@ export default function Picker({ setCharacter }) { vertical: "bottom", horizontal: "left", }} + className="modal" > - - {characters.map((c, index) => ( - { - handleClose(); - setCharacter(index); - }} - sx={{ - cursor: "pointer", - "&:hover": { - opacity: 0.5, - }, - "&:active": { - opacity: 0.8, - }, - }} - > - {c.name} - - ))} - +
+ setSearch(e.target.value)} + /> +
+
+ + {characters.map((c, index) => ( + { + handleClose(); + setCharacter(index); + }} + sx={{ + cursor: "pointer", + "&:hover": { + opacity: 0.5, + }, + "&:active": { + opacity: 0.8, + }, + }} + > + {c.name} + + ))} + +
);