import { IoMdClose } from "react-icons/io"; import { useEffect, useState } from "react"; import { useContext } from "react"; import { RiSearchLine } from "react-icons/ri"; import rals from "./logic/data/colors.json"; import { MyContext } from "./logic/data/contextapi"; export default function ColorSelector() { const { colorPickerOpened, setColorPickerOpened, setFrameType, setCustomFrameType } = useContext(MyContext); const iconSize = "16px"; const [value, setValue] = useState(""); const handleChange = (event) => setValue(event.target.value); const colors = rals; let resColors = []; for (const [key, value] of Object.entries(colors)) { resColors.push(value); } if (value) { resColors = resColors.filter((x) => x.code.startsWith(value.toLowerCase().trim()) ); } return (
Color selector
setColorPickerOpened(false)} size={iconSize} />
{resColors.map((c) => { return (
{ setFrameType(`./images/custom_colors/${c.img}`); setCustomFrameType({name: c.names.en, color: c.color.hex}) setColorPickerOpened(false); }} key={c.code} className="flex h-5 w-9 text-xs items-center justify-center text-white cursor-pointer" style={{ background: c.color.hex }} > {c.code}
); })}
); }