From 4430543e38d4ba98be38da7b422cd2e941723c45 Mon Sep 17 00:00:00 2001 From: fuwaa Date: Wed, 3 Aug 2022 09:51:29 +0800 Subject: [PATCH] feat: add search functionality --- src/components/global/CardTitle.tsx | 3 +-- src/components/options/Sidebar.tsx | 34 +++++++++++++++++++++++++--- src/components/popup/QuickChange.tsx | 2 +- src/views/Options.tsx | 27 ++++++++++++++++------ 4 files changed, 53 insertions(+), 13 deletions(-) diff --git a/src/components/global/CardTitle.tsx b/src/components/global/CardTitle.tsx index e0f79d8..d923aab 100644 --- a/src/components/global/CardTitle.tsx +++ b/src/components/global/CardTitle.tsx @@ -1,9 +1,8 @@ import "../../assets/styles/App.css"; -import chroma from "chroma-js"; interface Props { name: string; color?: string; - textcolor?: string | "#ffffff"; + textcolor?: string | "#000000"; className?: string; } diff --git a/src/components/options/Sidebar.tsx b/src/components/options/Sidebar.tsx index 7b3aa59..e97ad88 100644 --- a/src/components/options/Sidebar.tsx +++ b/src/components/options/Sidebar.tsx @@ -21,6 +21,7 @@ import { AiFillClockCircle, AiFillCloseCircle, AiFillHeart, + AiOutlineSearch, } from "react-icons/ai"; import { MdFormatColorText, MdTextSnippet } from "react-icons/md"; import * as settings from "../../methods/config/colorGroups.js"; @@ -42,10 +43,13 @@ var defaultSettings = Object.entries(baseSettings.settings); interface Props { color: string; setColor: (type: string) => void; + filteredList: string[]; + setFilter: (type: string[]) => void; + setting: string[]; } export default function Sidebar(props: Props) { - var { color, setColor } = props; + var { color, setColor, filteredList, setFilter, setting } = props; react.useLayoutEffect(() => { pintGetUpdate(settings.cg46_6e7681[0], setScaleGray); @@ -231,9 +235,33 @@ export default function Sidebar(props: Props) { chrome.tabs.reload(); } + function settingsFilter(searchquery: string) { + if (searchquery === "") { + setFilter(setting); + } else { + // replace all spaces with underscores + let filteredsearch = searchquery.replace(/\s/g, "_"); + setFilter(setting.filter((s) => s.includes(filteredsearch))); + } + } + return (