From 901f616da16b056d1b85e1f5d99e04e91a4adc31 Mon Sep 17 00:00:00 2001 From: Aarron Lee Date: Mon, 8 Jan 2024 09:33:47 -0500 Subject: [PATCH] filter modal per section --- src/components/HhdComponent.tsx | 2 +- src/components/HhdState.tsx | 1 + src/components/HintsAccordion.tsx | 24 +++++++++++++++++------- src/components/HintsModal.tsx | 12 ++++++++---- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/components/HhdComponent.tsx b/src/components/HhdComponent.tsx index 85a85ea..ff853bc 100644 --- a/src/components/HhdComponent.tsx +++ b/src/components/HhdComponent.tsx @@ -80,7 +80,7 @@ const HhdComponent: FC = ({ <> - {title} + {title} {renderChild && diff --git a/src/components/HhdState.tsx b/src/components/HhdState.tsx index 5826399..05c8746 100644 --- a/src/components/HhdState.tsx +++ b/src/components/HhdState.tsx @@ -36,6 +36,7 @@ const HhdState = () => { key={`${statePath}${topIdx}${idx}`} {...plugin} state={state} + childName={pluginName} renderChild={renderChild} statePath={statePath} updateState={setState} diff --git a/src/components/HintsAccordion.tsx b/src/components/HintsAccordion.tsx index 91f6058..8b17aa1 100644 --- a/src/components/HintsAccordion.tsx +++ b/src/components/HintsAccordion.tsx @@ -12,13 +12,17 @@ import { FC } from "react"; type PropType = { settings: { [key: string]: any }; + settingName: string; }; -const SettingsAccordion: FC = ({ settings }) => { +const SettingsAccordion: FC = ({ settings, settingName }) => { return ( - - {Object.keys(settings).map((topLevelStr, idx) => { - const { title, hint, children } = settings[topLevelStr]; + + {Object.keys(settings).map((pluginName, idx) => { + if (pluginName !== settingName) { + return null; + } + const { title, hint, children } = settings[pluginName]; return (

@@ -73,14 +77,20 @@ function renderChild(child: any, key: number) { ); } -const HintsAccordionContainer = () => { +type ContainerProps = { + pluginName: string; +}; + +const HintsAccordionContainer: FC = ({ pluginName }) => { const settings = useSelector(selectHhdSettings); return ( <> {Object.values(settings).map((s, idx) => { - //@ts-ignore - return ; + return ( + //@ts-ignore + + ); })} ); diff --git a/src/components/HintsModal.tsx b/src/components/HintsModal.tsx index 70b8a69..4bc90bc 100644 --- a/src/components/HintsModal.tsx +++ b/src/components/HintsModal.tsx @@ -9,10 +9,14 @@ import { ModalFooter, } from "@chakra-ui/react"; import { InfoIcon } from "@chakra-ui/icons"; -import { useState } from "react"; +import { FC, useState } from "react"; import HintsAccordion from "./HintsAccordion"; -function HintsModal() { +type Props = { + pluginName: string; +}; + +const HintsModal: FC = ({ pluginName }) => { const [open, setIsOpen] = useState(false); const onOpen = () => setIsOpen(true); @@ -30,7 +34,7 @@ function HintsModal() { More Information - + @@ -42,6 +46,6 @@ function HintsModal() { ); -} +}; export default HintsModal;